mirror of https://github.com/adamdruppe/arsd.git
experimenting with input proxy
This commit is contained in:
parent
158ce8e21d
commit
f44c993695
52
minigui.d
52
minigui.d
|
@ -8082,12 +8082,59 @@ class Window : Widget {
|
||||||
}
|
}
|
||||||
win = new SimpleWindow(width, height, title, OpenGlOptions.no, Resizability.allowResizing, WindowTypes.normal, WindowFlags.dontAutoShow | WindowFlags.managesChildWindowFocus);
|
win = new SimpleWindow(width, height, title, OpenGlOptions.no, Resizability.allowResizing, WindowTypes.normal, WindowFlags.dontAutoShow | WindowFlags.managesChildWindowFocus);
|
||||||
|
|
||||||
|
/+
|
||||||
|
// for input proxy
|
||||||
|
auto display = XDisplayConnection.get;
|
||||||
|
auto inputProxy = XCreateSimpleWindow(display, win.window, -1, -1, 1, 1, 0, 0, 0);
|
||||||
|
XSelectInput(display, inputProxy, EventMask.KeyPressMask | EventMask.KeyReleaseMask);
|
||||||
|
XMapWindow(display, inputProxy);
|
||||||
|
import std.stdio; writefln("input proxy: 0x%0x", inputProxy);
|
||||||
|
this.inputProxy = new SimpleWindow(inputProxy);
|
||||||
|
|
||||||
|
XEvent lastEvent;
|
||||||
|
this.inputProxy.handleNativeEvent = (XEvent ev) {
|
||||||
|
lastEvent = ev;
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
this.inputProxy.setEventHandlers(
|
||||||
|
(MouseEvent e) {
|
||||||
|
dispatchMouseEvent(e);
|
||||||
|
},
|
||||||
|
(KeyEvent e) {
|
||||||
|
//import std.stdio;
|
||||||
|
//writefln("%x %s", cast(uint) e.key, e.key);
|
||||||
|
if(dispatchKeyEvent(e)) {
|
||||||
|
// FIXME: i should trap error
|
||||||
|
if(auto nw = cast(NestedChildWindowWidget) focusedWidget) {
|
||||||
|
auto thing = nw.focusableWindow();
|
||||||
|
if(thing && thing.window) {
|
||||||
|
import std.stdio; writeln("sending event ", lastEvent.xkey);
|
||||||
|
XSendEvent(XDisplayConnection.get, thing.window, false, 0, &lastEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(dchar e) {
|
||||||
|
if(e == 13) e = 10; // hack?
|
||||||
|
if(e == 127) return; // linux sends this, windows doesn't. we don't want it.
|
||||||
|
dispatchCharEvent(e);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
// done
|
||||||
|
+/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
win.setRequestedInputFocus = &this.setRequestedInputFocus;
|
win.setRequestedInputFocus = &this.setRequestedInputFocus;
|
||||||
|
|
||||||
this(win);
|
this(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SimpleWindow inputProxy;
|
||||||
|
|
||||||
private SimpleWindow setRequestedInputFocus() {
|
private SimpleWindow setRequestedInputFocus() {
|
||||||
|
// return inputProxy;
|
||||||
|
|
||||||
if(auto fw = cast(NestedChildWindowWidget) focusedWidget) {
|
if(auto fw = cast(NestedChildWindowWidget) focusedWidget) {
|
||||||
// sdpyPrintDebugString("heaven");
|
// sdpyPrintDebugString("heaven");
|
||||||
return fw.focusableWindow;
|
return fw.focusableWindow;
|
||||||
|
@ -8126,13 +8173,14 @@ class Window : Widget {
|
||||||
event.ctrlKey = (ev.modifierState & ModifierState.ctrl) ? true : false;
|
event.ctrlKey = (ev.modifierState & ModifierState.ctrl) ? true : false;
|
||||||
event.dispatch();
|
event.dispatch();
|
||||||
|
|
||||||
return true;
|
return !event.defaultPrevented;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dispatchCharEvent(dchar ch) {
|
bool dispatchCharEvent(dchar ch) {
|
||||||
if(focusedWidget) {
|
if(focusedWidget) {
|
||||||
auto event = new CharEvent(focusedWidget, ch);
|
auto event = new CharEvent(focusedWidget, ch);
|
||||||
event.dispatch();
|
event.dispatch();
|
||||||
|
return !event.defaultPrevented;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8249,7 +8297,7 @@ class Window : Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true; // FIXME: the event default prevented?
|
||||||
}
|
}
|
||||||
|
|
||||||
/++
|
/++
|
||||||
|
|
|
@ -548,7 +548,7 @@ version(cef) {
|
||||||
|
|
||||||
runInGuiThread({
|
runInGuiThread({
|
||||||
ret = 1;
|
ret = 1;
|
||||||
scope WebViewWidget delegate(Widget, BrowserSettings) o = (parent, passed_settings) {
|
scope WebViewWidget delegate(Widget, BrowserSettings) accept = (parent, passed_settings) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if(parent !is null) {
|
if(parent !is null) {
|
||||||
auto widget = new WebViewWidget_CEF(this.client, parent);
|
auto widget = new WebViewWidget_CEF(this.client, parent);
|
||||||
|
@ -560,7 +560,7 @@ version(cef) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
this.client.openNewWindow(OpenNewWindowParams(target_url.toGC, o));
|
this.client.openNewWindow(OpenNewWindowParams(target_url.toGC, accept));
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -836,10 +836,12 @@ version(cef) {
|
||||||
// sdpyPrintDebugString("take");
|
// sdpyPrintDebugString("take");
|
||||||
}
|
}
|
||||||
override int on_set_focus(RC!(cef_browser_t) browser, cef_focus_source_t source) nothrow {
|
override int on_set_focus(RC!(cef_browser_t) browser, cef_focus_source_t source) nothrow {
|
||||||
//browser.runOnWebView((ev) {
|
/+
|
||||||
//sdpyPrintDebugString("setting");
|
browser.runOnWebView((ev) {
|
||||||
//ev.parentWindow.focusedWidget = ev;
|
sdpyPrintDebugString("setting");
|
||||||
//});
|
ev.parentWindow.focusedWidget = ev;
|
||||||
|
});
|
||||||
|
+/
|
||||||
|
|
||||||
return 1; // otherwise, cancel because this bullshit tends to steal focus from other applications and i never, ever, ever want that to happen.
|
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
|
// seems to happen because of race condition in it getting a focus event and then stealing the focus from the parent
|
||||||
|
|
Loading…
Reference in New Issue