comparison src/video/photon/SDL_ph_video.c @ 753:b14fdadd8311

Date: Thu, 4 Dec 2003 07:48:40 +0200 From: "Mike Gorchak" Subject: SDL/QNX6 new patch Here in attachment my patch for the SDL/QNX6 again :) It contain non-crtitical/cosmetic fixes: 1. Fixed window centering at other than the first consoles. 2. Fixed window centering algorithm in case when window height or width are greater than the desktop resolution. 3. Fixed window positioning on other than the first consoles. 4. Fixed occasional input focus lost when switching to fullscreen. 5. Removed the Photon's default chroma color for the overlays, added RGB(12, 6, 12) color instead (very dark pink). 6. Added more checks to the YUV overlay code (fixed crashes during resolution mode switches). 7. Added support for Enter/Backspace keys in unicode mode (used by Maelstrom and by other games). 8. Fixed window restore/maximize function. It works, finally.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 10 Dec 2003 12:35:56 +0000
parents cbc0f7fabd1c
children b8d311d90021
comparison
equal deleted inserted replaced
752:4bb432a0f6e0 753:b14fdadd8311
184 184
185 static PtWidget_t *ph_CreateWindow(_THIS) 185 static PtWidget_t *ph_CreateWindow(_THIS)
186 { 186 {
187 PtWidget_t *widget; 187 PtWidget_t *widget;
188 188
189 widget = PtCreateWidget(PtWindow, NULL, 0, 0); 189 widget = PtCreateWidget(PtWindow, NULL, 0, NULL);
190 190
191 return widget; 191 return widget;
192 } 192 }
193 193
194 static int ph_SetupWindow(_THIS, int w, int h, int flags) 194 static int ph_SetupWindow(_THIS, int w, int h, int flags)
195 { 195 {
196 PtArg_t args[32]; 196 PtArg_t args[32];
197 PhPoint_t pos = {0, 0}; 197 PhPoint_t pos = {0, 0};
198 PhDim_t* olddim;
198 PhDim_t dim = {w, h}; 199 PhDim_t dim = {w, h};
200 PhRect_t desktopextent;
199 int nargs = 0; 201 int nargs = 0;
200 const char* windowpos; 202 const char* windowpos;
201 const char* iscentered; 203 const char* iscentered;
202 int x, y; 204 int x, y;
203 205
204 PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0); 206 /* check if window size has been changed by Window Manager */
207 PtGetResource(window, Pt_ARG_DIM, &olddim, 0);
208 if ((olddim->w!=w) || (olddim->h!=h))
209 {
210 PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
211 }
205 212
206 if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE) 213 if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
207 { 214 {
208 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE); 215 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
209 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE); 216 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
210 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE); 217 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | Ph_WM_RESTORE);
211 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); 218 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
219 PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
212 } 220 }
213 else 221 else
214 { 222 {
215 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE); 223 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
216 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE); 224 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE);
217 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE); 225 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE);
218 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); 226 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN);
227 PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
219 } 228 }
220 229
221 if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)) 230 if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN))
222 { 231 {
223 if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE) 232 if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
238 247
239 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) 248 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
240 { 249 {
241 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); 250 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
242 PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL); 251 PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
243 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX); 252 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
244 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY); 253 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
245 } 254 }
246 else 255 else
247 { 256 {
248 windowpos = getenv("SDL_VIDEO_WINDOW_POS"); 257 if (!currently_maximized)
249 iscentered = getenv("SDL_VIDEO_CENTERED"); 258 {
250 259 windowpos = getenv("SDL_VIDEO_WINDOW_POS");
251 if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0))) 260 iscentered = getenv("SDL_VIDEO_CENTERED");
252 { 261
253 pos.x = (desktop_mode.width - w)/2; 262 if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
254 pos.y = (desktop_mode.height - h)/2; 263 {
255 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); 264 PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
256 } 265 if (desktop_mode.width>w)
266 {
267 pos.x = (desktop_mode.width - w)/2;
268 }
269 if (desktop_mode.height>h)
270 {
271 pos.y = (desktop_mode.height - h)/2;
272 }
273
274 pos.x+=desktopextent.ul.x;
275 pos.y+=desktopextent.ul.y;
276 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
277 }
278 else
279 {
280 if (windowpos)
281 {
282 if (sscanf(windowpos, "%d,%d", &x, &y) == 2)
283 {
284 if ((x<desktop_mode.width) && (y<desktop_mode.height))
285 {
286 PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
287 pos.x=x+desktopextent.ul.x;
288 pos.y=y+desktopextent.ul.y;
289 }
290 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
291 }
292 }
293 }
294 }
295
296 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
297
298 /* if window is maximized render it as maximized */
299 if (currently_maximized)
300 {
301 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
302 }
257 else 303 else
258 { 304 {
259 if (windowpos) 305 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISMAX);
260 { 306 }
261 if (sscanf(windowpos, "%d,%d", &x, &y) == 2 ) 307
262 { 308 /* do not grab the keyboard by default */
263 pos.x=x; 309 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);
264 pos.y=y; 310
265 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); 311 /* bring the focus to the window */
266 } 312 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);
267 } 313
268 } 314 /* allow to catch hide events */
269
270
271 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
272 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);
273 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE); 315 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
274 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE); 316 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
275 PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
276 } 317 }
277 318
278 PtSetResources(window, nargs, args); 319 PtSetResources(window, nargs, args);
279 PtRealizeWidget(window); 320 PtRealizeWidget(window);
280 PtWindowToFront(window); 321 PtWindowToFront(window);
384 } 425 }
385 } 426 }
386 427
387 currently_fullscreen = 0; 428 currently_fullscreen = 0;
388 currently_hided = 0; 429 currently_hided = 0;
430 currently_maximized = 0;
389 current_overlay = NULL; 431 current_overlay = NULL;
390 432
391 OCImage.direct_context = NULL; 433 OCImage.direct_context = NULL;
392 OCImage.offscreen_context = NULL; 434 OCImage.offscreen_context = NULL;
393 OCImage.offscreen_backcontext = NULL; 435 OCImage.offscreen_backcontext = NULL;
394 OCImage.oldDC = NULL; 436 OCImage.oldDC = NULL;
395 OCImage.CurrentFrameData = NULL; 437 OCImage.CurrentFrameData = NULL;
396 OCImage.FrameData0 = NULL; 438 OCImage.FrameData0 = NULL;
397 OCImage.FrameData1 = NULL; 439 OCImage.FrameData1 = NULL;
398
399 440
400 this->info.wm_available = 1; 441 this->info.wm_available = 1;
401 442
402 return 0; 443 return 0;
403 } 444 }