From 14ee0e0b7e3181a8c7072f83dce723ce74164003 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Wed, 30 Oct 2024 19:05:52 -0400 Subject: [PATCH] try to tame more of cef badness --- libssh2.lib | Bin 22528 -> 0 bytes minigui.d | 7 +++++++ minigui_addons/webview.d | 43 ++++++++++++++++++++++++++++++++++++++- simpledisplay.d | 4 ++++ 4 files changed, 53 insertions(+), 1 deletion(-) delete mode 100644 libssh2.lib diff --git a/libssh2.lib b/libssh2.lib deleted file mode 100644 index 36af1d17b64bbb7354e69dcd0ed5205a3e88d2df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22528 zcmeHPe~jG6Re!rzDHSD-ld}`YPI8{umme-z^(8fiT9MljO42|>Qj#X1ZuWM+=UZ-X zceA@^JA|5}X`^j|lvK3TLEzG=NvhBm5Dkfd1}Y4skw9)y4M9m!lpv*)swt}IKbDR+ zGvAr_nIC(%NCk?-N+rkN&t$~O5Nds|l1R)fNGJYBZ z9KjOzc8u2qjmxlbbTLaHfs~FJeXAMi2MJz>Rh`Paq!2(vd z(S;%Y%An}iSB8r;I%I$^ih$iXB95CPfHD?>@|>@;rT1%tA|p>3LmV$p8Kw{e{b{~F zDE41lYZi@elT9%8r(hUSygvmL76|8WENTYYwMM%;$jl!MXXg(n%J~(|IDNR`W~Fp}QM5P4w{#QXms0}%E>h$8*CC|n7{T9eL~!|75qMHu#RL<}LfrmvA#F+4V|Ivx zW(ixqHm0E z2q(n1la>Nly@GbfOXV=tY!@s7)^@XK)|&NUokqWC*P`o%pf z1t)>M;k`yp$|-fsP|@ooRTnH+#d*r z5zY4p0tyR;{ghz1k>LmN8;BtM1SC0rAiop5#$wS}qEVdRMFfcG^Sg*9h79b(FV5g` zBAeJpM1hE69}!Uinb%iSm(An##lwh{(U+dUxN2Ts*7FaUNFx0&5ltKeGWyC!1NJZI z_sV=+Os>Zd4{yMao?sn*Y-AYEPaGpM{A8mA^8@`@;YV++3#~Rc#o~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2p-Y})&F)_iNf2G94 diff --git a/minigui.d b/minigui.d index c3e0750..2bd2618 100644 --- a/minigui.d +++ b/minigui.d @@ -8243,6 +8243,7 @@ class Window : Widget { }; win.onFocusChange = (bool getting) { + // sdpyPrintDebugString("onFocusChange ", getting, " ", this.toString); if(this.focusedWidget) { if(getting) { this.focusedWidget.emit!FocusEvent(); @@ -8463,6 +8464,12 @@ class Window : Widget { // writefln("input proxy: 0x%0x", inputProxy); this.inputProxy = new SimpleWindow(inputProxy); + /+ + this.inputProxy.onFocusChange = (bool getting) { + sdpyPrintDebugString("input proxy focus change ", getting); + }; + +/ + XEvent lastEvent; this.inputProxy.handleNativeEvent = (XEvent ev) { lastEvent = ev; diff --git a/minigui_addons/webview.d b/minigui_addons/webview.d index 7663dd6..7129c2d 100644 --- a/minigui_addons/webview.d +++ b/minigui_addons/webview.d @@ -543,6 +543,8 @@ class WebViewWidget_CEF : WebViewWidgetBase { ev.mode = NotifyModes.NotifyNormal; ev.detail = NotifyDetail.NotifyVirtual; + // sdpyPrintDebugString("Sending FocusIn"); + trapXErrors( { XSendEvent(XDisplayConnection.get, ozone, false, 0, cast(XEvent*) &ev); }); @@ -560,6 +562,8 @@ class WebViewWidget_CEF : WebViewWidgetBase { ev.mode = NotifyModes.NotifyNormal; ev.detail = NotifyDetail.NotifyNonlinearVirtual; + // sdpyPrintDebugString("Sending FocusOut"); + trapXErrors( { XSendEvent(XDisplayConnection.get, ozone, false, 0, cast(XEvent*) &ev); }); @@ -1284,6 +1288,7 @@ version(cef) { class MiniguiFocusHandler : CEF!cef_focus_handler_t { override void on_take_focus(RC!(cef_browser_t) browser, int next) nothrow { + // sdpyPrintDebugString("taking"); browser.runOnWebView(delegate(wv) { Widget f; if(next) { @@ -1305,7 +1310,40 @@ version(cef) { ev.focus(); // even this can steal focus from other parts of my application! }); +/ - //sdpyPrintDebugString("setting"); + // sdpyPrintDebugString("setting"); + + // if either the parent window or the ozone window has the focus, we + // can redirect it to the input focus. CEF calls this method sometimes + // before setting the focus (where return 1 can override) and sometimes + // after... which is totally inappropriate for it to do but it does anyway + // and we want to undo the damage of this. + browser.runOnWebView((ev) { + arsd.simpledisplay.Window focus_window; + int revert_to_return; + XGetInputFocus(XDisplayConnection.get, &focus_window, &revert_to_return); + if(focus_window is ev.parentWindow.win.impl.window || focus_window is ev.ozone) { + // refocus our correct input focus + ev.parentWindow.win.focus(); + XSync(XDisplayConnection.get, 0); + + // and then tell the chromium thing it still has it + // so it will think it got it, lost it, then got it again + // and hopefully not try to get it again + XFocusChangeEvent eve; + eve.type = arsd.simpledisplay.EventType.FocusIn; + eve.display = XDisplayConnection.get; + eve.window = ev.ozone; + eve.mode = NotifyModes.NotifyNormal; + eve.detail = NotifyDetail.NotifyVirtual; + + // sdpyPrintDebugString("Sending FocusIn hack here"); + + trapXErrors( { + XSendEvent(XDisplayConnection.get, ev.ozone, false, 0, cast(XEvent*) &eve); + }); + + } + }); return 1; // otherwise, cancel because this bullshit tends to steal focus from other applications and i never, ever, ever want that to happen. // seems to happen because of race condition in it getting a focus event and then stealing the focus from the parent @@ -1314,10 +1352,13 @@ version(cef) { // it also breaks its own pop up menus and drop down boxes to allow this! wtf } override void on_got_focus(RC!(cef_browser_t) browser) nothrow { + // sdpyPrintDebugString("got"); browser.runOnWebView((ev) { // this sometimes steals from the app too but it is relatively acceptable // steals when i mouse in from the side of the window quickly, but still // i want the minigui state to match so i'll allow it + + //if(ev.parentWindow) ev.parentWindow.focus(); ev.focus(); }); } diff --git a/simpledisplay.d b/simpledisplay.d index 1404be3..5e83d97 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -2406,6 +2406,8 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon { setTo = setRequestedInputFocus(); if(setTo is null) setTo = this; + + // sdpyPrintDebugString("grabInput() ", setTo.impl.window; XSetInputFocus(XDisplayConnection.get, setTo.impl.window, RevertToParent, CurrentTime); } } @@ -2575,6 +2577,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon { setTo = setRequestedInputFocus(); if(setTo is null) setTo = this; + // sdpyPrintDebugString("sdpy.focus() ", setTo.impl.window); XSetInputFocus(XDisplayConnection.get, setTo.impl.window, RevertToParent, CurrentTime); } else version(Windows) { SetFocus(this.impl.hwnd); @@ -16400,6 +16403,7 @@ version(X11) { // FIXME: so this is actually supposed to focus to a relevant child window if appropriate + // sdpyPrintDebugString("WM_TAKE_FOCUS ", setTo.impl.window); XSetInputFocus(display, setTo.impl.window, RevertToParent, e.xclient.data.l[1]); } } else if(e.xclient.message_type == GetAtom!"MANAGER"(e.xany.display)) {