EAPI Ecore_X_Rectangle * ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret) { Ecore_X_Rectangle *rects = NULL; #ifdef ShapeInput XRectangle *rect; int i, num = 0, ord; LOGFN(__FILE__, __LINE__, __FUNCTION__); rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeInput, &num, &ord); if (_ecore_xlib_sync) ecore_x_sync(); if (rect) { if (num < 1) { XFree(rect); if (num_ret) *num_ret = 0; return NULL; } rects = malloc(sizeof(Ecore_X_Rectangle) * num); if (!rects) { XFree(rect); if (num_ret) *num_ret = 0; return NULL; } for (i = 0; i < num; i++) { rects[i].x = rect[i].x; rects[i].y = rect[i].y; rects[i].width = rect[i].width; rects[i].height = rect[i].height; } XFree(rect); } if (num_ret) *num_ret = num; return rects; #else // have to return fake shape input rect of size of window Window dw; unsigned int di; if (num_ret) *num_ret = 0; rects = malloc(sizeof(Ecore_X_Rectangle)); if (!rects) return NULL; if (!XGetGeometry(_ecore_x_disp, win, &dw, &(rects[0].x), &(rects[0].y), &(rects[0].width), &(rects[0].height), &di, &di)) { if (_ecore_xlib_sync) ecore_x_sync(); free(rects); return NULL; } if (_ecore_xlib_sync) ecore_x_sync(); if (num_ret) *num_ret = 1; return rects; #endif }
/** * Get a window icon name. * @param win The window * @return The windows icon name string * * Return the icon name of a window. String must be free'd when done with. */ EAPI char * ecore_x_icccm_icon_name_get(Ecore_X_Window win) { XTextProperty xprop; LOGFN(__FILE__, __LINE__, __FUNCTION__); xprop.value = NULL; if (XGetWMIconName(_ecore_x_disp, win, &xprop) >= Success) { if (_ecore_xlib_sync) ecore_x_sync(); if (xprop.value) { char **list = NULL; char *t = NULL; int num = 0; int ret; if (xprop.encoding == ECORE_X_ATOM_UTF8_STRING) t = strdup((char *)xprop.value); else { /* convert to utf8 */ #ifdef X_HAVE_UTF8_STRING ret = Xutf8TextPropertyToTextList(_ecore_x_disp, &xprop, &list, &num); #else /* ifdef X_HAVE_UTF8_STRING */ ret = XmbTextPropertyToTextList(_ecore_x_disp, &xprop, &list, &num); #endif /* ifdef X_HAVE_UTF8_STRING */ if (_ecore_xlib_sync) ecore_x_sync(); if ((ret == XLocaleNotSupported) || (ret == XNoMemory) || (ret == XConverterNotFound)) t = strdup((char *)xprop.value); else if (ret >= Success) { if ((num >= 1) && (list)) t = strdup(list[0]); if (list) XFreeStringList(list); } } if (xprop.value) XFree(xprop.value); return t; } } else { if (_ecore_xlib_sync) ecore_x_sync(); } return NULL; }
EAPI void ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win, int x, int y, int w, int h) { #ifdef ShapeInput XRectangle rect; LOGFN(__FILE__, __LINE__, __FUNCTION__); rect.x = x; rect.y = y; rect.width = w; rect.height = h; XShapeCombineRectangles(_ecore_x_disp, win, ShapeInput, 0, 0, &rect, 1, ShapeIntersect, Unsorted); if (_ecore_xlib_sync) ecore_x_sync(); #else return; win = x = y = w = h = 0; #endif }
EAPI Eina_Bool ecore_x_input_raw_select(Ecore_X_Window win) { #ifdef ECORE_XI2 XIEventMask emask; unsigned char mask[4] = { 0 }; if (!_ecore_x_xi2_devs) return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); emask.deviceid = XIAllMasterDevices; emask.mask_len = sizeof(mask); emask.mask = mask; #ifdef XI_RawButtonPress XISetMask(emask.mask, XI_RawButtonPress); #endif #ifdef XI_RawButtonRelease XISetMask(emask.mask, XI_RawButtonRelease); #endif #ifdef XI_RawMotion XISetMask(emask.mask, XI_RawMotion); #endif XISelectEvents(_ecore_x_disp, win, &emask, 1); if (_ecore_xlib_sync) ecore_x_sync(); return EINA_TRUE; #else return EINA_FALSE; #endif }
EAPI Ecore_X_Sync_Alarm ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter) { Ecore_X_Sync_Alarm alarm; XSyncAlarmAttributes values; XSyncValue init; LOGFN(__FILE__, __LINE__, __FUNCTION__); XSyncIntToValue(&init, 0); XSyncSetCounter(_ecore_x_disp, counter, init); values.trigger.counter = counter; values.trigger.value_type = XSyncAbsolute; XSyncIntToValue(&values.trigger.wait_value, 1); values.trigger.test_type = XSyncPositiveComparison; XSyncIntToValue(&values.delta, 1); values.events = True; alarm = XSyncCreateAlarm(_ecore_x_disp, XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType | XSyncCADelta | XSyncCAEvents, &values); ecore_x_sync(); return alarm; } /* ecore_x_sync_alarm_new */
EAPI void ecore_x_window_shape_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) { XRectangle *rect = NULL; int i; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (num > 0) { rect = malloc(sizeof(XRectangle) * num); if (!rect) return; for (i = 0; i < num; i++) { rect[i].x = rects[i].x; rect[i].y = rects[i].y; rect[i].width = rects[i].width; rect[i].height = rects[i].height; } } XShapeCombineRectangles(_ecore_x_disp, win, ShapeBounding, 0, 0, rect, num, ShapeUnion, Unsorted); if (_ecore_xlib_sync) ecore_x_sync(); if (rect) free(rect); }
/* * Set X ID (array) property */ EAPI void ecore_x_window_prop_xid_set(Ecore_X_Window win, Ecore_X_Atom atom, Ecore_X_Atom type, Ecore_X_ID *lst, unsigned int num) { #if SIZEOF_INT == SIZEOF_LONG XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace, (unsigned char *)lst, num); #else /* if SIZEOF_INT == SIZEOF_LONG */ unsigned long *pl; unsigned int i; LOGFN(__FILE__, __LINE__, __FUNCTION__); pl = malloc(num * sizeof(unsigned long)); if (!pl) return; for (i = 0; i < num; i++) pl[i] = lst[i]; XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace, (unsigned char *)pl, num); free(pl); #endif /* if SIZEOF_INT == SIZEOF_LONG */ if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Get a window name & class. * @param win The window * @param n The name string * @param c The class string * * Get a window name * class */ EAPI void ecore_x_icccm_name_class_get(Ecore_X_Window win, char **n, char **c) { XClassHint xch; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (n) *n = NULL; if (c) *c = NULL; xch.res_name = NULL; xch.res_class = NULL; if (XGetClassHint(_ecore_x_disp, win, &xch)) { if (n) if (xch.res_name) *n = strdup(xch.res_name); if (c) if (xch.res_class) *c = strdup(xch.res_class); XFree(xch.res_name); XFree(xch.res_class); } if (_ecore_xlib_sync) ecore_x_sync(); }
EAPI Ecore_X_Window_State_Hint ecore_x_icccm_state_get(Ecore_X_Window win) { unsigned char *prop_ret = NULL; Atom type_ret; unsigned long bytes_after, num_ret; int format_ret; Ecore_X_Window_State_Hint hint; LOGFN(__FILE__, __LINE__, __FUNCTION__); hint = ECORE_X_WINDOW_STATE_HINT_NONE; XGetWindowProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_STATE, 0, 0x7fffffff, False, ECORE_X_ATOM_WM_STATE, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret); if (_ecore_xlib_sync) ecore_x_sync(); if ((prop_ret) && (num_ret == 2)) { if (prop_ret[0] == WithdrawnState) hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; else if (prop_ret[0] == NormalState) hint = ECORE_X_WINDOW_STATE_HINT_NORMAL; else if (prop_ret[0] == IconicState) hint = ECORE_X_WINDOW_STATE_HINT_ICONIC; } if (prop_ret) XFree(prop_ret); return hint; }
EAPI Ecore_X_Atom * ecore_x_window_prop_list(Ecore_X_Window win, int *num_ret) { Ecore_X_Atom *atoms; Atom *atom_ret; int num = 0, i; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (num_ret) *num_ret = 0; atom_ret = XListProperties(_ecore_x_disp, win, &num); if (_ecore_xlib_sync) ecore_x_sync(); if (!atom_ret) return NULL; atoms = malloc(num * sizeof(Ecore_X_Atom)); if (atoms) { for (i = 0; i < num; i++) atoms[i] = atom_ret[i]; if (num_ret) *num_ret = num; } XFree(atom_ret); return atoms; }
EAPI Eina_Bool ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) { Atom proto, *protos = NULL; int i, protos_count = 0; Eina_Bool ret = EINA_FALSE; /* check for invalid values */ if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); proto = _ecore_x_atoms_wm_protocols[protocol]; ret = XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count); if (_ecore_xlib_sync) ecore_x_sync(); if (!ret) return ret; for (i = 0; i < protos_count; i++) if (protos[i] == proto) { ret = EINA_TRUE; break; } XFree(protos); return ret; }
EAPI void ecore_x_icccm_iconic_request_send(Ecore_X_Window win, Ecore_X_Window root) { XEvent xev; if (!win) return; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!root) root = DefaultRootWindow(_ecore_x_disp); xev.xclient.type = ClientMessage; xev.xclient.serial = 0; xev.xclient.send_event = True; xev.xclient.display = _ecore_x_disp; xev.xclient.window = win; xev.xclient.format = 32; xev.xclient.message_type = ECORE_X_ATOM_WM_CHANGE_STATE; xev.xclient.data.l[0] = IconicState; XSendEvent(_ecore_x_disp, root, False, SubstructureNotifyMask | SubstructureRedirectMask, &xev); if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Remove the transient_for setting from a window. * @param win The window */ EAPI void ecore_x_icccm_transient_for_unset(Ecore_X_Window win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_TRANSIENT_FOR); if (_ecore_xlib_sync) ecore_x_sync(); }
EAPI void ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, int x, int y, int w, int h) { XRectangle rect; LOGFN(__FILE__, __LINE__, __FUNCTION__); rect.x = x; rect.y = y; rect.width = w; rect.height = h; XShapeCombineRectangles(_ecore_x_disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeIntersect, Unsorted); if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Specify that a window is transient for another top-level window and should be handled accordingly. * @param win the transient window * @param forwin the toplevel window */ EAPI void ecore_x_icccm_transient_for_set(Ecore_X_Window win, Ecore_X_Window forwin) { LOGFN(__FILE__, __LINE__, __FUNCTION__); XSetTransientForHint(_ecore_x_disp, win, forwin); if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Sets the shape of the given window to that given by the pixmap @p mask. * @param win The given window. * @param mask A 2-bit depth pixmap that provides the new shape of the * window. * @ingroup Ecore_X_Window_Shape */ EAPI void ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) { LOGFN(__FILE__, __LINE__, __FUNCTION__); XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet); if (_ecore_xlib_sync) ecore_x_sync(); }
EAPI void ecore_x_window_prop_property_del(Ecore_X_Window win, Ecore_X_Atom property) { LOGFN(__FILE__, __LINE__, __FUNCTION__); XDeleteProperty(_ecore_x_disp, win, property); if (_ecore_xlib_sync) ecore_x_sync(); }
EAPI void ecore_x_icccm_hints_set(Ecore_X_Window win, Eina_Bool accepts_focus, Ecore_X_Window_State_Hint initial_state, Ecore_X_Pixmap icon_pixmap, Ecore_X_Pixmap icon_mask, Ecore_X_Window icon_window, Ecore_X_Window window_group, Eina_Bool is_urgent) { XWMHints *hints; hints = XAllocWMHints(); if (!hints) return; LOGFN(__FILE__, __LINE__, __FUNCTION__); hints->flags = InputHint | StateHint; hints->input = accepts_focus; if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) hints->initial_state = WithdrawnState; else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL) hints->initial_state = NormalState; else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC) hints->initial_state = IconicState; if (icon_pixmap != 0) { hints->icon_pixmap = icon_pixmap; hints->flags |= IconPixmapHint; } if (icon_mask != 0) { hints->icon_mask = icon_mask; hints->flags |= IconMaskHint; } if (icon_window != 0) { hints->icon_window = icon_window; hints->flags |= IconWindowHint; } if (window_group != 0) { hints->window_group = window_group; hints->flags |= WindowGroupHint; } if (is_urgent) hints->flags |= XUrgencyHint; XSetWMHints(_ecore_x_disp, win, hints); if (_ecore_xlib_sync) ecore_x_sync(); XFree(hints); }
/** * Sets the WM_COMMAND property for @a win. * * @param win The window. * @param argc Number of arguments. * @param argv Arguments. */ EAPI void ecore_x_icccm_command_set(Ecore_X_Window win, int argc, char **argv) { LOGFN(__FILE__, __LINE__, __FUNCTION__); XSetCommand(_ecore_x_disp, win, argv, argc); if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Get a window string property. * @param win The window * @param type The property * @return Window string property of a window. String must be free'd when done. */ EAPI char * ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type) { XTextProperty xtp; char *str = NULL; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (win == 0) win = DefaultRootWindow(_ecore_x_disp); if (XGetTextProperty(_ecore_x_disp, win, &xtp, type)) { int items; char **list = NULL; Status s; if (_ecore_xlib_sync) ecore_x_sync(); if (xtp.encoding == ECORE_X_ATOM_UTF8_STRING) str = strdup((char *)xtp.value); else { #ifdef X_HAVE_UTF8_STRING s = Xutf8TextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items); #else /* ifdef X_HAVE_UTF8_STRING */ s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp, &list, &items); #endif /* ifdef X_HAVE_UTF8_STRING */ if (_ecore_xlib_sync) ecore_x_sync(); if ((s == XLocaleNotSupported) || (s == XNoMemory) || (s == XConverterNotFound)) str = strdup((char *)xtp.value); else if ((s >= Success) && (items > 0)) str = strdup(list[0]); if (list) XFreeStringList(list); } XFree(xtp.value); } return str; }
EAPI void ecore_x_region_extents(Ecore_X_Region dest, Ecore_X_Region source) { #ifdef ECORE_XFIXES LOGFN(__FILE__, __LINE__, __FUNCTION__); XFixesRegionExtents(_ecore_x_disp, dest, source); if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ }
EAPI void ecore_x_icccm_title_set(Ecore_X_Window win, const char *t) { char *list[1]; XTextProperty xprop; int ret; if (!t) return; LOGFN(__FILE__, __LINE__, __FUNCTION__); xprop.value = NULL; #ifdef X_HAVE_UTF8_STRING list[0] = strdup(t); ret = Xutf8TextListToTextProperty(_ecore_x_disp, list, 1, XUTF8StringStyle, &xprop); #else /* ifdef X_HAVE_UTF8_STRING */ list[0] = strdup(t); ret = XmbTextListToTextProperty(_ecore_x_disp, list, 1, XStdICCTextStyle, &xprop); #endif /* ifdef X_HAVE_UTF8_STRING */ if (_ecore_xlib_sync) ecore_x_sync(); if (ret >= Success) { XSetWMName(_ecore_x_disp, win, &xprop); if (_ecore_xlib_sync) ecore_x_sync(); if (xprop.value) XFree(xprop.value); } else if (XStringListToTextProperty(list, 1, &xprop) >= Success) { XSetWMName(_ecore_x_disp, win, &xprop); if (_ecore_xlib_sync) ecore_x_sync(); if (xprop.value) XFree(xprop.value); } free(list[0]); }
EAPI void ecore_x_region_translate(Ecore_X_Region region, int dx, int dy) { #ifdef ECORE_XFIXES LOGFN(__FILE__, __LINE__, __FUNCTION__); XFixesTranslateRegion(_ecore_x_disp, region, dx, dy); if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ }
EAPI void ecore_x_region_subtract(Ecore_X_Region dest, Ecore_X_Region source1, Ecore_X_Region source2) { #ifdef ECORE_XFIXES LOGFN(__FILE__, __LINE__, __FUNCTION__); XFixesSubtractRegion(_ecore_x_disp, dest, source1, source2); if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ }
EAPI void ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (on) XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask); else XShapeSelectInput(_ecore_x_disp, win, 0); if (_ecore_xlib_sync) ecore_x_sync(); }
/** * Get the WM_COMMAND property for @a win. * * Return the command of a window. String must be free'd when done with. * * @param win The window. * @param argc Number of arguments. * @param argv Arguments. */ EAPI void ecore_x_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv) { int i, c; char **v; Eina_Bool success; if (argc) *argc = 0; if (argv) *argv = NULL; LOGFN(__FILE__, __LINE__, __FUNCTION__); success = XGetCommand(_ecore_x_disp, win, &v, &c); if (_ecore_xlib_sync) ecore_x_sync(); if (!success) return; if (c < 1) { if (v) XFreeStringList(v); return; } if (argc) *argc = c; if (argv) { (*argv) = malloc(c * sizeof(char *)); if (!*argv) { XFreeStringList(v); if (argc) *argc = 0; return; } for (i = 0; i < c; i++) { if (v[i]) (*argv)[i] = strdup(v[i]); else (*argv)[i] = strdup(""); } } XFreeStringList(v); }
EAPI void ecore_x_region_set(Ecore_X_Region region, Ecore_X_Rectangle *rects, int num) { #ifdef ECORE_XFIXES XRectangle *xrect = _ecore_x_rectangle_ecore_to_x(rects, num); LOGFN(__FILE__, __LINE__, __FUNCTION__); XFixesSetRegion(_ecore_x_disp, region, xrect, num); if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ }
/** * Set protocol atoms explicitly * @param win The Window * @param protos An array of protocol atoms * @param num the number of members of the array */ EAPI void ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, Ecore_X_Atom *protos, int num) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (num > 0) XSetWMProtocols(_ecore_x_disp, win, (Atom *)(protos), num); else XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_PROTOCOLS); if (_ecore_xlib_sync) ecore_x_sync(); }
EAPI void ecore_x_region_gc_clip_set(Ecore_X_Region region, Ecore_X_GC gc, int x_origin, int y_origin) { #ifdef ECORE_XFIXES LOGFN(__FILE__, __LINE__, __FUNCTION__); XFixesSetGCClipRegion(_ecore_x_disp, gc, x_origin, y_origin, region); if (_ecore_xlib_sync) ecore_x_sync(); #endif /* ifdef ECORE_XFIXES */ }
/** * Retrieves the atom value associated with the given name. * @param name The given name. * @return Associated atom value. */ EAPI Ecore_X_Atom ecore_x_atom_get(const char *name) { Ecore_X_Atom atom; if (!_ecore_x_disp) return 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); atom = XInternAtom(_ecore_x_disp, name, False); if (_ecore_xlib_sync) ecore_x_sync(); return atom; }