X11 Modal window support (solution based on windows code).

This commit is contained in:
and3md 2017-08-04 22:05:17 +02:00
parent 7b545992d4
commit 85ae6ebfb5
1 changed files with 28 additions and 0 deletions

View File

@ -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)