From 7bc2a5d9ef834d85fcdba861010ae8458299730e Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 19 Jan 2014 01:26:56 +0000 Subject: [PATCH] Import X11 and Win32 code changed by Harrison --- dgl/src/pugl/pugl_win.cpp | 12 +++++++++--- dgl/src/pugl/pugl_x11.c | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dgl/src/pugl/pugl_win.cpp b/dgl/src/pugl/pugl_win.cpp index 4a2344a7..c6d376b9 100644 --- a/dgl/src/pugl/pugl_win.cpp +++ b/dgl/src/pugl/pugl_win.cpp @@ -71,7 +71,7 @@ puglCreate(PuglNativeWindow parent, // Should class be a parameter? Does this make sense on other platforms? static int wc_count = 0; char classNameBuf[256]; - _snprintf(classNameBuf, sizeof(classNameBuf), "%s_%d\n", title, wc_count++); + sprintf(classNameBuf, "%s_%d\n", title, wc_count++); impl->wc.style = CS_OWNDC; impl->wc.lpfnWndProc = wndProc; @@ -91,6 +91,7 @@ puglCreate(PuglNativeWindow parent, } // Adjust the overall window size to accomodate our requested client size + // If there's any doubt that Windows is laughably outdated, here's the proof RECT wr = { 0, 0, width, height }; AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST); @@ -145,7 +146,7 @@ puglDestroy(PuglView* view) free(view); } -static void +void puglReshape(PuglView* view, int width, int height) { wglMakeCurrent(view->impl->hdc, view->impl->hglrc); @@ -266,21 +267,27 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) } break; case WM_LBUTTONDOWN: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 1, true, lParam); break; case WM_MBUTTONDOWN: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 2, true, lParam); break; case WM_RBUTTONDOWN: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 3, true, lParam); break; case WM_LBUTTONUP: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 1, false, lParam); break; case WM_MBUTTONUP: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 2, false, lParam); break; case WM_RBUTTONUP: + view->event_timestamp_ms = (GetMessageTime()); processMouseEvent(view, 3, false, lParam); break; case WM_MOUSEWHEEL: @@ -331,7 +338,6 @@ puglProcessEvents(PuglView* view) handleMessage(view, msg.message, msg.wParam, msg.lParam); } - if (view->redisplay) { InvalidateRect(view->impl->hwnd, NULL, FALSE); } diff --git a/dgl/src/pugl/pugl_x11.c b/dgl/src/pugl/pugl_x11.c index 313409e7..ed1ef249 100644 --- a/dgl/src/pugl/pugl_x11.c +++ b/dgl/src/pugl/pugl_x11.c @@ -163,6 +163,21 @@ puglCreate(PuglNativeWindow parent, XSetWMProtocols(impl->display, impl->win, &wmDelete, 1); } +#if 0 + if (true) { // stay on top + Atom type = XInternAtom(impl->display, "_NET_WM_STATE_ABOVE", False); + XChangeProperty(impl->display, + impl->win, + XInternAtom(impl->display, "_NET_WM_STATE", False), + XInternAtom(impl->display, "ATOM", False), + 32, + PropModeReplace, + (unsigned char *)&type, + 1 + ); + } +#endif + if (visible) { XMapRaised(impl->display, impl->win); } @@ -170,6 +185,7 @@ puglCreate(PuglNativeWindow parent, if (glXIsDirect(impl->display, impl->ctx)) { #ifdef VERBOSE_PUGL printf("puGL: DRI enabled\n"); + printf("If you have drawing issues, try setting LIBGL_ALWAYS_INDIRECT=1 in your environment.\n" ); #endif } else { #ifdef VERBOSE_PUGL @@ -196,7 +212,7 @@ puglDestroy(PuglView* view) free(view); } -static void +void puglReshape(PuglView* view, int width, int height) { glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx); @@ -211,7 +227,7 @@ puglReshape(PuglView* view, int width, int height) view->height = height; } -static void +void puglDisplay(PuglView* view) { glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx);