diff options
author | David Robillard <d@drobilla.net> | 2013-03-18 19:49:48 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-03-18 19:49:48 +0000 |
commit | cea41bcb9be36fdfe9d273133996e1622586f27b (patch) | |
tree | e93871a5fc04ad3be78ed37a8d819d875919f68a /pugl | |
parent | d5bfc40d6dd1834d28db9e0739a8286878e3d77a (diff) | |
download | pugl-cea41bcb9be36fdfe9d273133996e1622586f27b.tar.gz pugl-cea41bcb9be36fdfe9d273133996e1622586f27b.tar.bz2 pugl-cea41bcb9be36fdfe9d273133996e1622586f27b.zip |
Addition of visible parameter and other minor fixes from FalkTX.
Diffstat (limited to 'pugl')
-rw-r--r-- | pugl/pugl.h | 8 | ||||
-rw-r--r-- | pugl/pugl_internal.h | 4 | ||||
-rw-r--r-- | pugl/pugl_osx.m | 25 | ||||
-rw-r--r-- | pugl/pugl_win.cpp | 16 | ||||
-rw-r--r-- | pugl/pugl_x11.c | 7 |
5 files changed, 36 insertions, 24 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h index 9be936b..7f68351 100644 --- a/pugl/pugl.h +++ b/pugl/pugl.h @@ -124,7 +124,7 @@ typedef enum { PUGL_KEY_SHIFT, PUGL_KEY_CTRL, PUGL_KEY_ALT, - PUGL_KEY_SUPER, + PUGL_KEY_SUPER } PuglKey; /** @@ -134,7 +134,7 @@ typedef enum { PUGL_MOD_SHIFT = 1, /**< Shift key */ PUGL_MOD_CTRL = 1 << 1, /**< Control key */ PUGL_MOD_ALT = 1 << 2, /**< Alt/Option key */ - PUGL_MOD_SUPER = 1 << 3, /**< Mod4/Command/Windows key */ + PUGL_MOD_SUPER = 1 << 3 /**< Mod4/Command/Windows key */ } PuglMod; /** @@ -219,13 +219,15 @@ typedef void (*PuglSpecialFunc)(PuglView* view, bool press, PuglKey key); @param width Window width in pixels. @param height Window height in pixels. @param resizable Whether window should be user resizable. + @param visible Whether window should be initially visible. */ PUGL_API PuglView* puglCreate(PuglNativeWindow parent, const char* title, int width, int height, - bool resizable); + bool resizable, + bool visible); /** Set the handle to be passed to all callbacks. diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h index 37db9e5..8cdada8 100644 --- a/pugl/pugl_internal.h +++ b/pugl/pugl_internal.h @@ -82,6 +82,10 @@ puglDefaultReshape(PuglView* view, int width, int height) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + return; + + // unused + (void)view; } void diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 5621edc..a9bbd24 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -36,8 +36,6 @@ defer:(BOOL)flag; - (void) setPuglview:(PuglView*)view; - (BOOL) windowShouldClose:(id)sender; -- (void) becomeKeyWindow:(id)sender; -- (BOOL) canBecomeKeyWindow:(id)sender; @end @implementation PuglWindow @@ -74,6 +72,14 @@ @end +void +puglDisplay(PuglView* view) +{ + if (view->displayFunc) { + view->displayFunc(view); + } +} + @interface PuglOpenGLView : NSOpenGLView { int colorBits; @@ -169,9 +175,9 @@ } static unsigned -getModifiers(PuglView* view, NSevent* ev) +getModifiers(PuglView* view, NSEvent* ev) { - const unsigned modifierFlags = [ev modifierFlags] + const unsigned modifierFlags = [ev modifierFlags]; view->event_timestamp_ms = fmod([ev timestamp] * 1000.0, UINT32_MAX); @@ -320,7 +326,8 @@ puglCreate(PuglNativeWindow parent, const char* title, int width, int height, - bool resizable) + bool resizable, + bool visible) { PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); @@ -369,14 +376,6 @@ puglDestroy(PuglView* view) free(view); } -void -puglDisplay(PuglView* view) -{ - if (view->displayFunc) { - view->displayFunc(view); - } -} - PuglStatus puglProcessEvents(PuglView* view) { diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp index ff32cf2..780752b 100644 --- a/pugl/pugl_win.cpp +++ b/pugl/pugl_win.cpp @@ -54,7 +54,8 @@ puglCreate(PuglNativeWindow parent, const char* title, int width, int height, - bool resizable) + bool resizable, + bool visible) { PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); @@ -84,15 +85,19 @@ puglCreate(PuglNativeWindow parent, impl->wc.lpszClassName = classNameBuf; RegisterClass(&impl->wc); + int winFlags = WS_POPUPWINDOW | WS_CAPTION; + if (resizable) { + winFlags |= WS_SIZEBOX; + } + // Adjust the overall window size to accomodate our requested client size RECT wr = { 0, 0, width, height }; - AdjustWindowRectEx( - &wr, WS_SIZEBOX | WS_POPUPWINDOW | WS_CAPTION, FALSE, WS_EX_TOPMOST); + AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST); impl->hwnd = CreateWindowEx( WS_EX_TOPMOST, classNameBuf, title, - WS_VISIBLE | (parent ? WS_CHILD : (WS_SIZEBOX | WS_POPUPWINDOW | WS_CAPTION)), + (addToDesktop ? WS_VISIBLE : 0) | (parent ? WS_CHILD : winFlags), 0, 0, wr.right-wr.left, wr.bottom-wr.top, (HWND)parent, NULL, NULL, NULL); @@ -236,7 +241,6 @@ setModifiers(PuglView* view) static LRESULT handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) { - MSG msg; PAINTSTRUCT ps; PuglKey key; @@ -297,7 +301,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) break; } // else nobreak case WM_KEYUP: - if (key = keySymToSpecial(wParam)) { + if ((key = keySymToSpecial(wParam))) { if (view->specialFunc) { view->specialFunc(view, message == WM_KEYDOWN, key); } diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c index fd61632..d9fccf2 100644 --- a/pugl/pugl_x11.c +++ b/pugl/pugl_x11.c @@ -70,7 +70,8 @@ puglCreate(PuglNativeWindow parent, const char* title, int width, int height, - bool resizable) + bool resizable, + bool visible) { PuglView* view = (PuglView*)calloc(1, sizeof(PuglView)); PuglInternals* impl = (PuglInternals*)calloc(1, sizeof(PuglInternals)); @@ -142,7 +143,9 @@ puglCreate(PuglNativeWindow parent, XSetWMProtocols(impl->display, impl->win, &wmDelete, 1); } - XMapRaised(impl->display, impl->win); + if (visible) { + XMapRaised(impl->display, impl->win); + } if (glXIsDirect(impl->display, impl->ctx)) { printf("DRI enabled\n"); |