Added SDL_SetWindowBordered() API.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 13 Sep 2012 01:43:53 -0400
changeset 6422 fd0ac1b56115
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
--- a/include/SDL_video.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/include/SDL_video.h	Thu Sep 13 01:43:53 2012 -0400
@@ -84,6 +84,7 @@
  *  \sa SDL_SetWindowIcon()
  *  \sa SDL_SetWindowPosition()
  *  \sa SDL_SetWindowSize()
+ *  \sa SDL_SetWindowBorder()
  *  \sa SDL_SetWindowTitle()
  *  \sa SDL_ShowWindow()
  */
@@ -518,6 +519,23 @@
                                                int *h);
 
 /**
+ *  \brief Set the border state of a window.
+ *
+ *  This will add or remove the window's SDL_WINDOW_BORDERLESS flag and
+ *  add or remove the border from the actual window. This is a no-op if the
+ *  window's border already matches the requested state.
+ *
+ *  \param window The window of which to change the border state.
+ *  \param bordered SDL_FALSE to remove border, SDL_TRUE to add border.
+ *
+ *  \note You can't change the border state of a fullscreen window.
+ *  
+ *  \sa SDL_GetWindowFlags()
+ */
+extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
+                                                   SDL_bool bordered);
+
+/**
  *  \brief Show a window.
  *  
  *  \sa SDL_HideWindow()
--- a/src/video/SDL_sysvideo.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/SDL_sysvideo.h	Thu Sep 13 01:43:53 2012 -0400
@@ -186,6 +186,7 @@
     void (*MaximizeWindow) (_THIS, SDL_Window * window);
     void (*MinimizeWindow) (_THIS, SDL_Window * window);
     void (*RestoreWindow) (_THIS, SDL_Window * window);
+    void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered);
     void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
     int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp);
     int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
--- a/src/video/SDL_video.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/SDL_video.c	Thu Sep 13 01:43:53 2012 -0400
@@ -1491,6 +1491,24 @@
 }
 
 void
+SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered)
+{
+    CHECK_WINDOW_MAGIC(window, );
+    if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+        const int want = (bordered != SDL_FALSE);  /* normalize the flag. */
+        const int have = ((window->flags & SDL_WINDOW_BORDERLESS) == 0);
+        if ((want != have) && (_this->SetWindowBordered)) {
+            if (want) {
+                window->flags &= ~SDL_WINDOW_BORDERLESS;
+            } else {
+                window->flags |= SDL_WINDOW_BORDERLESS;
+            }
+            _this->SetWindowBordered(_this, window, (SDL_bool) want);
+        }
+    }
+}
+
+void
 SDL_SetWindowSize(SDL_Window * window, int w, int h)
 {
     CHECK_WINDOW_MAGIC(window, );
--- a/src/video/bwindow/SDL_BWin.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/bwindow/SDL_BWin.h	Thu Sep 13 01:43:53 2012 -0400
@@ -55,6 +55,7 @@
 	BWIN_MINIMIZE_WINDOW,
 	BWIN_RESTORE_WINDOW,
 	BWIN_SET_TITLE,
+	BWIN_SET_BORDERED,
 	BWIN_FULLSCREEN
 };
 
@@ -372,6 +373,9 @@
     		case BWIN_RESIZE_WINDOW:
     			_ResizeTo(message);
     			break;
+    		case BWIN_SET_BORDERED:
+    			_SetBordered(message);
+    			break;
     		case BWIN_SHOW_WINDOW:
     			Show();
     			break;
@@ -553,7 +557,15 @@
 		}
     	ResizeTo(w, h);
     }
