diff --git a/legacy/ecore/src/Ecore.h b/legacy/ecore/src/Ecore.h index 2120553778..409b81b019 100644 --- a/legacy/ecore/src/Ecore.h +++ b/legacy/ecore/src/Ecore.h @@ -79,11 +79,10 @@ void e_sync(void); void e_flush(void); Window e_window_new(Window parent, int x, int y, int w, int h); Window e_window_override_new(Window parent, int x, int y, int w, - int h); Window e_window_input_new(Window parent, int x, int y, int w, - int h); +void e_window_set_events_propagate(Window win, int propagate); void e_window_show(Window win); void e_window_hide(Window win); Pixmap e_pixmap_new(Window win, int w, int h, int dep); @@ -268,7 +267,10 @@ int e_window_is_manageable(Window win); void e_windows_restack(Window *wins, int num); void e_window_stack_above(Window win, Window above); void e_window_stack_below(Window win, Window below); - +char *e_window_get_title(Window win); +void e_keyboard_grab(Window win); +void e_keyboard_ungrab(void); + typedef struct _eev Eevent; typedef struct _ev_fd_handler Ev_Fd_Handler; typedef struct _ev_pid_handler Ev_Pid_Handler; diff --git a/legacy/ecore/src/e_ev_x.c b/legacy/ecore/src/e_ev_x.c index ebbf99ec8c..6d76d73373 100644 --- a/legacy/ecore/src/e_ev_x.c +++ b/legacy/ecore/src/e_ev_x.c @@ -443,7 +443,7 @@ e_ev_x_handle_enter_notify(XEvent * xevent) { Ev_Window_Enter *e; - if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return; +/* if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;*/ e_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root); e = NEW(Ev_Window_Enter, 1); e->win = xevent->xcrossing.window; @@ -477,7 +477,7 @@ e_ev_x_handle_leave_notify(XEvent * xevent) { Ev_Window_Leave *e; - if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return; +/* if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;*/ e_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root); { Ev_Mouse_Move *e; diff --git a/legacy/ecore/src/e_x.c b/legacy/ecore/src/e_x.c index 4765586d9f..00be63031d 100644 --- a/legacy/ecore/src/e_x.c +++ b/legacy/ecore/src/e_x.c @@ -354,6 +354,20 @@ e_window_input_new(Window parent, int x, int y, int w, int h) return win; } +void +e_window_set_events_propagate(Window win, int propagate) +{ + XSetWindowAttributes attr; + + if (!win) + win = default_root; + if (!propagate) + attr.do_not_propagate_mask = True; + else + attr.do_not_propagate_mask = False; + XChangeWindowAttributes(disp, win, CWDontPropagate, &attr); +} + void e_window_show(Window win) { @@ -782,7 +796,11 @@ e_key_get_keysym_from_keycode(KeyCode keycode) char * e_key_get_string_from_keycode(KeyCode keycode) { - return strdup(XKeysymToString(e_key_get_keysym_from_keycode(keycode))); + char *str; + + str = XKeysymToString(e_key_get_keysym_from_keycode(keycode)); + if (!str) return strdup(""); + return strdup(str); } void @@ -2798,6 +2816,8 @@ e_window_stack_above(Window win, Window above) { XWindowChanges xwc; + if (win == 0) + win = default_root; xwc.sibling = above; xwc.stack_mode = Above; XConfigureWindow(disp, win, CWSibling | CWStackMode, &xwc); @@ -2808,7 +2828,65 @@ e_window_stack_below(Window win, Window below) { XWindowChanges xwc; + if (win == 0) + win = default_root; xwc.sibling = below; xwc.stack_mode = Below; XConfigureWindow(disp, win, CWSibling | CWStackMode, &xwc); } + +char * +e_window_get_title(Window win) +{ + XTextProperty xtp; + + if (win == 0) + win = default_root; + if (XGetWMName(disp, win, &xtp)) + { + int items; + char **list; + Status s; + char *title = NULL; + + if (xtp.format == 8) + { + s = XmbTextPropertyToTextList(disp, &xtp, &list, &items); + if ((s == Success) && (items > 0)) + { + title = strdup(*list); + XFreeStringList(list); + } + else title = strdup((char *)xtp.value); + } + else title = strdup((char *)xtp.value); + XFree(xtp.value); + return title; + } + return NULL; +} + +static Window keyboard_grab_win = 0; + +void +e_keyboard_grab(Window win) +{ + int status; + + if (keyboard_grab_win) return; + if (win == 0) + win = default_root; + keyboard_grab_win = win; + status = XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime); + if ((status == AlreadyGrabbed) || (status == GrabNotViewable) || + (status == GrabFrozen) || (status == GrabInvalidTime)) + keyboard_grab_win = 0; +} + +void +e_keyboard_ungrab(void) +{ + if (!keyboard_grab_win) return; + keyboard_grab_win = 0; + XUngrabKeyboard(disp, CurrentTime); +}