comparison src/video/x11/SDL_x11window.c @ 1956:ba0d62354872

Simplified driver window creation code. Implemented several Cocoa window functions
author Sam Lantinga <slouken@libsdl.org>
date Sat, 29 Jul 2006 21:51:00 +0000
parents 420716272158
children e906da4414a3
comparison
equal deleted inserted replaced
1955:8c6106e45fc1 1956:ba0d62354872
191 XCreateColormap(data->display, 191 XCreateColormap(data->display,
192 RootWindow(data->display, displaydata->screen), 192 RootWindow(data->display, displaydata->screen),
193 visual, AllocNone); 193 visual, AllocNone);
194 } 194 }
195 195
196 if ((window->flags & SDL_WINDOW_FULLSCREEN) || 196 if (window->x == SDL_WINDOWPOS_CENTERED) {
197 window->x == SDL_WINDOWPOS_CENTERED) {
198 x = (DisplayWidth(data->display, displaydata->screen) - 197 x = (DisplayWidth(data->display, displaydata->screen) -
199 window->w) / 2; 198 window->w) / 2;
200 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { 199 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
201 x = 0; 200 x = 0;
202 } else { 201 } else {
203 x = window->x; 202 x = window->x;
204 } 203 }
205 if ((window->flags & SDL_WINDOW_FULLSCREEN) || 204 if (window->y == SDL_WINDOWPOS_CENTERED) {
206 window->y == SDL_WINDOWPOS_CENTERED) {
207 y = (DisplayHeight(data->display, displaydata->screen) - 205 y = (DisplayHeight(data->display, displaydata->screen) -
208 window->h) / 2; 206 window->h) / 2;
209 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { 207 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
210 y = 0; 208 y = 0;
211 } else { 209 } else {
358 356
359 /* Set the input hints so we get keyboard input */ 357 /* Set the input hints so we get keyboard input */
360 wmhints = XAllocWMHints(); 358 wmhints = XAllocWMHints();
361 if (wmhints) { 359 if (wmhints) {
362 wmhints->input = True; 360 wmhints->input = True;
363 if (window->flags & SDL_WINDOW_MINIMIZED) { 361 wmhints->flags = InputHint;
364 wmhints->initial_state = IconicState;
365 } else if (window->flags & SDL_WINDOW_SHOWN) {
366 wmhints->initial_state = NormalState;
367 } else {
368 wmhints->initial_state = WithdrawnState;
369 }
370 wmhints->flags = InputHint | StateHint;
371 XSetWMHints(data->display, w, wmhints); 362 XSetWMHints(data->display, w, wmhints);
372 XFree(wmhints); 363 XFree(wmhints);
373 } 364 }
374 365
375 XSelectInput(data->display, w, 366 XSelectInput(data->display, w,
389 } 380 }
390 381
391 /* Allow the window to be deleted by the window manager */ 382 /* Allow the window to be deleted by the window manager */
392 XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1); 383 XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
393 384
394 /* Finally, show the window */
395 if (window->flags & SDL_WINDOW_SHOWN) {
396 XEvent event;
397
398 XMapRaised(data->display, w);
399 do {
400 XCheckWindowEvent(data->display, w, StructureNotifyMask, &event);
401 } while (event.type != MapNotify);
402 }
403
404 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { 385 if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
405 #ifdef SDL_VIDEO_OPENGL_GLX 386 #ifdef SDL_VIDEO_OPENGL_GLX
406 if (window->flags & SDL_WINDOW_OPENGL) { 387 if (window->flags & SDL_WINDOW_OPENGL) {
407 X11_GL_Shutdown(_this); 388 X11_GL_Shutdown(_this);
408 } 389 }
409 #endif 390 #endif
410 XDestroyWindow(data->display, w); 391 XDestroyWindow(data->display, w);
411 return -1; 392 return -1;
412 } 393 }
413
414 X11_SetWindowTitle(_this, window);
415
416 return 0; 394 return 0;
417 } 395 }
418 396
419 int 397 int
420 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) 398 X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
508 { 486 {
509 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; 487 SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
510 SDL_DisplayData *displaydata = 488 SDL_DisplayData *displaydata =
511 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; 489 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
512 Display *display = data->videodata->display; 490 Display *display = data->videodata->display;
513 int x, y; 491
514 492 XMoveWindow(display, data->window, window->x, window->y);
515 if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
516 window->x == SDL_WINDOWPOS_CENTERED) {
517 x = (DisplayWidth(display, displaydata->screen) - window->w) / 2;
518 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
519 x = 0;
520 } else {
521 x = window->x;
522 }
523 if ((window->flags & SDL_WINDOW_FULLSCREEN) ||
524 window->y == SDL_WINDOWPOS_CENTERED) {
525 y = (DisplayHeight(display, displaydata->screen) - window->h) / 2;
526 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) {
527 y = 0;
528 } else {
529 y = window->y;
530 }
531 XMoveWindow(display, data->window, x, y);
532 } 493 }
533 494
534 void 495 void
535 X11_SetWindowSize(_THIS, SDL_Window * window) 496 X11_SetWindowSize(_THIS, SDL_Window * window)
536 { 497 {