diff --git a/internal/desktop/xevent/xevent.c b/internal/desktop/xevent/xevent.c index 238d7756..3791375c 100644 --- a/internal/desktop/xevent/xevent.c +++ b/internal/desktop/xevent/xevent.c @@ -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; diff --git a/internal/desktop/xevent/xevent.go b/internal/desktop/xevent/xevent.go index ba40d19f..6f1d53f5 100644 --- a/internal/desktop/xevent/xevent.go +++ b/internal/desktop/xevent/xevent.go @@ -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") } diff --git a/internal/desktop/xevent/xevent.h b/internal/desktop/xevent/xevent.h index bf744e63..3dfdfc0b 100644 --- a/internal/desktop/xevent/xevent.h +++ b/internal/desktop/xevent/xevent.h @@ -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);