-    
+
+    void _SetBordered(BMessage *msg) {
+    	bool bEnabled;
+    	if(msg->FindInt32("window-border", &bEnabled) != B_OK) {
+			return;
+		}
+    	SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
+    }
+
     void _Restore() {
     	if(IsMinimized()) {
     		Minimize(false);
--- a/src/video/bwindow/SDL_bvideo.cc	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/bwindow/SDL_bvideo.cc	Thu Sep 13 01:43:53 2012 -0400
@@ -80,6 +80,7 @@
     device->MaximizeWindow = BE_MaximizeWindow;
     device->MinimizeWindow = BE_MinimizeWindow;
     device->RestoreWindow = BE_RestoreWindow;
+    device->SetWindowBordered = BE_SetWindowBordered;
     device->SetWindowFullscreen = BE_SetWindowFullscreen;
     device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
     device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
--- a/src/video/bwindow/SDL_bwindow.cc	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/bwindow/SDL_bwindow.cc	Thu Sep 13 01:43:53 2012 -0400
@@ -139,6 +139,12 @@
 	_ToBeWin(window)->PostMessage(&msg);
 }
 
+void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
+	BMessage msg(BWIN_SET_BORDERED);
+	msg.AddBool("window-border", bordered != SDL_FALSE);
+	_ToBeWin(window)->PostMessage(&msg);
+}
+
 void BE_ShowWindow(_THIS, SDL_Window * window) {
 	BMessage msg(BWIN_SHOW_WINDOW);
 	_ToBeWin(window)->PostMessage(&msg);
--- a/src/video/bwindow/SDL_bwindow.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/bwindow/SDL_bwindow.h	Thu Sep 13 01:43:53 2012 -0400
@@ -38,6 +38,7 @@
 extern void BE_MaximizeWindow(_THIS, SDL_Window * window);
 extern void BE_MinimizeWindow(_THIS, SDL_Window * window);
 extern void BE_RestoreWindow(_THIS, SDL_Window * window);
+extern void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
 extern void BE_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
 extern int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
 extern int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
--- a/src/video/cocoa/SDL_cocoavideo.m	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/cocoa/SDL_cocoavideo.m	Thu Sep 13 01:43:53 2012 -0400
@@ -100,6 +100,7 @@
     device->MaximizeWindow = Cocoa_MaximizeWindow;
     device->MinimizeWindow = Cocoa_MinimizeWindow;
     device->RestoreWindow = Cocoa_RestoreWindow;
+    device->SetWindowFullscreen = Cocoa_SetWindowBordered;
     device->SetWindowFullscreen = Cocoa_SetWindowFullscreen;
     device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp;
     device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp;
--- a/src/video/cocoa/SDL_cocoawindow.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.h	Thu Sep 13 01:43:53 2012 -0400
@@ -102,6 +102,7 @@
 extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window);
 extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window);
 extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window);
+extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
 extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
 extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
 extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
--- a/src/video/cocoa/SDL_cocoawindow.m	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Sep 13 01:43:53 2012 -0400
@@ -822,6 +822,20 @@
 }
 
 void
+Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
+{
+    /* this message arrived in 10.6. You're out of luck on older OSes. */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+    if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
+        [nswindow setStyleMask:GetWindowStyle(window)];
+    }
+    [pool release];
+#endif
+}
+
+void
 Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
 {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
--- a/src/video/directfb/SDL_DirectFB_video.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/directfb/SDL_DirectFB_video.c	Thu Sep 13 01:43:53 2012 -0400
@@ -132,6 +132,8 @@
     device->DestroyWindow = DirectFB_DestroyWindow;
     device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;
 
+    /* !!! FIXME: implement SetWindowBordered */
+
 #if SDL_DIRECTFB_OPENGL
     device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
     device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
--- a/src/video/pandora/SDL_pandora.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/pandora/SDL_pandora.c	Thu Sep 13 01:43:53 2012 -0400
@@ -131,6 +131,8 @@
     device->GL_DeleteContext = PND_gl_deletecontext;
     device->PumpEvents = PND_PumpEvents;
 
+    /* !!! FIXME: implement SetWindowBordered */
+
     return device;
 }
 
--- a/src/video/uikit/SDL_uikitvideo.m	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/uikit/SDL_uikitvideo.m	Thu Sep 13 01:43:53 2012 -0400
@@ -90,6 +90,8 @@
     device->DestroyWindow = UIKit_DestroyWindow;
     device->GetWindowWMInfo = UIKit_GetWindowWMInfo;
 
+    /* !!! FIXME: implement SetWindowBordered */
+
     device->SDL_HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport;
     device->SDL_ShowScreenKeyboard = UIKit_ShowScreenKeyboard;
     device->SDL_HideScreenKeyboard = UIKit_HideScreenKeyboard;
--- a/src/video/windows/SDL_windowsvideo.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/windows/SDL_windowsvideo.c	Thu Sep 13 01:43:53 2012 -0400
@@ -125,6 +125,7 @@
     device->MaximizeWindow = WIN_MaximizeWindow;
     device->MinimizeWindow = WIN_MinimizeWindow;
     device->RestoreWindow = WIN_RestoreWindow;
