Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11window.c @ 2876:3fcb0d447bcd
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 17 Dec 2008 07:19:55 +0000 |
parents | 91a7e08cd238 |
children | e705adf6f3dc |
comparison
equal
deleted
inserted
replaced
2875:91a7e08cd238 | 2876:3fcb0d447bcd |
---|---|
285 XCreateColormap(data->display, | 285 XCreateColormap(data->display, |
286 RootWindow(data->display, displaydata->screen), | 286 RootWindow(data->display, displaydata->screen), |
287 visual, AllocNone); | 287 visual, AllocNone); |
288 } | 288 } |
289 | 289 |
290 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) { | 290 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
291 || window->x == SDL_WINDOWPOS_CENTERED) { | |
291 x = (DisplayWidth(data->display, displaydata->screen) - | 292 x = (DisplayWidth(data->display, displaydata->screen) - |
292 window->w) / 2; | 293 window->w) / 2; |
293 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { | 294 } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { |
294 x = 0; | 295 x = 0; |
295 } else { | 296 } else { |
296 x = window->x; | 297 x = window->x; |
297 } | 298 } |
298 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) { | 299 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
300 || window->y == SDL_WINDOWPOS_CENTERED) { | |
299 y = (DisplayHeight(data->display, displaydata->screen) - | 301 y = (DisplayHeight(data->display, displaydata->screen) - |
300 window->h) / 2; | 302 window->h) / 2; |
301 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { | 303 } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { |
302 y = 0; | 304 y = 0; |
303 } else { | 305 } else { |
319 return -1; | 321 return -1; |
320 } | 322 } |
321 | 323 |
322 sizehints = XAllocSizeHints(); | 324 sizehints = XAllocSizeHints(); |
323 if (sizehints) { | 325 if (sizehints) { |
324 if ((window->flags & SDL_WINDOW_RESIZABLE) && !(window->flags & SDL_WINDOW_FULLSCREEN)) { | 326 if ((window->flags & SDL_WINDOW_RESIZABLE) |
327 && !(window->flags & SDL_WINDOW_FULLSCREEN)) { | |
325 sizehints->min_width = 32; | 328 sizehints->min_width = 32; |
326 sizehints->min_height = 32; | 329 sizehints->min_height = 32; |
327 sizehints->max_height = 4096; | 330 sizehints->max_height = 4096; |
328 sizehints->max_width = 4096; | 331 sizehints->max_width = 4096; |
329 } else { | 332 } else { |
340 } | 343 } |
341 XSetWMNormalHints(data->display, w, sizehints); | 344 XSetWMNormalHints(data->display, w, sizehints); |
342 XFree(sizehints); | 345 XFree(sizehints); |
343 } | 346 } |
344 | 347 |
345 if (window->flags & (SDL_WINDOW_BORDERLESS|SDL_WINDOW_FULLSCREEN)) { | 348 if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) { |
346 SDL_bool set; | 349 SDL_bool set; |
347 Atom WM_HINTS; | 350 Atom WM_HINTS; |
348 | 351 |
349 /* We haven't modified the window manager hints yet */ | 352 /* We haven't modified the window manager hints yet */ |
350 set = SDL_FALSE; | 353 set = SDL_FALSE; |
601 SDL_DisplayData *displaydata = | 604 SDL_DisplayData *displaydata = |
602 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; | 605 (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; |
603 Display *display = data->videodata->display; | 606 Display *display = data->videodata->display; |
604 int x, y; | 607 int x, y; |
605 | 608 |
606 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->x == SDL_WINDOWPOS_CENTERED) { | 609 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
610 || window->x == SDL_WINDOWPOS_CENTERED) { | |
607 x = (DisplayWidth(display, displaydata->screen) - window->w) / 2; | 611 x = (DisplayWidth(display, displaydata->screen) - window->w) / 2; |
608 } else { | 612 } else { |
609 x = window->x; | 613 x = window->x; |
610 } | 614 } |
611 if ((window->flags & SDL_WINDOW_FULLSCREEN) || window->y == SDL_WINDOWPOS_CENTERED) { | 615 if ((window->flags & SDL_WINDOW_FULLSCREEN) |
616 || window->y == SDL_WINDOWPOS_CENTERED) { | |
612 y = (DisplayHeight(display, displaydata->screen) - window->h) / 2; | 617 y = (DisplayHeight(display, displaydata->screen) - window->h) / 2; |
613 } else { | 618 } else { |
614 y = window->y; | 619 y = window->y; |
615 } | 620 } |
616 XMoveWindow(display, data->window, x, y); | 621 XMoveWindow(display, data->window, x, y); |
674 X11_SetWindowGrab(_THIS, SDL_Window * window) | 679 X11_SetWindowGrab(_THIS, SDL_Window * window) |
675 { | 680 { |
676 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; | 681 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
677 Display *display = data->videodata->display; | 682 Display *display = data->videodata->display; |
678 | 683 |
679 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED|SDL_WINDOW_FULLSCREEN)) && | 684 if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) |
680 (window->flags & SDL_WINDOW_INPUT_FOCUS)) { | 685 && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { |
681 /* Try to grab the mouse */ | 686 /* Try to grab the mouse */ |
682 for ( ; ; ) { | 687 for (;;) { |
683 int result = XGrabPointer(display, data->window, True, 0, GrabModeAsync, GrabModeAsync, data->window, None, CurrentTime); | 688 int result = |
684 if ( result == GrabSuccess ) { | 689 XGrabPointer(display, data->window, True, 0, GrabModeAsync, |
690 GrabModeAsync, data->window, None, CurrentTime); | |
691 if (result == GrabSuccess) { | |
685 break; | 692 break; |
686 } | 693 } |
687 SDL_Delay(100); | 694 SDL_Delay(100); |
688 } | 695 } |
689 | 696 |
690 /* Raise the window if we grab the mouse */ | 697 /* Raise the window if we grab the mouse */ |
691 XRaiseWindow(display, data->window); | 698 XRaiseWindow(display, data->window); |
692 | 699 |
693 /* Now grab the keyboard */ | 700 /* Now grab the keyboard */ |
694 XGrabKeyboard(display, data->window, True, GrabModeAsync, GrabModeAsync, CurrentTime); | 701 XGrabKeyboard(display, data->window, True, GrabModeAsync, |
702 GrabModeAsync, CurrentTime); | |
695 } else { | 703 } else { |
696 XUngrabPointer(display, CurrentTime); | 704 XUngrabPointer(display, CurrentTime); |
697 XUngrabKeyboard(display, CurrentTime); | 705 XUngrabKeyboard(display, CurrentTime); |
698 } | 706 } |
699 } | 707 } |