diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common.c | 2 | ||||
-rw-r--r-- | src/internal.c | 22 | ||||
-rw-r--r-- | src/mac.m | 9 | ||||
-rw-r--r-- | src/types.h | 1 | ||||
-rw-r--r-- | src/win.c | 10 | ||||
-rw-r--r-- | src/win.h | 1 | ||||
-rw-r--r-- | src/x11.c | 38 | ||||
-rw-r--r-- | src/x11.h | 1 |
8 files changed, 36 insertions, 48 deletions
diff --git a/src/common.c b/src/common.c index 0249e0d..f0292ab 100644 --- a/src/common.c +++ b/src/common.c @@ -256,7 +256,7 @@ puglGetTransientParent(const PuglView* const view) bool puglGetVisible(const PuglView* view) { - return view->stage == PUGL_VIEW_STAGE_MAPPED && + return (view->lastConfigure.style & PUGL_VIEW_STYLE_MAPPED) && !(view->lastConfigure.style & PUGL_VIEW_STYLE_HIDDEN); } diff --git a/src/internal.c b/src/internal.c index f1f2e65..5549cbc 100644 --- a/src/internal.c +++ b/src/internal.c @@ -131,9 +131,9 @@ puglPreRealize(PuglView* const view) PuglStatus puglDispatchSimpleEvent(PuglView* view, const PuglEventType type) { - assert(type == PUGL_REALIZE || type == PUGL_UNREALIZE || type == PUGL_MAP || - type == PUGL_UNMAP || type == PUGL_UPDATE || type == PUGL_CLOSE || - type == PUGL_LOOP_ENTER || type == PUGL_LOOP_LEAVE); + assert(type == PUGL_REALIZE || type == PUGL_UNREALIZE || + type == PUGL_UPDATE || type == PUGL_CLOSE || type == PUGL_LOOP_ENTER || + type == PUGL_LOOP_LEAVE); const PuglEvent event = {{type, 0}}; return puglDispatchEvent(view, &event); @@ -213,22 +213,8 @@ puglDispatchEvent(PuglView* view, const PuglEvent* event) } break; - case PUGL_MAP: - assert(view->stage >= PUGL_VIEW_STAGE_CONFIGURED); - if (view->stage != PUGL_VIEW_STAGE_MAPPED) { - st0 = view->eventFunc(view, event); - view->stage = PUGL_VIEW_STAGE_MAPPED; - } - break; - - case PUGL_UNMAP: - assert(view->stage == PUGL_VIEW_STAGE_MAPPED); - st0 = view->eventFunc(view, event); - view->stage = PUGL_VIEW_STAGE_CONFIGURED; - break; - case PUGL_EXPOSE: - assert(view->stage == PUGL_VIEW_STAGE_MAPPED); + assert(view->stage == PUGL_VIEW_STAGE_CONFIGURED); if (!(st0 = view->backend->enter(view, &event->expose))) { st0 = puglExpose(view, event); st1 = view->backend->leave(view, &event->expose); @@ -187,8 +187,10 @@ getCurrentViewStyleFlags(PuglView* const view) const bool isFullScreen = styleMask & NSWindowStyleMaskFullScreen; const bool isMiniaturized = [view->impl->window isMiniaturized]; const bool isZoomed = [view->impl->window isZoomed]; + const bool isVisible = [view->impl->window isVisible]; - return (isFullScreen ? PUGL_VIEW_STYLE_FULLSCREEN : 0U) | + return (isVisible ? PUGL_VIEW_STYLE_MAPPED : 0U) | + (isFullScreen ? PUGL_VIEW_STYLE_FULLSCREEN : 0U) | (isMiniaturized ? PUGL_VIEW_STYLE_HIDDEN : 0U) | (isZoomed ? (PUGL_VIEW_STYLE_TALL | PUGL_VIEW_STYLE_WIDE) : 0U) | (isResizing ? PUGL_VIEW_STYLE_RESIZING : 0U); @@ -254,11 +256,8 @@ getCurrentViewStyleFlags(PuglView* const view) { [super setIsVisible:flag]; - if (flag && puglview->stage < PUGL_VIEW_STAGE_MAPPED) { + if (flag != (puglview->lastConfigure.style & PUGL_VIEW_STYLE_MAPPED)) { [self dispatchCurrentConfiguration]; - puglDispatchSimpleEvent(puglview, PUGL_MAP); - } else if (!flag && puglview->stage == PUGL_VIEW_STAGE_MAPPED) { - puglDispatchSimpleEvent(puglview, PUGL_UNMAP); } } diff --git a/src/types.h b/src/types.h index 2f6721b..785eae8 100644 --- a/src/types.h +++ b/src/types.h @@ -38,7 +38,6 @@ typedef enum { PUGL_VIEW_STAGE_ALLOCATED, PUGL_VIEW_STAGE_REALIZED, PUGL_VIEW_STAGE_CONFIGURED, - PUGL_VIEW_STAGE_MAPPED, } PuglViewStage; /// Cross-platform view definition @@ -576,7 +576,8 @@ handleConfigure(PuglView* view, PuglEvent* event) event->configure.height = (PuglSpan)height; event->configure.style = - ((view->resizing ? PUGL_VIEW_STYLE_RESIZING : 0U) | + ((view->impl->mapped ? PUGL_VIEW_STYLE_MAPPED : 0U) | + (view->resizing ? PUGL_VIEW_STYLE_RESIZING : 0U) | (view->impl->fullscreen ? PUGL_VIEW_STYLE_FULLSCREEN : 0U) | (view->impl->minimized ? PUGL_VIEW_STYLE_HIDDEN : 0U) | (view->impl->maximized ? (PUGL_VIEW_STYLE_TALL | PUGL_VIEW_STYLE_WIDE) @@ -674,17 +675,14 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_SHOWWINDOW: if (wParam) { - handleConfigure(view, &event); - puglDispatchEvent(view, &event); - event.type = PUGL_NOTHING; - RedrawWindow(view->impl->hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_INTERNALPAINT); } - event.any.type = wParam ? PUGL_MAP : PUGL_UNMAP; + view->impl->mapped = wParam; + handleConfigure(view, &event); break; case WM_DISPLAYCHANGE: view->impl->scaleFactor = puglWinGetViewScaleFactor(view); @@ -28,6 +28,7 @@ struct PuglInternalsImpl { PuglBlob clipboard; PuglSurface* surface; double scaleFactor; + bool mapped; bool flashing; bool mouseTracked; bool minimized; @@ -252,6 +252,7 @@ styleFlagToAtom(PuglWorld* const world, const PuglViewStyleFlag flag) case PUGL_VIEW_STYLE_DEMANDING: return atoms->NET_WM_STATE_DEMANDS_ATTENTION; case PUGL_VIEW_STYLE_RESIZING: + case PUGL_VIEW_STYLE_MAPPED: break; } @@ -645,6 +646,11 @@ puglUnrealize(PuglView* const view) memset(&view->lastConfigure, 0, sizeof(PuglConfigureEvent)); memset(&view->impl->pendingConfigure, 0, sizeof(PuglEvent)); memset(&view->impl->pendingExpose, 0, sizeof(PuglEvent)); + + if (impl->mapped) { + view->impl->pendingConfigure.configure.style |= PUGL_VIEW_STYLE_MAPPED; + } + return PUGL_SUCCESS; } @@ -944,6 +950,10 @@ getCurrentViewStyleFlags(PuglView* const view) } } + if (view->impl->mapped) { + state |= PUGL_VIEW_STYLE_MAPPED; + } + return state; } @@ -972,6 +982,10 @@ makeConfigureEvent(PuglView* const view) if (event.type != PUGL_CONFIGURE) { event = getCurrentConfiguration(view); + } else if (view->impl->mapped) { + event.configure.style |= PUGL_VIEW_STYLE_MAPPED; + } else { + event.configure.style &= ~PUGL_VIEW_STYLE_MAPPED; } return event; @@ -994,7 +1008,7 @@ translatePropertyNotify(PuglView* const view, XPropertyEvent message) // Make a configure event based on the current configuration to update event = makeConfigureEvent(view); - event.configure.style = getCurrentViewStyleFlags(view); + event.configure.style = getCurrentViewStyleFlags(view); // FIXME: necessary? XFree(hints); } @@ -1019,10 +1033,12 @@ translateEvent(PuglView* const view, XEvent xevent) event = makeConfigureEvent(view); break; case MapNotify: - event.type = PUGL_MAP; + view->impl->mapped = true; + event = makeConfigureEvent(view); break; case UnmapNotify: - event.type = PUGL_UNMAP; + view->impl->mapped = false; + event = makeConfigureEvent(view); break; case ConfigureNotify: event = makeConfigureEvent(view); @@ -1508,7 +1524,7 @@ flushExposures(PuglWorld* const world) PuglView* const view = world->views[i]; // Send update event so the application can trigger redraws - if (view->stage == PUGL_VIEW_STAGE_MAPPED) { + if (puglGetVisible(view)) { puglDispatchSimpleEvent(view, PUGL_UPDATE); } @@ -1566,13 +1582,6 @@ handleTimerEvent(PuglWorld* const world, const XEvent xevent) } static PuglStatus -dispatchCurrentConfiguration(PuglView* const view) -{ - const PuglEvent configureEvent = getCurrentConfiguration(view); - return puglDispatchEvent(view, &configureEvent); -} - -static PuglStatus dispatchX11Events(PuglWorld* const world) { PuglStatus st0 = PUGL_SUCCESS; @@ -1625,11 +1634,6 @@ dispatchX11Events(PuglWorld* const world) // Update configure event to be dispatched after loop view->impl->pendingConfigure = event; break; - case PUGL_MAP: - // Dispatch an initial configure (if necessary), then the map event - st0 = dispatchCurrentConfiguration(view); - st1 = puglDispatchEvent(view, &event); - break; case PUGL_EXPOSE: // Expand expose event to be dispatched after loop mergeExposeEvents(&view->impl->pendingExpose.expose, &event.expose); @@ -1723,7 +1727,7 @@ puglPostRedisplayRect(PuglView* const view, const PuglRect rect) if (view->world->impl->dispatchingEvents) { // Currently dispatching events, add/expand expose for the loop end mergeExposeEvents(&view->impl->pendingExpose.expose, &event); - } else if (view->stage == PUGL_VIEW_STAGE_MAPPED) { + } else if (view->stage == PUGL_VIEW_STAGE_CONFIGURED) { // Not dispatching events, send an X expose so we wake up next time PuglEvent exposeEvent = {{PUGL_EXPOSE, 0}}; exposeEvent.expose = event; @@ -84,6 +84,7 @@ struct PuglInternalsImpl { PuglX11Clipboard clipboard; int screen; const char* cursorName; + bool mapped; }; PUGL_WARN_UNUSED_RESULT |