+    device->SetWindowBordered = WIN_SetWindowBordered;
     device->SetWindowFullscreen = WIN_SetWindowFullscreen;
     device->SetWindowGammaRamp = WIN_SetWindowGammaRamp;
     device->GetWindowGammaRamp = WIN_GetWindowGammaRamp;
--- a/src/video/windows/SDL_windowswindow.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/windows/SDL_windowswindow.c	Thu Sep 13 01:43:53 2012 -0400
@@ -505,6 +505,13 @@
 }
 
 void
+WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
+{
+    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+    SetWindowLong(hwnd, GWL_STYLE, GetWindowStyle(window));
+}
+
+void
 WIN_RestoreWindow(_THIS, SDL_Window * window)
 {
     HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
--- a/src/video/windows/SDL_windowswindow.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/windows/SDL_windowswindow.h	Thu Sep 13 01:43:53 2012 -0400
@@ -57,6 +57,7 @@
 extern void WIN_MaximizeWindow(_THIS, SDL_Window * window);
 extern void WIN_MinimizeWindow(_THIS, SDL_Window * window);
 extern void WIN_RestoreWindow(_THIS, SDL_Window * window);
+extern void WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
 extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
 extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
 extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
--- a/src/video/x11/SDL_x11sym.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/x11/SDL_x11sym.h	Thu Sep 13 01:43:53 2012 -0400
@@ -27,6 +27,7 @@
 SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return)
 SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return)
 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)
+SDL_X11_SYM(Bool,XCheckIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return)
 SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
 SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return)
 SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return)
--- a/src/video/x11/SDL_x11video.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/x11/SDL_x11video.c	Thu Sep 13 01:43:53 2012 -0400
@@ -194,6 +194,7 @@
     device->MaximizeWindow = X11_MaximizeWindow;
     device->MinimizeWindow = X11_MinimizeWindow;
     device->RestoreWindow = X11_RestoreWindow;
+    device->SetWindowBordered = X11_SetWindowBordered;
     device->SetWindowFullscreen = X11_SetWindowFullscreen;
     device->SetWindowGammaRamp = X11_SetWindowGammaRamp;
     device->SetWindowGrab = X11_SetWindowGrab;
--- a/src/video/x11/SDL_x11window.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/x11/SDL_x11window.c	Thu Sep 13 01:43:53 2012 -0400
@@ -247,6 +247,37 @@
     return 0;
 }
 
+static void
+SetWindowBordered(Display *display, int screen, Window window, SDL_bool border)
+{
+    /*
+     * this code used to check for KWM_WIN_DECORATION, but KDE hasn't
+     *  supported it for years and years. It now respects _MOTIF_WM_HINTS.
+     *  Gnome is similar: just use the Motif atom.
+     */
+
+    Atom WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
+    if (WM_HINTS != None) {
+        /* Hints used by Motif compliant window managers */
+        struct
+        {
+            unsigned long flags;
+            unsigned long functions;
+            unsigned long decorations;
+            long input_mode;
+            unsigned long status;
+        } MWMHints = {
+            (1L << 1), 0, border ? 1 : 0, 0, 0
+        };
+
+        XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32,
+                        PropModeReplace, (unsigned char *) &MWMHints,
+                        sizeof(MWMHints) / 4);
+    } else {  /* set the transient hints instead, if necessary */
+        XSetTransientForHint(display, window, RootWindow(display, screen));
+    }
+}
+
 int
 X11_CreateWindow(_THIS, SDL_Window * window)
 {
@@ -412,88 +443,8 @@
     }
 #endif
 
