From 85ae6ebfb59320926ed8e04f72e2631985383a0a Mon Sep 17 00:00:00 2001 From: and3md Date: Fri, 4 Aug 2017 22:05:17 +0200 Subject: [PATCH] X11 Modal window support (solution based on windows code). --- src/dlangui/platforms/x11/x11app.d | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/dlangui/platforms/x11/x11app.d b/src/dlangui/platforms/x11/x11app.d index 50e0770f..10c8d769 100644 --- a/src/dlangui/platforms/x11/x11app.d +++ b/src/dlangui/platforms/x11/x11app.d @@ -1193,6 +1193,7 @@ class X11Platform : Platform { } private X11Window[XWindow] _windowMap; + private X11Window[] _windowList; /** * create window @@ -1210,6 +1211,7 @@ class X11Platform : Platform { int newheight = height; X11Window window = new X11Window(this, windowCaption, parent, flags, newwidth, newheight); _windowMap[window._win] = window; + _windowList ~= window; return window; } @@ -1238,6 +1240,17 @@ class X11Platform : Platform { XSendEvent(x11display2, window._win, false, StructureNotifyMask, &ev); XFlush(x11display2); XUnlockDisplay(x11display2); + + for (uint i = 0; i < _windowList.length; i++) { + if (w is _windowList[i]) { + for (uint j = i; j + 1 < _windowList.length; j++) + _windowList[j] = _windowList[j + 1]; + _windowList[$ - 1] = null; + _windowList.length--; + break; + } + } + } bool handleTimers() { @@ -1648,6 +1661,21 @@ class X11Platform : Platform { } } + /// returns true if there is some modal window opened above this window, and this window should not process mouse/key input and should not allow closing + override bool hasModalWindowsAbove(DWindow w) { + // override in platform specific class + for (uint i = 0; i + 1 < _windowList.length; i++) { + if (_windowList[i] is w) { + for (uint j = i + 1; j < _windowList.length; j++) { + if (_windowList[j].flags & WindowFlag.Modal) + return true; + } + return false; + } + } + return false; + } + /// handle theme change: e.g. reload some themed resources override void onThemeChanged() { foreach(w; _windowMap)