aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bindings/cpp/include/pugl/pugl.hpp10
-rw-r--r--include/pugl/pugl.h29
-rw-r--r--src/common.c2
-rw-r--r--src/internal.c22
-rw-r--r--src/mac.m9
-rw-r--r--src/types.h1
-rw-r--r--src/win.c10
-rw-r--r--src/win.h1
-rw-r--r--src/x11.c38
-rw-r--r--src/x11.h1
-rw-r--r--test/test_show_hide.c15
-rw-r--r--test/test_size.c6
-rw-r--r--test/test_utils.h6
-rw-r--r--test/test_view.c13
14 files changed, 51 insertions, 112 deletions
diff --git a/bindings/cpp/include/pugl/pugl.hpp b/bindings/cpp/include/pugl/pugl.hpp
index e8c9d72..0ce7df7 100644
--- a/bindings/cpp/include/pugl/pugl.hpp
+++ b/bindings/cpp/include/pugl/pugl.hpp
@@ -119,12 +119,6 @@ using UnrealizeEvent = Event<PUGL_UNREALIZE, PuglUnrealizeEvent>;
/// @copydoc PuglConfigureEvent
using ConfigureEvent = Event<PUGL_CONFIGURE, PuglConfigureEvent>;
-/// @copydoc PuglMapEvent
-using MapEvent = Event<PUGL_MAP, PuglMapEvent>;
-
-/// @copydoc PuglUnmapEvent
-using UnmapEvent = Event<PUGL_UNMAP, PuglUnmapEvent>;
-
/// @copydoc PuglUpdateEvent
using UpdateEvent = Event<PUGL_UPDATE, PuglUpdateEvent>;
@@ -680,10 +674,6 @@ private:
return target.onEvent(UnrealizeEvent{event->any});
case PUGL_CONFIGURE:
return target.onEvent(ConfigureEvent{event->configure});
- case PUGL_MAP:
- return target.onEvent(MapEvent{event->any});
- case PUGL_UNMAP:
- return target.onEvent(UnmapEvent{event->any});
case PUGL_UPDATE:
return target.onEvent(UpdateEvent{event->any});
case PUGL_EXPOSE:
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 00dffba..22cdfca 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -79,9 +79,7 @@ typedef enum {
PUGL_NOTHING, ///< No event
PUGL_REALIZE, ///< View realized, a #PuglRealizeEvent
PUGL_UNREALIZE, ///< View unrealizeed, a #PuglUnrealizeEvent
- PUGL_CONFIGURE, ///< View moved/resized, a #PuglConfigureEvent
- PUGL_MAP, ///< View made visible, a #PuglMapEvent
- PUGL_UNMAP, ///< View made invisible, a #PuglUnmapEvent
+ PUGL_CONFIGURE, ///< View configured, a #PuglConfigureEvent
PUGL_UPDATE, ///< View ready to draw, a #PuglUpdateEvent
PUGL_EXPOSE, ///< View must be drawn, a #PuglExposeEvent
PUGL_CLOSE, ///< View will be closed, a #PuglCloseEvent
@@ -218,25 +216,6 @@ typedef struct {
} PuglConfigureEvent;
/**
- View show event.
-
- This event is sent when a view is mapped to the screen and made visible.
-
- This event type has no extra fields.
-*/
-typedef PuglAnyEvent PuglMapEvent;
-
-/**
- View hide event.
-
- This event is sent when a view is unmapped from the screen and made
- invisible.
-
- This event type has no extra fields.
-*/
-typedef PuglAnyEvent PuglUnmapEvent;
-
-/**
Recursive loop enter event.
This event is sent when the window system enters a recursive loop. The main
@@ -1566,12 +1545,6 @@ typedef PuglDestroyEvent PuglEventDestroy;
PUGL_DEPRECATED_BY("PuglConfigureEvent")
typedef PuglConfigureEvent PuglEventConfigure;
-PUGL_DEPRECATED_BY("PuglMapEvent")
-typedef PuglMapEvent PuglEventMap;
-
-PUGL_DEPRECATED_BY("PuglUnmapEvent")
-typedef PuglUnmapEvent PuglEventUnmap;
-
PUGL_DEPRECATED_BY("PuglUpdateEvent")
typedef PuglUpdateEvent PuglEventUpdate;
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);
diff --git a/src/mac.m b/src/mac.m
index 72f5f9c..042832b 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -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
diff --git a/src/win.c b/src/win.c
index b410607..a0b7901 100644
--- a/src/win.c
+++ b/src/win.c
@@ -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);
diff --git a/src/win.h b/src/win.h
index 37ffa72..890d940 100644
--- a/src/win.h
+++ b/src/win.h
@@ -28,6 +28,7 @@ struct PuglInternalsImpl {
PuglBlob clipboard;
PuglSurface* surface;
double scaleFactor;
+ bool mapped;
bool flashing;
bool mouseTracked;
bool minimized;
diff --git a/src/x11.c b/src/x11.c
index 372c167..593e8b7 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -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;
diff --git a/src/x11.h b/src/x11.h
index a048495..e90694a 100644
--- a/src/x11.h
+++ b/src/x11.h
@@ -84,6 +84,7 @@ struct PuglInternalsImpl {
PuglX11Clipboard clipboard;
int screen;
const char* cursorName;
+ bool mapped;
};
PUGL_WARN_UNUSED_RESULT
diff --git a/test/test_show_hide.c b/test/test_show_hide.c
index a5c8622..6664a1e 100644
--- a/test/test_show_hide.c
+++ b/test/test_show_hide.c
@@ -20,7 +20,6 @@
typedef enum {
START,
REALIZED,
- CONFIGURED,
MAPPED,
EXPOSED,
UNMAPPED,
@@ -49,22 +48,16 @@ onEvent(PuglView* view, const PuglEvent* event)
test->state = REALIZED;
break;
case PUGL_CONFIGURE:
- if (test->state == REALIZED) {
- test->state = CONFIGURED;
+ if (event->configure.style & PUGL_VIEW_STYLE_MAPPED) {
+ test->state = MAPPED;
+ } else {
+ test->state = UNMAPPED;
}
break;
- case PUGL_MAP:
- assert(test->state == CONFIGURED || test->state == UNMAPPED);
- test->state = MAPPED;
- break;
case PUGL_EXPOSE:
assert(test->state == MAPPED || test->state == EXPOSED);
test->state = EXPOSED;
break;
- case PUGL_UNMAP:
- assert(test->state == MAPPED || test->state == EXPOSED);
- test->state = UNMAPPED;
- break;
case PUGL_UNREALIZE:
assert(test->state == UNMAPPED);
test->state = UNREALIZED;
diff --git a/test/test_size.c b/test/test_size.c
index ef8b738..f19deb9 100644
--- a/test/test_size.c
+++ b/test/test_size.c
@@ -18,7 +18,6 @@ typedef enum {
START,
REALIZED,
CONFIGURED,
- MAPPED,
UNREALIZED,
} State;
@@ -53,9 +52,6 @@ onEvent(PuglView* view, const PuglEvent* event)
test->configuredFrame.width = event->configure.width;
test->configuredFrame.height = event->configure.height;
break;
- case PUGL_MAP:
- test->state = MAPPED;
- break;
case PUGL_UNREALIZE:
test->state = UNREALIZED;
break;
@@ -96,7 +92,7 @@ main(int argc, char** argv)
// Create and show window
assert(!puglRealize(test.view));
assert(!puglShow(test.view));
- while (test.state < MAPPED) {
+ while (test.state < CONFIGURED) {
assert(!puglUpdate(test.world, -1.0));
}
diff --git a/test/test_utils.h b/test/test_utils.h
index 5655e53..85276fb 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -111,6 +111,8 @@ viewStyleFlagString(const PuglViewStyleFlag state)
return "demanding";
case PUGL_VIEW_STYLE_RESIZING:
return "resizing";
+ case PUGL_VIEW_STYLE_MAPPED:
+ return "mapped";
}
return "unknown";
@@ -132,10 +134,6 @@ printEvent(const PuglEvent* event, const char* prefix, const bool verbose)
return fprintf(stderr, "%sRealize\n", prefix);
case PUGL_UNREALIZE:
return fprintf(stderr, "%sUnrealize\n", prefix);
- case PUGL_MAP:
- return fprintf(stderr, "%sMap\n", prefix);
- case PUGL_UNMAP:
- return fprintf(stderr, "%sUnmap\n", prefix);
case PUGL_KEY_PRESS:
return PRINT("%sKey press code %3u key U+%04X\n",
prefix,
diff --git a/test/test_view.c b/test/test_view.c
index 34bf124..eeedc96 100644
--- a/test/test_view.c
+++ b/test/test_view.c
@@ -16,8 +16,8 @@
typedef enum {
START,
- CREATED,
- MAPPED,
+ REALIZED,
+ CONFIGURED,
UNREALIZED,
} State;
@@ -40,10 +40,11 @@ onEvent(PuglView* view, const PuglEvent* event)
switch (event->type) {
case PUGL_REALIZE:
assert(test->state == START);
- test->state = CREATED;
+ test->state = REALIZED;
break;
- case PUGL_MAP:
- test->state = MAPPED;
+ case PUGL_CONFIGURE:
+ assert(test->state == REALIZED);
+ test->state = CONFIGURED;
break;
case PUGL_UNREALIZE:
test->state = UNREALIZED;
@@ -75,7 +76,7 @@ main(int argc, char** argv)
// Create and show window
assert(!puglRealize(test.view));
assert(!puglShow(test.view));
- while (test.state < MAPPED) {
+ while (test.state < CONFIGURED) {
assert(!puglUpdate(test.world, -1.0));
}