-    if (window->flags & SDL_WINDOW_BORDERLESS) {
-        SDL_bool set;
-        Atom WM_HINTS;
-
-        /* We haven't modified the window manager hints yet */
-        set = SDL_FALSE;
-
-        /* First try to set MWM hints */
-        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
-        if (WM_HINTS != None) {
-            /* Hints used by Motif compliant window managers */
-            struct
-            {
-                unsigned long flags;
-                unsigned long functions;
-                unsigned long decorations;
-                long input_mode;
-                unsigned long status;
-            } MWMHints = {
-            (1L << 1), 0, 0, 0, 0};
-
-            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
-                            PropModeReplace, (unsigned char *) &MWMHints,
-                            sizeof(MWMHints) / 4);
-            set = SDL_TRUE;
-        }
-        /* Now try to set KWM hints */
-        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
-        if (WM_HINTS != None) {
-            long KWMHints = 0;
-
-            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
-                            PropModeReplace,
-                            (unsigned char *) &KWMHints,
-                            sizeof(KWMHints) / 4);
-            set = SDL_TRUE;
-        }
-        /* Now try to set GNOME hints */
-        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
-        if (WM_HINTS != None) {
-            long GNOMEHints = 0;
-
-            XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
-                            PropModeReplace,
-                            (unsigned char *) &GNOMEHints,
-                            sizeof(GNOMEHints) / 4);
-            set = SDL_TRUE;
-        }
-        /* Finally set the transient hints if necessary */
-        if (!set) {
-            XSetTransientForHint(display, w, RootWindow(display, screen));
-        }
-    } else {
-        SDL_bool set;
-        Atom WM_HINTS;
-
-        /* We haven't modified the window manager hints yet */
-        set = SDL_FALSE;
-
-        /* First try to unset MWM hints */
-        WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
-        if (WM_HINTS != None) {
-            XDeleteProperty(display, w, WM_HINTS);
-            set = SDL_TRUE;
-        }
-        /* Now try to unset KWM hints */
-        WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
-        if (WM_HINTS != None) {
-            XDeleteProperty(display, w, WM_HINTS);
-            set = SDL_TRUE;
-        }
-        /* Now try to unset GNOME hints */
-        WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
-        if (WM_HINTS != None) {
-            XDeleteProperty(display, w, WM_HINTS);
-            set = SDL_TRUE;
-        }
-        /* Finally unset the transient hints if necessary */
-        if (!set) {
-            XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR);
-        }
-    }
+    SetWindowBordered(display, screen, w,
+                      (window->flags & SDL_WINDOW_BORDERLESS) == 0);
 
     /* Setup the normal size hints */
     sizehints.flags = 0;
@@ -775,6 +726,29 @@
 {
     return ev->type == UnmapNotify && ev->xunmap.window == *((Window*)win);
 }
+static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win)
+{
+    return ev->type == ConfigureNotify && ev->xunmap.window == *((Window*)win);
+}
+
+void
+X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    SDL_DisplayData *displaydata =
+        (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
+    Display *display = data->videodata->display;
+    XEvent event;
+
+    SetWindowBordered(display, displaydata->screen, data->xwindow, bordered);
+    XIfEvent(display, &event, &isConfigureNotify, (XPointer)&data->xwindow);
+
+    /* make sure these don't make it to the real event queue if they fired here. */
+    while (XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow)) {}
+    while (XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow)) {}
+
+    XFlush(display);
+}
 
 void
 X11_ShowWindow(_THIS, SDL_Window * window)
--- a/src/video/x11/SDL_x11window.h	Thu Sep 13 01:29:18 2012 -0400
+++ b/src/video/x11/SDL_x11window.h	Thu Sep 13 01:43:53 2012 -0400
@@ -54,6 +54,7 @@
 extern void X11_MaximizeWindow(_THIS, SDL_Window * window);
 extern void X11_MinimizeWindow(_THIS, SDL_Window * window);
 extern void X11_RestoreWindow(_THIS, SDL_Window * window);
+extern void X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
 extern void X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
 extern int X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
 extern void X11_SetWindowGrab(_THIS, SDL_Window * window);
--- a/test/common.c	Thu Sep 13 01:29:18 2012 -0400
+++ b/test/common.c	Thu Sep 13 01:43:53 2012 -0400
@@ -1142,6 +1142,17 @@
                 }
             }
             break;
+        case SDLK_b:
+            if (event->key.keysym.mod & KMOD_CTRL) {
+                /* Ctrl-B toggle window border */
+                SDL_Window *window = SDL_GetWindowFromID(event->key.windowID);
+                if (window) {
+                    const Uint32 flags = SDL_GetWindowFlags(window);
+                    const SDL_bool b = ((flags & SDL_WINDOW_BORDERLESS) != 0);
+                    SDL_SetWindowBordered(window, b);
+                }
+            }
+            break;
         case SDLK_ESCAPE:
             *done = 1;
             break;