mirror of https://github.com/adamdruppe/arsd.git
helpers for webview
This commit is contained in:
parent
d177023e44
commit
dbae090c61
|
@ -1738,18 +1738,21 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
||||||
impl.hwnd = nativeWindow;
|
impl.hwnd = nativeWindow;
|
||||||
else version(X11) {
|
else version(X11) {
|
||||||
impl.window = nativeWindow;
|
impl.window = nativeWindow;
|
||||||
display = XDisplayConnection.get(); // get initial display to not segfault
|
if(nativeWindow)
|
||||||
|
display = XDisplayConnection.get(); // get initial display to not segfault
|
||||||
} else version(OSXCocoa)
|
} else version(OSXCocoa)
|
||||||
throw new NotYetImplementedException();
|
throw new NotYetImplementedException();
|
||||||
else featureNotImplemented();
|
else featureNotImplemented();
|
||||||
// FIXME: set the size correctly
|
// FIXME: set the size correctly
|
||||||
_width = 1;
|
_width = 1;
|
||||||
_height = 1;
|
_height = 1;
|
||||||
nativeMapping[nativeWindow] = this;
|
if(nativeWindow)
|
||||||
|
nativeMapping[nativeWindow] = this;
|
||||||
|
|
||||||
beingOpenKeepsAppOpen = false;
|
beingOpenKeepsAppOpen = false;
|
||||||
|
|
||||||
CapableOfHandlingNativeEvent.nativeHandleMapping[nativeWindow] = this;
|
if(nativeWindow)
|
||||||
|
CapableOfHandlingNativeEvent.nativeHandleMapping[nativeWindow] = this;
|
||||||
_suppressDestruction = true; // so it doesn't try to close
|
_suppressDestruction = true; // so it doesn't try to close
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1826,6 +1829,26 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
||||||
} else static assert(0);
|
} else static assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/++
|
||||||
|
Returns the native window.
|
||||||
|
|
||||||
|
History:
|
||||||
|
Added November 5, 2021 (dub v10.4). Prior to that, you'd have
|
||||||
|
to access it through the `impl` member (which is semi-supported
|
||||||
|
but platform specific and here it is simple enough to offer an accessor).
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
Not implemented outside Windows or X11.
|
||||||
|
+/
|
||||||
|
NativeWindowHandle nativeWindowHandle() {
|
||||||
|
version(X11)
|
||||||
|
return impl.window;
|
||||||
|
else version(Windows)
|
||||||
|
return impl.hwnd;
|
||||||
|
else
|
||||||
|
throw new NotYetImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
private bool isTransient() {
|
private bool isTransient() {
|
||||||
with(WindowTypes)
|
with(WindowTypes)
|
||||||
final switch(windowType) {
|
final switch(windowType) {
|
||||||
|
@ -3012,6 +3035,9 @@ private:
|
||||||
|
|
||||||
// for all windows in nativeMapping
|
// for all windows in nativeMapping
|
||||||
static void processAllCustomEvents () {
|
static void processAllCustomEvents () {
|
||||||
|
|
||||||
|
justCommunication.processCustomEvents();
|
||||||
|
|
||||||
foreach (SimpleWindow sw; SimpleWindow.nativeMapping.byValue) {
|
foreach (SimpleWindow sw; SimpleWindow.nativeMapping.byValue) {
|
||||||
if (sw is null || sw.closed) continue;
|
if (sw is null || sw.closed) continue;
|
||||||
sw.processCustomEvents();
|
sw.processCustomEvents();
|
||||||
|
@ -3056,6 +3082,15 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/++
|
||||||
|
Magic pseudo-window for just posting events to a global queue.
|
||||||
|
|
||||||
|
Not entirely supported, I might delete it at any time.
|
||||||
|
|
||||||
|
Added Nov 5, 2021.
|
||||||
|
+/
|
||||||
|
__gshared SimpleWindow justCommunication = new SimpleWindow(NativeWindowHandle.init);
|
||||||
|
|
||||||
/* Drag and drop support { */
|
/* Drag and drop support { */
|
||||||
version(X11) {
|
version(X11) {
|
||||||
|
|
||||||
|
@ -8989,6 +9024,36 @@ bool runInGuiThread(scope void delegate() dg) @trusted {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runInGuiThreadAsync(void delegate() dg, void delegate(Exception) nothrow handleError = null) nothrow {
|
||||||
|
claimGuiThread();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(thisIsGuiThread) {
|
||||||
|
dg();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(guiThreadTerminating)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RunQueueMember* rqm = new RunQueueMember;
|
||||||
|
rqm.dg = cast(typeof(rqm.dg)) dg;
|
||||||
|
rqm.signal = null;
|
||||||
|
rqm.thrown = null;
|
||||||
|
|
||||||
|
synchronized(runInGuiThreadLock) {
|
||||||
|
runInGuiThreadQueue ~= rqm;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!SimpleWindow.eventWakeUp())
|
||||||
|
throw new Error("runInGuiThread impossible; eventWakeUp failed");
|
||||||
|
} catch(Exception e) {
|
||||||
|
if(handleError)
|
||||||
|
handleError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void runPendingRunInGuiThreadDelegates() {
|
private void runPendingRunInGuiThreadDelegates() {
|
||||||
more:
|
more:
|
||||||
RunQueueMember* next;
|
RunQueueMember* next;
|
||||||
|
@ -9009,13 +9074,14 @@ private void runPendingRunInGuiThreadDelegates() {
|
||||||
next.thrown = t;
|
next.thrown = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
next.signal.notify();
|
if(next.signal)
|
||||||
|
next.signal.notify();
|
||||||
|
|
||||||
goto more;
|
goto more;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void claimGuiThread() {
|
private void claimGuiThread() nothrow {
|
||||||
import core.atomic;
|
import core.atomic;
|
||||||
if(cas(&guiThreadExists, false, true))
|
if(cas(&guiThreadExists, false, true))
|
||||||
thisIsGuiThread = true;
|
thisIsGuiThread = true;
|
||||||
|
@ -15067,7 +15133,15 @@ enum {
|
||||||
MWM_FUNC_MOVE = (1L << 2),
|
MWM_FUNC_MOVE = (1L << 2),
|
||||||
MWM_FUNC_MINIMIZE = (1L << 3),
|
MWM_FUNC_MINIMIZE = (1L << 3),
|
||||||
MWM_FUNC_MAXIMIZE = (1L << 4),
|
MWM_FUNC_MAXIMIZE = (1L << 4),
|
||||||
MWM_FUNC_CLOSE = (1L << 5)
|
MWM_FUNC_CLOSE = (1L << 5),
|
||||||
|
|
||||||
|
MWM_DECOR_ALL = (1L << 0),
|
||||||
|
MWM_DECOR_BORDER = (1L << 1),
|
||||||
|
MWM_DECOR_RESIZEH = (1L << 2),
|
||||||
|
MWM_DECOR_TITLE = (1L << 3),
|
||||||
|
MWM_DECOR_MENU = (1L << 4),
|
||||||
|
MWM_DECOR_MINIMIZE = (1L << 5),
|
||||||
|
MWM_DECOR_MAXIMIZE = (1L << 6),
|
||||||
}
|
}
|
||||||
|
|
||||||
import core.stdc.config : c_long, c_ulong;
|
import core.stdc.config : c_long, c_ulong;
|
||||||
|
|
Loading…
Reference in New Issue