Added SDL_SetWindowBordered() API.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 13 Sep 2012 01:43:53 -0400
changeset 6422fd0ac1b56115
parent 6421 798d88be4de9
child 6423 339c0ccf6250
Added SDL_SetWindowBordered() API.
include/SDL_video.h
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/bwindow/SDL_BWin.h
src/video/bwindow/SDL_bvideo.cc
src/video/bwindow/SDL_bwindow.cc
src/video/bwindow/SDL_bwindow.h
src/video/cocoa/SDL_cocoavideo.m
src/video/cocoa/SDL_cocoawindow.h
src/video/cocoa/SDL_cocoawindow.m
src/video/directfb/SDL_DirectFB_video.c
src/video/pandora/SDL_pandora.c
src/video/uikit/SDL_uikitvideo.m
src/video/windows/SDL_windowsvideo.c
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
src/video/x11/SDL_x11sym.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11window.c
src/video/x11/SDL_x11window.h
test/common.c
     1.1 --- a/include/SDL_video.h	Thu Sep 13 01:29:18 2012 -0400
     1.2 +++ b/include/SDL_video.h	Thu Sep 13 01:43:53 2012 -0400
     1.3 @@ -84,6 +84,7 @@
     1.4   *  \sa SDL_SetWindowIcon()
     1.5   *  \sa SDL_SetWindowPosition()
     1.6   *  \sa SDL_SetWindowSize()
     1.7 + *  \sa SDL_SetWindowBorder()
     1.8   *  \sa SDL_SetWindowTitle()
     1.9   *  \sa SDL_ShowWindow()
    1.10   */
    1.11 @@ -518,6 +519,23 @@
    1.12                                                 int *h);
    1.13  
    1.14  /**
    1.15 + *  \brief Set the border state of a window.
    1.16 + *
    1.17 + *  This will add or remove the window's SDL_WINDOW_BORDERLESS flag and
    1.18 + *  add or remove the border from the actual window. This is a no-op if the
    1.19 + *  window's border already matches the requested state.
    1.20 + *
    1.21 + *  \param window The window of which to change the border state.
    1.22 + *  \param bordered SDL_FALSE to remove border, SDL_TRUE to add border.
    1.23 + *
    1.24 + *  \note You can't change the border state of a fullscreen window.
    1.25 + *  
    1.26 + *  \sa SDL_GetWindowFlags()
    1.27 + */
    1.28 +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
    1.29 +                                                   SDL_bool bordered);
    1.30 +
    1.31 +/**
    1.32   *  \brief Show a window.
    1.33   *  
    1.34   *  \sa SDL_HideWindow()
     2.1 --- a/src/video/SDL_sysvideo.h	Thu Sep 13 01:29:18 2012 -0400
     2.2 +++ b/src/video/SDL_sysvideo.h	Thu Sep 13 01:43:53 2012 -0400
     2.3 @@ -186,6 +186,7 @@
     2.4      void (*MaximizeWindow) (_THIS, SDL_Window * window);
     2.5      void (*MinimizeWindow) (_THIS, SDL_Window * window);
     2.6      void (*RestoreWindow) (_THIS, SDL_Window * window);
     2.7 +    void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
     2.8      void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
     2.9      int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
    2.10      int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
     3.1 --- a/src/video/SDL_video.c	Thu Sep 13 01:29:18 2012 -0400
     3.2 +++ b/src/video/SDL_video.c	Thu Sep 13 01:43:53 2012 -0400
     3.3 @@ -1491,6 +1491,24 @@
     3.4  }
     3.5  
     3.6  void
     3.7 +SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
     3.8 +{
     3.9 +    CHECK_WINDOW_MAGIC(window, );
    3.10 +    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
    3.11 +        const int want = (bordered != SDL_FALSE);  /* normalize the flag. */
    3.12 +        const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
    3.13 +        if ((want != have) && (_this->SetWindowBordered)) {
    3.14 +            if (want) {
    3.15 +                window->flags &= ~SDL_WINDOW_BORDERLESS;
    3.16 +            } else {
    3.17 +                window->flags |= SDL_WINDOW_BORDERLESS;
    3.18 +            }
    3.19 +            _this->SetWindowBordered(_this, window, (SDL_bool) want);
    3.20 +        }
    3.21 +    }
    3.22 +}
    3.23 +
    3.24 +void
    3.25  SDL_SetWindowSize(SDL_Window * window, int w, int h)
    3.26  {
    3.27      CHECK_WINDOW_MAGIC(window, );
     4.1 --- a/src/video/bwindow/SDL_BWin.h	Thu Sep 13 01:29:18 2012 -0400
     4.2 +++ b/src/video/bwindow/SDL_BWin.h	Thu Sep 13 01:43:53 2012 -0400
     4.3 @@ -55,6 +55,7 @@
     4.4  	BWIN_MINIMIZE_WINDOW,
     4.5  	BWIN_RESTORE_WINDOW,
     4.6  	BWIN_SET_TITLE,
     4.7 +	BWIN_SET_BORDERED,
     4.8  	BWIN_FULLSCREEN
     4.9  };
    4.10  
    4.11 @@ -372,6 +373,9 @@
    4.12      		case BWIN_RESIZE_WINDOW:
    4.13      			_ResizeTo(message);
    4.14      			break;
    4.15 +    		case BWIN_SET_BORDERED:
    4.16 +    			_SetBordered(message);
    4.17 +    			break;
    4.18      		case BWIN_SHOW_WINDOW:
    4.19      			Show();
    4.20      			break;
    4.21 @@ -553,7 +557,15 @@
    4.22  		}
    4.23      	ResizeTo(w, h);
    4.24      }
    4.25 -    
    4.26 +
    4.27 +    void _SetBordered(BMessage *msg) {
    4.28 +    	bool bEnabled;
    4.29 +    	if(msg->FindInt32("window-border", &bEnabled) != B_OK) {
    4.30 +			return;
    4.31 +		}
    4.32 +    	SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
    4.33 +    }
    4.34 +
    4.35      void _Restore() {
    4.36      	if(IsMinimized()) {
    4.37      		Minimize(false);
     5.1 --- a/src/video/bwindow/SDL_bvideo.cc	Thu Sep 13 01:29:18 2012 -0400
     5.2 +++ b/src/video/bwindow/SDL_bvideo.cc	Thu Sep 13 01:43:53 2012 -0400
     5.3 @@ -80,6 +80,7 @@
     5.4      device->MaximizeWindow = BE_MaximizeWindow;
     5.5      device->MinimizeWindow = BE_MinimizeWindow;
     5.6      device->RestoreWindow = BE_RestoreWindow;
     5.7 +    device->SetWindowBordered = BE_SetWindowBordered;
     5.8      device->SetWindowFullscreen = BE_SetWindowFullscreen;
     5.9      device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
    5.10      device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
     6.1 --- a/src/video/bwindow/SDL_bwindow.cc	Thu Sep 13 01:29:18 2012 -0400
     6.2 +++ b/src/video/bwindow/SDL_bwindow.cc	Thu Sep 13 01:43:53 2012 -0400
     6.3 @@ -139,6 +139,12 @@
     6.4  	_ToBeWin(window)->PostMessage(&msg);
     6.5  }
     6.6  
     6.7 +void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
     6.8 +	BMessage msg(BWIN_SET_BORDERED);
     6.9 +	msg.AddBool("window-border", bordered != SDL_FALSE);
    6.10 +	_ToBeWin(window)->PostMessage(&msg);
    6.11 +}
    6.12 +
    6.13  void BE_ShowWindow(_THIS, SDL_Window * window) {
    6.14  	BMessage msg(BWIN_SHOW_WINDOW);
    6.15  	_ToBeWin(window)->PostMessage(&msg);
     7.1 --- a/src/video/bwindow/SDL_bwindow.h	Thu Sep 13 01:29:18 2012 -0400
     7.2 +++ b/src/video/bwindow/SDL_bwindow.h	Thu Sep 13 01:43:53 2012 -0400
     7.3 @@ -38,6 +38,7 @@
     7.4  extern void BE_MaximizeWindow(_THIS, SDL_Window * window);
     7.5  extern void BE_MinimizeWindow(_THIS, SDL_Window * window);
     7.6  extern void BE_RestoreWindow(_THIS, SDL_Window * window);
     7.7 +extern void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
     7.8  extern void BE_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
     7.9  extern int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
    7.10  extern int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
     8.1 --- a/src/video/cocoa/SDL_cocoavideo.m	Thu Sep 13 01:29:18 2012 -0400
     8.2 +++ b/src/video/cocoa/SDL_cocoavideo.m	Thu Sep 13 01:43:53 2012 -0400
     8.3 @@ -100,6 +100,7 @@
     8.4      device->MaximizeWindow = Cocoa_MaximizeWindow;
     8.5      device->MinimizeWindow = Cocoa_MinimizeWindow;
     8.6      device->RestoreWindow = Cocoa_RestoreWindow;
     8.7 +    device->SetWindowFullscreen = Cocoa_SetWindowBordered;
     8.8      device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
     8.9      device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
    8.10      device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
     9.1 --- a/src/video/cocoa/SDL_cocoawindow.h	Thu Sep 13 01:29:18 2012 -0400
     9.2 +++ b/src/video/cocoa/SDL_cocoawindow.h	Thu Sep 13 01:43:53 2012 -0400
     9.3 @@ -102,6 +102,7 @@
     9.4  extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
     9.5  extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
     9.6  extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
     9.7 +extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
     9.8  extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
     9.9  extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
    9.10  extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
    10.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Sep 13 01:29:18 2012 -0400
    10.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Sep 13 01:43:53 2012 -0400
    10.3 @@ -822,6 +822,20 @@
    10.4  }
    10.5  
    10.6  void
    10.7 +Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
    10.8 +{
    10.9 +    /* this message arrived in 10.6. You're out of luck on older OSes. */
   10.10 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
   10.11 +    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   10.12 +    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
   10.13 +    if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
   10.14 +        [nswindow setStyleMask:GetWindowStyle(window)];
   10.15 +    }
   10.16 +    [pool release];
   10.17 +#endif
   10.18 +}
   10.19 +
   10.20 +void
   10.21  Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
   10.22  {
   10.23      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    11.1 --- a/src/video/directfb/SDL_DirectFB_video.c	Thu Sep 13 01:29:18 2012 -0400
    11.2 +++ b/src/video/directfb/SDL_DirectFB_video.c	Thu Sep 13 01:43:53 2012 -0400
    11.3 @@ -132,6 +132,8 @@
    11.4      device->DestroyWindow = DirectFB_DestroyWindow;
    11.5      device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;
    11.6  
    11.7 +    /* !!! FIXME: implement SetWindowBordered */
    11.8 +
    11.9  #if SDL_DIRECTFB_OPENGL
   11.10      device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
   11.11      device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
    12.1 --- a/src/video/pandora/SDL_pandora.c	Thu Sep 13 01:29:18 2012 -0400
    12.2 +++ b/src/video/pandora/SDL_pandora.c	Thu Sep 13 01:43:53 2012 -0400
    12.3 @@ -131,6 +131,8 @@
    12.4      device->GL_DeleteContext = PND_gl_deletecontext;
    12.5      device->PumpEvents = PND_PumpEvents;
    12.6  
    12.7 +    /* !!! FIXME: implement SetWindowBordered */
    12.8 +
    12.9      return device;
   12.10  }
   12.11  
    13.1 --- a/src/video/uikit/SDL_uikitvideo.m	Thu Sep 13 01:29:18 2012 -0400
    13.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Thu Sep 13 01:43:53 2012 -0400
    13.3 @@ -90,6 +90,8 @@
    13.4      device->DestroyWindow = UIKit_DestroyWindow;
    13.5      device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
    13.6  
    13.7 +    /* !!! FIXME: implement SetWindowBordered */
    13.8 +
    13.9      device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
   13.10      device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
   13.11      device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
    14.1 --- a/src/video/windows/SDL_windowsvideo.c	Thu Sep 13 01:29:18 2012 -0400
    14.2 +++ b/src/video/windows/SDL_windowsvideo.c	Thu Sep 13 01:43:53 2012 -0400
    14.3 @@ -125,6 +125,7 @@
    14.4      device->MaximizeWindow = WIN_MaximizeWindow;
    14.5      device->MinimizeWindow = WIN_MinimizeWindow;
    14.6      device->RestoreWindow = WIN_RestoreWindow;
    14.7 +    device->SetWindowBordered = WIN_SetWindowBordered;
    14.8      device->SetWindowFullscreen = WIN_SetWindowFullscreen;
    14.9      device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
   14.10      device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
    15.1 --- a/src/video/windows/SDL_windowswindow.c	Thu Sep 13 01:29:18 2012 -0400
    15.2 +++ b/src/video/windows/SDL_windowswindow.c	Thu Sep 13 01:43:53 2012 -0400
    15.3 @@ -505,6 +505,13 @@
    15.4  }
    15.5  
    15.6  void
    15.7 +WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
    15.8 +{
    15.9 +    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
   15.10 +    SetWindowLong(hwnd, GWL_STYLE, GetWindowStyle(window));
   15.11 +}
   15.12 +
   15.13 +void
   15.14  WIN_RestoreWindow(_THIS, SDL_Window * window)
   15.15  {
   15.16      HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    16.1 --- a/src/video/windows/SDL_windowswindow.h	Thu Sep 13 01:29:18 2012 -0400
    16.2 +++ b/src/video/windows/SDL_windowswindow.h	Thu Sep 13 01:43:53 2012 -0400
    16.3 @@ -57,6 +57,7 @@
    16.4  extern void WIN_MaximizeWindow(_THIS, SDL_Window * window);
    16.5  extern void WIN_MinimizeWindow(_THIS, SDL_Window * window);
    16.6  extern void WIN_RestoreWindow(_THIS, SDL_Window * window);
    16.7 +extern void WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
    16.8  extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
    16.9  extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
   16.10  extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
    17.1 --- a/src/video/x11/SDL_x11sym.h	Thu Sep 13 01:29:18 2012 -0400
    17.2 +++ b/src/video/x11/SDL_x11sym.h	Thu Sep 13 01:43:53 2012 -0400
    17.3 @@ -27,6 +27,7 @@
    17.4  SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
    17.5  SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
    17.6  SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return)
    17.7 +SDL_X11_SYM(Bool,XCheckIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return)
    17.8  SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
    17.9  SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
   17.10  SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
    18.1 --- a/src/video/x11/SDL_x11video.c	Thu Sep 13 01:29:18 2012 -0400
    18.2 +++ b/src/video/x11/SDL_x11video.c	Thu Sep 13 01:43:53 2012 -0400
    18.3 @@ -194,6 +194,7 @@
    18.4      device->MaximizeWindow = X11_MaximizeWindow;
    18.5      device->MinimizeWindow = X11_MinimizeWindow;
    18.6      device->RestoreWindow = X11_RestoreWindow;
    18.7 +    device->SetWindowBordered = X11_SetWindowBordered;
    18.8      device->SetWindowFullscreen = X11_SetWindowFullscreen;
    18.9      device->SetWindowGammaRamp = X11_SetWindowGammaRamp;
   18.10      device->SetWindowGrab = X11_SetWindowGrab;
    19.1 --- a/src/video/x11/SDL_x11window.c	Thu Sep 13 01:29:18 2012 -0400
    19.2 +++ b/src/video/x11/SDL_x11window.c	Thu Sep 13 01:43:53 2012 -0400
    19.3 @@ -247,6 +247,37 @@
    19.4      return 0;
    19.5  }
    19.6  
    19.7 +static void
    19.8 +SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
    19.9 +{
   19.10 +    /*
   19.11 +     * this code used to check for KWM_WIN_DECORATION, but KDE hasn't
   19.12 +     *  supported it for years and years. It now respects _MOTIF_WM_HINTS.
   19.13 +     *  Gnome is similar: just use the Motif atom.
   19.14 +     */
   19.15 +
   19.16 +    Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
   19.17 +    if (WM_HINTS != None) {
   19.18 +        /* Hints used by Motif compliant window managers */
   19.19 +        struct
   19.20 +        {
   19.21 +            unsigned long flags;
   19.22 +            unsigned long functions;
   19.23 +            unsigned long decorations;
   19.24 +            long input_mode;
   19.25 +            unsigned long status;
   19.26 +        } MWMHints = {
   19.27 +            (1L << 1), 0, border ? 1 : 0, 0, 0
   19.28 +        };
   19.29 +
   19.30 +        XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
   19.31 +                        PropModeReplace, (unsigned char *) &MWMHints,
   19.32 +                        sizeof(MWMHints) / 4);
   19.33 +    } else {  /* set the transient hints instead, if necessary */
   19.34 +        XSetTransientForHint(display, window, RootWindow(display, screen));
   19.35 +    }
   19.36 +}
   19.37 +
   19.38  int
   19.39  X11_CreateWindow(_THIS, SDL_Window * window)
   19.40  {
   19.41 @@ -412,88 +443,8 @@
   19.42      }
   19.43  #endif
   19.44  
   19.45 -    if (window->flags & SDL_WINDOW_BORDERLESS) {
   19.46 -        SDL_bool set;
   19.47 -        Atom WM_HINTS;
   19.48 -
   19.49 -        /* We haven't modified the window manager hints yet */
   19.50 -        set = SDL_FALSE;
   19.51 -
   19.52 -        /* First try to set MWM hints */
   19.53 -        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
   19.54 -        if (WM_HINTS != None) {
   19.55 -            /* Hints used by Motif compliant window managers */
   19.56 -            struct
   19.57 -            {
   19.58 -                unsigned long flags;
   19.59 -                unsigned long functions;
   19.60 -                unsigned long decorations;
   19.61 -                long input_mode;
   19.62 -                unsigned long status;
   19.63 -            } MWMHints = {
   19.64 -            (1L << 1), 0, 0, 0, 0};
   19.65 -
   19.66 -            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
   19.67 -                            PropModeReplace, (unsigned char *) &MWMHints,
   19.68 -                            sizeof(MWMHints) / 4);
   19.69 -            set = SDL_TRUE;
   19.70 -        }
   19.71 -        /* Now try to set KWM hints */
   19.72 -        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
   19.73 -        if (WM_HINTS != None) {
   19.74 -            long KWMHints = 0;
   19.75 -
   19.76 -            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
   19.77 -                            PropModeReplace,
   19.78 -                            (unsigned char *) &KWMHints,
   19.79 -                            sizeof(KWMHints) / 4);
   19.80 -            set = SDL_TRUE;
   19.81 -        }
   19.82 -        /* Now try to set GNOME hints */
   19.83 -        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
   19.84 -        if (WM_HINTS != None) {
   19.85 -            long GNOMEHints = 0;
   19.86 -
   19.87 -            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
   19.88 -                            PropModeReplace,
   19.89 -                            (unsigned char *) &GNOMEHints,
   19.90 -                            sizeof(GNOMEHints) / 4);
   19.91 -            set = SDL_TRUE;
   19.92 -        }
   19.93 -        /* Finally set the transient hints if necessary */
   19.94 -        if (!set) {
   19.95 -            XSetTransientForHint(display, w, RootWindow(display, screen));
   19.96 -        }
   19.97 -    } else {
   19.98 -        SDL_bool set;
   19.99 -        Atom WM_HINTS;
  19.100 -
  19.101 -        /* We haven't modified the window manager hints yet */
  19.102 -        set = SDL_FALSE;
  19.103 -
  19.104 -        /* First try to unset MWM hints */
  19.105 -        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
  19.106 -        if (WM_HINTS != None) {
  19.107 -            XDeleteProperty(display, w, WM_HINTS);
  19.108 -            set = SDL_TRUE;
  19.109 -        }
  19.110 -        /* Now try to unset KWM hints */
  19.111 -        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
  19.112 -        if (WM_HINTS != None) {
  19.113 -            XDeleteProperty(display, w, WM_HINTS);
  19.114 -            set = SDL_TRUE;
  19.115 -        }
  19.116 -        /* Now try to unset GNOME hints */
  19.117 -        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
  19.118 -        if (WM_HINTS != None) {
  19.119 -            XDeleteProperty(display, w, WM_HINTS);
  19.120 -            set = SDL_TRUE;
  19.121 -        }
  19.122 -        /* Finally unset the transient hints if necessary */
  19.123 -        if (!set) {
  19.124 -            XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR);
  19.125 -        }
  19.126 -    }
  19.127 +    SetWindowBordered(display, screen, w,
  19.128 +                      (window->flags & SDL_WINDOW_BORDERLESS) == 0);
  19.129  
  19.130      /* Setup the normal size hints */
  19.131      sizehints.flags = 0;
  19.132 @@ -775,6 +726,29 @@
  19.133  {
  19.134      return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
  19.135  }
  19.136 +static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
  19.137 +{
  19.138 +    return ev->type == ConfigureNotify && ev->xunmap.window == *((Window*)win);
  19.139 +}
  19.140 +
  19.141 +void
  19.142 +X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
  19.143 +{
  19.144 +    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  19.145 +    SDL_DisplayData *displaydata =
  19.146 +        (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
  19.147 +    Display *display = data->videodata->display;
  19.148 +    XEvent event;
  19.149 +
  19.150 +    SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
  19.151 +    XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
  19.152 +
  19.153 +    /* make sure these don't make it to the real event queue if they fired here. */
  19.154 +    while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
  19.155 +    while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
  19.156 +
  19.157 +    XFlush(display);
  19.158 +}
  19.159  
  19.160  void
  19.161  X11_ShowWindow(_THIS, SDL_Window * window)
    20.1 --- a/src/video/x11/SDL_x11window.h	Thu Sep 13 01:29:18 2012 -0400
    20.2 +++ b/src/video/x11/SDL_x11window.h	Thu Sep 13 01:43:53 2012 -0400
    20.3 @@ -54,6 +54,7 @@
    20.4  extern void X11_MaximizeWindow(_THIS, SDL_Window * window);
    20.5  extern void X11_MinimizeWindow(_THIS, SDL_Window * window);
    20.6  extern void X11_RestoreWindow(_THIS, SDL_Window * window);
    20.7 +extern void X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
    20.8  extern void X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
    20.9  extern int X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
   20.10  extern void X11_SetWindowGrab(_THIS, SDL_Window * window);
    21.1 --- a/test/common.c	Thu Sep 13 01:29:18 2012 -0400
    21.2 +++ b/test/common.c	Thu Sep 13 01:43:53 2012 -0400
    21.3 @@ -1142,6 +1142,17 @@
    21.4                  }
    21.5              }
    21.6              break;
    21.7 +        case SDLK_b:
    21.8 +            if (event->key.keysym.mod & KMOD_CTRL) {
    21.9 +                /* Ctrl-B toggle window border */
   21.10 +                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
   21.11 +                if (window) {
   21.12 +                    const Uint32 flags = SDL_GetWindowFlags(window);
   21.13 +                    const SDL_bool b = ((flags & SDL_WINDOW_BORDERLESS) != 0);
   21.14 +                    SDL_SetWindowBordered(window, b);
   21.15 +                }
   21.16 +            }
   21.17 +            break;
   21.18          case SDLK_ESCAPE:
   21.19              *done = 1;
   21.20              break;