mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add OnWindowConfigured.
This commit is contained in:
parent
bd062d3949
commit
54760551f7
@ -16,6 +16,10 @@ func (manager *DesktopManagerCtx) OnWindowCreated(listener func(window uint32, n
|
||||
xevent.OnWindowCreated(listener)
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) OnWindowConfigured(listener func(window uint32, name string, role string)) {
|
||||
xevent.OnWindowConfigured(listener)
|
||||
}
|
||||
|
||||
func (manager *DesktopManagerCtx) OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8)) {
|
||||
xevent.OnEventError(listener)
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ void XEventLoop(char *name) {
|
||||
return;
|
||||
}
|
||||
|
||||
Atom XA_CLIPBOARD;
|
||||
XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
|
||||
Atom WM_WINDOW_ROLE = XInternAtom(display, "WM_WINDOW_ROLE", 1);
|
||||
Atom XA_CLIPBOARD = XInternAtom(display, "CLIPBOARD", 0);
|
||||
XFixesSelectSelectionInput(display, root, XA_CLIPBOARD, XFixesSetSelectionOwnerNotifyMask);
|
||||
XFixesSelectCursorInput(display, root, XFixesDisplayCursorNotifyMask);
|
||||
XSelectInput(display, root, SubstructureNotifyMask);
|
||||
@ -54,18 +54,32 @@ void XEventLoop(char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
// XFixesSelectionNotifyEvent
|
||||
// CreateNotify
|
||||
if (event.type == CreateNotify) {
|
||||
Window window = event.xcreatewindow.window;
|
||||
|
||||
char *name;
|
||||
XFetchName(display, event.xcreatewindow.window, &name);
|
||||
XFetchName(display, window, &name);
|
||||
|
||||
char *role;
|
||||
XTextProperty text_data;
|
||||
Atom atom = XInternAtom(display, "WM_WINDOW_ROLE", True);
|
||||
int status = XGetTextProperty(display, event.xcreatewindow.window, &text_data, atom);
|
||||
role = (char *)text_data.value;
|
||||
XTextProperty role;
|
||||
XGetTextProperty(display, window, &role, WM_WINDOW_ROLE);
|
||||
|
||||
goXEventWindowCreated(event.xcreatewindow, name, role);
|
||||
goXEventWindowCreated(window, name, role.value);
|
||||
XFree(name);
|
||||
continue;
|
||||
}
|
||||
|
||||
// ConfigureNotify
|
||||
if (event.type == ConfigureNotify) {
|
||||
Window window = event.xconfigure.window;
|
||||
|
||||
char *name;
|
||||
XFetchName(display, window, &name);
|
||||
|
||||
XTextProperty role;
|
||||
XGetTextProperty(display, window, &role, WM_WINDOW_ROLE);
|
||||
|
||||
goXEventWindowConfigured(window, name, role.value);
|
||||
XFree(name);
|
||||
continue;
|
||||
}
|
||||
|
@ -44,6 +44,12 @@ func OnWindowCreated(listener func(window uint32, name string, role string)) {
|
||||
})
|
||||
}
|
||||
|
||||
func OnWindowConfigured(listener func(window uint32, name string, role string)) {
|
||||
emmiter.On("window-configured", func(payload ...interface{}) {
|
||||
listener(payload[0].(uint32), payload[1].(string), payload[2].(string))
|
||||
})
|
||||
}
|
||||
|
||||
func OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8)) {
|
||||
emmiter.On("event-error", func(payload ...interface{}) {
|
||||
listener(payload[0].(uint8), payload[1].(string), payload[2].(uint8), payload[3].(uint8))
|
||||
@ -61,8 +67,13 @@ func goXEventClipboardUpdated() {
|
||||
}
|
||||
|
||||
//export goXEventWindowCreated
|
||||
func goXEventWindowCreated(event C.XCreateWindowEvent, name *C.char, role *C.char) {
|
||||
emmiter.Emit("window-created", uint32(event.window), C.GoString(name), C.GoString(role))
|
||||
func goXEventWindowCreated(window C.Window, name *C.char, role *C.char) {
|
||||
emmiter.Emit("window-created", uint32(window), C.GoString(name), C.GoString(role))
|
||||
}
|
||||
|
||||
//export goXEventWindowConfigured
|
||||
func goXEventWindowConfigured(window C.Window, name *C.char, role *C.char) {
|
||||
emmiter.Emit("window-configured", uint32(window), C.GoString(name), C.GoString(role))
|
||||
}
|
||||
|
||||
//export goXEventError
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
extern void goXEventCursorChanged(XFixesCursorNotifyEvent event);
|
||||
extern void goXEventClipboardUpdated();
|
||||
extern void goXEventWindowCreated(XCreateWindowEvent event, char *name, char *role);
|
||||
extern void goXEventWindowCreated(Window window, char *name, char *role);
|
||||
extern void goXEventWindowConfigured(Window window, char *name, char *role);
|
||||
extern void goXEventError(XErrorEvent *event, char *message);
|
||||
extern int goXEventActive();
|
||||
|
||||
static int XEventError(Display *display, XErrorEvent *event);
|
||||
void XEventLoop(char *display);
|
||||
|
||||
|
@ -58,6 +58,7 @@ type DesktopManager interface {
|
||||
OnCursorChanged(listener func(serial uint64))
|
||||
OnClipboardUpdated(listener func())
|
||||
OnWindowCreated(listener func(window uint32, name string, role string))
|
||||
OnWindowConfigured(listener func(window uint32, name string, role string))
|
||||
OnEventError(listener func(error_code uint8, message string, request_code uint8, minor_code uint8))
|
||||
|
||||
// clipboard
|
||||
|
Loading…
Reference in New Issue
Block a user