xevent file-chooser-dialog-opened onConfigure.

This commit is contained in:
Miroslav Šedivý 2021-01-20 23:47:49 +01:00
parent 1559c6c3bd
commit dbbbc85c18
3 changed files with 6 additions and 27 deletions

View File

@ -54,21 +54,6 @@ void XEventLoop(char *name) {
}
}
// CreateNotify
if (event.type == CreateNotify) {
Window window = event.xcreatewindow.window;
char *name;
XFetchName(display, window, &name);
XTextProperty role;
XGetTextProperty(display, window, &role, WM_WINDOW_ROLE);
goXEventCreateNotify(window, name, role.value);
XFree(name);
continue;
}
// ConfigureNotify
if (event.type == ConfigureNotify) {
Window window = event.xconfigure.window;

View File

@ -68,17 +68,6 @@ func goXEventClipboardUpdated() {
emmiter.Emit("clipboard-updated")
}
//export goXEventCreateNotify
func goXEventCreateNotify(window C.Window, nameUnsafe *C.char, roleUnsafe *C.char) {
role := C.GoString(roleUnsafe)
if role != "GtkFileChooserDialog" {
return
}
file_chooser_dialog_window = uint32(window)
emmiter.Emit("file-chooser-dialog-opened")
}
//export goXEventConfigureNotify
func goXEventConfigureNotify(display *C.Display, window C.Window, nameUnsafe *C.char, roleUnsafe *C.char) {
role := C.GoString(roleUnsafe)
@ -91,6 +80,11 @@ func goXEventConfigureNotify(display *C.Display, window C.Window, nameUnsafe *C.
// Because first dialog is not put properly to background
time.Sleep(10 * time.Millisecond)
C.XFileChooserHide(display, window)
if file_chooser_dialog_window == 0 {
file_chooser_dialog_window = uint32(window)
emmiter.Emit("file-chooser-dialog-opened")
}
}
//export goXEventUnmapNotify
@ -99,6 +93,7 @@ func goXEventUnmapNotify(window C.Window) {
return
}
file_chooser_dialog_window = 0
emmiter.Emit("file-chooser-dialog-closed")
}

View File

@ -9,7 +9,6 @@
extern void goXEventCursorChanged(XFixesCursorNotifyEvent event);
extern void goXEventClipboardUpdated();
extern void goXEventCreateNotify(Window window, char *name, char *role);
extern void goXEventConfigureNotify(Display *display, Window window, char *name, char *role);
extern void goXEventUnmapNotify(Window window);
extern void goXEventError(XErrorEvent *event, char *message);