From 92b5ab6bdfc8450ed3c4e4e7006cee949386dcd4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Jan 2023 01:02:07 -0500 Subject: Add support for raising windows --- src/mac.m | 18 +++++++++++++++--- src/win.c | 18 +++++++++++++++--- src/x11.c | 15 +++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mac.m b/src/mac.m index 042832b..307a557 100644 --- a/src/mac.m +++ b/src/mac.m @@ -1311,7 +1311,7 @@ puglUnrealize(PuglView* const view) } PuglStatus -puglShow(PuglView* view) +puglShow(PuglView* view, const PuglShowCommand command) { if (!view->impl->wrapperView) { const PuglStatus st = puglRealize(view); @@ -1320,12 +1320,24 @@ puglShow(PuglView* view) } } - if (![view->impl->window isVisible]) { - [view->impl->window setIsVisible:YES]; + NSWindow* const window = [view->impl->wrapperView window]; + if (![window isVisible]) { + [window setIsVisible:YES]; [view->impl->drawView setNeedsDisplay:YES]; updateViewRect(view); } + switch (command) { + case PUGL_SHOW_PASSIVE: + break; + case PUGL_SHOW_RAISE: + [window orderFront:view->impl->wrapperView]; + break; + case PUGL_SHOW_FORCE_RAISE: + [window orderFrontRegardless]; + break; + } + return PUGL_SUCCESS; } diff --git a/src/win.c b/src/win.c index a0b7901..80a5baf 100644 --- a/src/win.c +++ b/src/win.c @@ -309,7 +309,7 @@ puglUnrealize(PuglView* const view) } PuglStatus -puglShow(PuglView* view) +puglShow(PuglView* view, const PuglShowCommand command) { PuglInternals* impl = view->impl; @@ -320,8 +320,20 @@ puglShow(PuglView* view) } } - ShowWindow(impl->hwnd, SW_SHOWNORMAL); - SetFocus(impl->hwnd); + switch (command) { + case PUGL_SHOW_PASSIVE: + ShowWindow(impl->hwnd, SW_SHOWNOACTIVATE); + break; + case PUGL_SHOW_RAISE: + ShowWindow(impl->hwnd, SW_SHOWNORMAL); + SetActiveWindow(impl->hwnd); + break; + case PUGL_SHOW_FORCE_RAISE: + ShowWindow(impl->hwnd, SW_SHOWNORMAL); + SetForegroundWindow(impl->hwnd); + break; + } + return PUGL_SUCCESS; } diff --git a/src/x11.c b/src/x11.c index 593e8b7..4e8d591 100644 --- a/src/x11.c +++ b/src/x11.c @@ -655,12 +655,23 @@ puglUnrealize(PuglView* const view) } PuglStatus -puglShow(PuglView* const view) +puglShow(PuglView* const view, const PuglShowCommand command) { PuglStatus st = view->impl->win ? PUGL_SUCCESS : puglRealize(view); if (!st) { - XMapRaised(view->world->impl->display, view->impl->win); + switch (command) { + case PUGL_SHOW_PASSIVE: + XMapWindow(view->world->impl->display, view->impl->win); + break; + case PUGL_SHOW_RAISE: + XMapRaised(view->world->impl->display, view->impl->win); + break; + case PUGL_SHOW_FORCE_RAISE: + XMapRaised(view->world->impl->display, view->impl->win); + break; + } + st = puglPostRedisplay(view); } -- cgit v1.2.1