Formatting.

This commit is contained in:
Camilla Berglund 2013-04-08 15:16:32 +02:00
parent 8e2e7b37a1
commit 49db3b2a9e
8 changed files with 59 additions and 38 deletions

View File

@ -482,7 +482,7 @@ extern "C" {
#define GLFW_ICONIFIED 0x00020002 #define GLFW_ICONIFIED 0x00020002
#define GLFW_RESIZABLE 0x00022007 #define GLFW_RESIZABLE 0x00022007
#define GLFW_VISIBLE 0x00022008 #define GLFW_VISIBLE 0x00022008
#define GLFW_UNDECORATED 0x00022009 #define GLFW_DECORATED 0x00022009
#define GLFW_CONTEXT_REVISION 0x00020004 #define GLFW_CONTEXT_REVISION 0x00020004
#define GLFW_RED_BITS 0x00021000 #define GLFW_RED_BITS 0x00021000

View File

@ -481,6 +481,24 @@ static int convertMacKeyCode(unsigned int macKeyCode)
@end @end
//------------------------------------------------------------------------
// GLFW window class
//------------------------------------------------------------------------
@interface GLFWWindow : NSWindow {}
@end
@implementation GLFWWindow
- (BOOL)canBecomeKeyWindow
{
// Required for NSBorderlessWindowMask windows
return YES;
}
@end
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// GLFW application class // GLFW application class
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -636,14 +654,6 @@ static GLboolean initializeAppKit(void)
return GL_TRUE; return GL_TRUE;
} }
@interface GLFWWindow : NSWindow {}
@end
@implementation GLFWWindow
- (BOOL)canBecomeKeyWindow {
return YES; // Required for NSBorderlessWindowMask windows.
}
@end
// Create the Cocoa window // Create the Cocoa window
// //
static GLboolean createWindow(_GLFWwindow* window, static GLboolean createWindow(_GLFWwindow* window,
@ -651,7 +661,7 @@ static GLboolean createWindow(_GLFWwindow* window,
{ {
unsigned int styleMask = 0; unsigned int styleMask = 0;
if (wndconfig->monitor || wndconfig->undecorated) if (wndconfig->monitor || !wndconfig->decorated)
styleMask = NSBorderlessWindowMask; styleMask = NSBorderlessWindowMask;
else else
{ {

View File

@ -145,8 +145,8 @@ struct _GLFWhints
int auxBuffers; int auxBuffers;
GLboolean stereo; GLboolean stereo;
GLboolean resizable; GLboolean resizable;
GLboolean undecorated;
GLboolean visible; GLboolean visible;
GLboolean decorated;
int samples; int samples;
GLboolean sRGB; GLboolean sRGB;
int clientAPI; int clientAPI;
@ -171,8 +171,8 @@ struct _GLFWwndconfig
int height; int height;
const char* title; const char* title;
GLboolean resizable; GLboolean resizable;
GLboolean undecorated;
GLboolean visible; GLboolean visible;
GLboolean decorated;
int clientAPI; int clientAPI;
int glMajor; int glMajor;
int glMinor; int glMinor;
@ -218,7 +218,7 @@ struct _GLFWwindow
// Window settings and state // Window settings and state
GLboolean iconified; GLboolean iconified;
GLboolean resizable; GLboolean resizable;
GLboolean undecorated; GLboolean decorated;
GLboolean visible; GLboolean visible;
GLboolean closed; GLboolean closed;
void* userPointer; void* userPointer;

View File

@ -730,6 +730,8 @@ static int createWindow(_GLFWwindow* window,
fullHeight = wndconfig->height; fullHeight = wndconfig->height;
} }
else else
{
if (wndconfig->decorated)
{ {
window->win32.dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; window->win32.dwStyle |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
@ -738,8 +740,9 @@ static int createWindow(_GLFWwindow* window,
window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX; window->win32.dwStyle |= WS_MAXIMIZEBOX | WS_SIZEBOX;
window->win32.dwExStyle |= WS_EX_WINDOWEDGE; window->win32.dwExStyle |= WS_EX_WINDOWEDGE;
} }
}
if (wndconfig->undecorated) { else
{
window->win32.dwStyle = WS_POPUP; window->win32.dwStyle = WS_POPUP;
window->win32.dwExStyle = 0; window->win32.dwExStyle = 0;
} }

View File

@ -176,8 +176,8 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
wndconfig.height = height; wndconfig.height = height;
wndconfig.title = title; wndconfig.title = title;
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE; wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.undecorated = _glfw.hints.undecorated ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE; wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE;
wndconfig.clientAPI = _glfw.hints.clientAPI; wndconfig.clientAPI = _glfw.hints.clientAPI;
wndconfig.glMajor = _glfw.hints.glMajor; wndconfig.glMajor = _glfw.hints.glMajor;
wndconfig.glMinor = _glfw.hints.glMinor; wndconfig.glMinor = _glfw.hints.glMinor;
@ -216,7 +216,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->monitor = wndconfig.monitor; window->monitor = wndconfig.monitor;
window->resizable = wndconfig.resizable; window->resizable = wndconfig.resizable;
window->undecorated = wndconfig.undecorated; window->decorated = wndconfig.decorated;
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
// Save the currently current context so it can be restored later // Save the currently current context so it can be restored later
@ -278,10 +278,10 @@ void glfwDefaultWindowHints(void)
_glfw.hints.glMajor = 1; _glfw.hints.glMajor = 1;
_glfw.hints.glMinor = 0; _glfw.hints.glMinor = 0;
// The default is to show the window and allow window resizing // The default is a visible, resizable window with decorations
_glfw.hints.resizable = GL_TRUE; _glfw.hints.resizable = GL_TRUE;
_glfw.hints.undecorated = GL_FALSE;
_glfw.hints.visible = GL_TRUE; _glfw.hints.visible = GL_TRUE;
_glfw.hints.decorated = GL_TRUE;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
_glfw.hints.redBits = 8; _glfw.hints.redBits = 8;
@ -336,8 +336,8 @@ GLFWAPI void glfwWindowHint(int target, int hint)
case GLFW_RESIZABLE: case GLFW_RESIZABLE:
_glfw.hints.resizable = hint; _glfw.hints.resizable = hint;
break; break;
case GLFW_UNDECORATED: case GLFW_DECORATED:
_glfw.hints.undecorated = hint; _glfw.hints.decorated = hint;
break; break;
case GLFW_VISIBLE: case GLFW_VISIBLE:
_glfw.hints.visible = hint; _glfw.hints.visible = hint;
@ -546,8 +546,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow* handle, int param)
return window->iconified; return window->iconified;
case GLFW_RESIZABLE: case GLFW_RESIZABLE:
return window->resizable; return window->resizable;
case GLFW_UNDECORATED: case GLFW_DECORATED:
return window->undecorated; return window->decorated;
case GLFW_VISIBLE: case GLFW_VISIBLE:
return window->visible; return window->visible;
case GLFW_CLIENT_API: case GLFW_CLIENT_API:

View File

@ -442,6 +442,9 @@ static GLboolean initDisplay(void)
_glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display, _glfw.x11.WM_DELETE_WINDOW = XInternAtom(_glfw.x11.display,
"WM_DELETE_WINDOW", "WM_DELETE_WINDOW",
False); False);
_glfw.x11.MOTIF_WM_HINTS = XInternAtom(_glfw.x11.display,
"_MOTIF_WM_HINTS",
False);
// Check for XF86VidMode extension // Check for XF86VidMode extension
_glfw.x11.vidmode.available = _glfw.x11.vidmode.available =

View File

@ -118,6 +118,7 @@ typedef struct _GLFWlibraryX11
Atom NET_WM_STATE; Atom NET_WM_STATE;
Atom NET_WM_STATE_FULLSCREEN; Atom NET_WM_STATE_FULLSCREEN;
Atom NET_ACTIVE_WINDOW; Atom NET_ACTIVE_WINDOW;
Atom MOTIF_WM_HINTS;
// Selection atoms // Selection atoms
Atom TARGETS; Atom TARGETS;

View File

@ -57,6 +57,7 @@ typedef struct
#define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_DECORATIONS (1L << 1)
// Translates an X Window key to internal coding // Translates an X Window key to internal coding
// //
static int translateKey(int keycode) static int translateKey(int keycode)
@ -140,15 +141,18 @@ static GLboolean createWindow(_GLFWwindow* window,
return GL_FALSE; return GL_FALSE;
} }
if (wndconfig->undecorated) { if (!wndconfig->decorated)
Atom motif_hints_atom = XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False); {
MotifWmHints motif_hints; MotifWmHints hints;
motif_hints.flags = MWM_HINTS_DECORATIONS; hints.flags = MWM_HINTS_DECORATIONS;
motif_hints.decorations = 0; hints.decorations = 0;
XChangeProperty(_glfw.x11.display, window->x11.handle, XChangeProperty(_glfw.x11.display, window->x11.handle,
motif_hints_atom, motif_hints_atom, 32, _glfw.x11.MOTIF_WM_HINTS,
_glfw.x11.MOTIF_WM_HINTS, 32,
PropModeReplace, PropModeReplace,
(unsigned char *)&motif_hints, sizeof(MotifWmHints) / sizeof(long)); (unsigned char*) &hints,
sizeof(MotifWmHints) / sizeof(long));
} }
} }