Ecore_X: Add new xcb code (still not 100% complete tho).

SVN revision: 61376
This commit is contained in:
Christopher Michael 2011-07-14 15:35:42 +00:00
parent e3ad6ca2cc
commit 654b646e22
39 changed files with 18142 additions and 15816 deletions

View File

@ -1,79 +1,93 @@
MAINTAINERCLEANFILES = Makefile.in
MAINTAINERCLEANFILES = Makefile.in ecore_xcb_keysym_table.h
if BUILD_ECORE_X_XCB
AM_CPPFLAGS = \
@XCB_DAMAGE_CFLAGS@ \
@XCB_COMPOSITE_CFLAGS@ \
@XCB_DPMS_CFLAGS@ \
@XCB_RANDR_CFLAGS@ \
@XCB_RENDER_CFLAGS@ \
@XCB_SCREENSAVER_CFLAGS@ \
@XCB_SHAPE_CFLAGS@ \
@XCB_SYNC_CFLAGS@ \
@XCB_XFIXES_CFLAGS@ \
@XCB_XINERAMA_CFLAGS@ \
@XCB_XPRINT_CFLAGS@ \
@XCB_XTEST_CFLAGS@ \
@XCB_CFLAGS@ \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_x \
-I$(top_srcdir)/src/lib/ecore_input \
-I$(top_builddir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore_x \
-I$(top_builddir)/src/lib/ecore_input \
@EVAS_CFLAGS@ \
@EINA_CFLAGS@
@XCB_DAMAGE_CFLAGS@ \
@XCB_COMPOSITE_CFLAGS@ \
@XCB_DPMS_CFLAGS@ \
@XCB_RANDR_CFLAGS@ \
@XCB_RENDER_CFLAGS@ \
@XCB_SCREENSAVER_CFLAGS@ \
@XCB_SHAPE_CFLAGS@ \
@XCB_SYNC_CFLAGS@ \
@XCB_XFIXES_CFLAGS@ \
@XCB_XINERAMA_CFLAGS@ \
@XCB_XPRINT_CFLAGS@ \
@XCB_XTEST_CFLAGS@ \
@XCB_XINPUT_CFLAGS@ \
@XCB_CURSOR_CFLAGS@ \
@XCB_DRI_CFLAGS@ \
@XCB_CFLAGS@ \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_x \
-I$(top_srcdir)/src/lib/ecore_input \
-I$(top_builddir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore_x \
-I$(top_builddir)/src/lib/ecore_input \
@EINA_CFLAGS@
noinst_LTLIBRARIES = libecore_x_xcb.la
libecore_x_xcb_la_SOURCES = \
ecore_xcb_atom.c \
ecore_xcb_cursor.c \
ecore_xcb_damage.c \
ecore_xcb_composite.c \
ecore_xcb_dnd.c \
ecore_xcb_dpms.c \
ecore_xcb_drawable.c \
ecore_xcb_e.c \
ecore_xcb_events.c \
ecore_xcb_fixes.c \
ecore_xcb_gc.c \
ecore_xcb_icccm.c \
ecore_xcb_mwm.c \
ecore_xcb_netwm.c \
ecore_xcb_pixmap.c \
ecore_xcb_randr.c \
ecore_xcb_region.c \
ecore_xcb_reply.c \
ecore_xcb_screensaver.c \
ecore_xcb_selection.c \
ecore_xcb_shape.c \
ecore_xcb_sync.c \
ecore_xcb_window.c \
ecore_xcb_window_prop.c \
ecore_xcb_window_shadow.c \
ecore_xcb_xinerama.c \
ecore_xcb.c
ecore_xcb.c \
ecore_xcb_atoms.c \
ecore_xcb_extensions.c \
ecore_xcb_shape.c \
ecore_xcb_screensaver.c \
ecore_xcb_sync.c \
ecore_xcb_render.c \
ecore_xcb_randr.c \
ecore_xcb_xfixes.c \
ecore_xcb_composite.c \
ecore_xcb_cursor.c \
ecore_xcb_damage.c \
ecore_xcb_dnd.c \
ecore_xcb_dpms.c \
ecore_xcb_drawable.c \
ecore_xcb_e.c \
ecore_xcb_gc.c \
ecore_xcb_image.c \
ecore_xcb_input.c \
ecore_xcb_mwm.c \
ecore_xcb_pixmap.c \
ecore_xcb_region.c \
ecore_xcb_selection.c \
ecore_xcb_textlist.c \
ecore_xcb_events.c \
ecore_xcb_keymap.c \
ecore_xcb_netwm.c \
ecore_xcb_icccm.c \
ecore_xcb_window.c \
ecore_xcb_window_prop.c \
ecore_xcb_window_shape.c \
ecore_xcb_window_shadow.c \
ecore_xcb_xinerama.c \
ecore_xcb_error.c \
ecore_xcb_xtest.c \
ecore_xcb_vsync.c
libecore_x_xcb_la_LIBADD = \
@XCB_DAMAGE_LIBS@ \
@XCB_COMPOSITE_LIBS@ \
@XCB_DPMS_LIBS@ \
@XCB_RANDR_LIBS@ \
@XCB_RENDER_LIBS@ \
@XCB_SCREENSAVER_LIBS@ \
@XCB_SHAPE_LIBS@ \
@XCB_SYNC_LIBS@ \
@XCB_XFIXES_LIBS@ \
@XCB_XINERAMA_LIBS@ \
@XCB_XPRINT_LIBS@ \
@XCB_XTEST_LIBS@ \
@XCB_LIBS@ \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_input/libecore_input.la \
@EINA_LIBS@
@XCB_DAMAGE_LIBS@ \
@XCB_COMPOSITE_LIBS@ \
@XCB_DPMS_LIBS@ \
@XCB_RANDR_LIBS@ \
@XCB_RENDER_LIBS@ \
@XCB_SCREENSAVER_LIBS@ \
@XCB_SHAPE_LIBS@ \
@XCB_SYNC_LIBS@ \
@XCB_XFIXES_LIBS@ \
@XCB_XINERAMA_LIBS@ \
@XCB_XPRINT_LIBS@ \
@XCB_XTEST_LIBS@ \
@XCB_XINPUT_LIBS@ \
@XCB_CURSOR_LIBS@ \
@XCB_DRI_LIBS@ \
@XCB_LIBS@ \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_input/libecore_input.la \
@EINA_LIBS@
endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,397 @@
#include "ecore_xcb_private.h"
#include "ecore_x_atoms_decl.h"
/* NB: Increment if you add new atoms */
#define ECORE_X_ATOMS_COUNT 199
typedef struct _Xcb_Atom Xcb_Atom;
struct _Xcb_Atom
{
const char *name;
Ecore_X_Atom *atom;
};
/* local function prototypes */
/* local variables */
static xcb_intern_atom_cookie_t cookies[ECORE_X_ATOMS_COUNT];
static Xcb_Atom atoms[] =
{
{ "ATOM", &ECORE_X_ATOM_ATOM },
{ "CARDINAL", &ECORE_X_ATOM_CARDINAL },
{ "COMPOUND_TEXT", &ECORE_X_ATOM_COMPOUND_TEXT },
{ "FILE_NAME", &ECORE_X_ATOM_FILE_NAME },
{ "STRING", &ECORE_X_ATOM_STRING },
{ "TEXT", &ECORE_X_ATOM_TEXT },
{ "UTF8_STRING", &ECORE_X_ATOM_UTF8_STRING },
{ "WINDOW", &ECORE_X_ATOM_WINDOW },
{ "PIXMAP", &ECORE_X_ATOM_PIXMAP },
{ "VISUALID", &ECORE_X_ATOM_VISUALID },
{ "JXSelectionWindowProperty", &ECORE_X_ATOM_SELECTION_PROP_XDND },
{ "XdndSelection", &ECORE_X_ATOM_SELECTION_XDND },
{ "XdndAware", &ECORE_X_ATOM_XDND_AWARE },
{ "XdndEnter", &ECORE_X_ATOM_XDND_ENTER },
{ "XdndTypeList", &ECORE_X_ATOM_XDND_TYPE_LIST },
{ "XdndPosition", &ECORE_X_ATOM_XDND_POSITION },
{ "XdndActionCopy", &ECORE_X_ATOM_XDND_ACTION_COPY },
{ "XdndActionMove", &ECORE_X_ATOM_XDND_ACTION_MOVE },
{ "XdndActionPrivate", &ECORE_X_ATOM_XDND_ACTION_PRIVATE },
{ "XdndActionAsk", &ECORE_X_ATOM_XDND_ACTION_ASK },
{ "XdndActionList", &ECORE_X_ATOM_XDND_ACTION_LIST },
{ "XdndActionLink", &ECORE_X_ATOM_XDND_ACTION_LINK },
{ "XdndActionDescription", &ECORE_X_ATOM_XDND_ACTION_DESCRIPTION },
{ "XdndProxy", &ECORE_X_ATOM_XDND_PROXY },
{ "XdndStatus", &ECORE_X_ATOM_XDND_STATUS },
{ "XdndLeave", &ECORE_X_ATOM_XDND_LEAVE },
{ "XdndDrop", &ECORE_X_ATOM_XDND_DROP },
{ "XdndFinished", &ECORE_X_ATOM_XDND_FINISHED },
{ "XdndActionCopy", &ECORE_X_DND_ACTION_COPY },
{ "XdndActionMove", &ECORE_X_DND_ACTION_MOVE },
{ "XdndActionLink", &ECORE_X_DND_ACTION_LINK },
{ "XdndActionAsk", &ECORE_X_DND_ACTION_ASK },
{ "XdndActionPrivate", &ECORE_X_DND_ACTION_PRIVATE },
{ "_E_FRAME_SIZE", &ECORE_X_ATOM_E_FRAME_SIZE },
{ "_WIN_LAYER", &ECORE_X_ATOM_WIN_LAYER },
{ "WM_NAME", &ECORE_X_ATOM_WM_NAME },
{ "WM_ICON_NAME", &ECORE_X_ATOM_WM_ICON_NAME },
{ "WM_NORMAL_HINTS", &ECORE_X_ATOM_WM_NORMAL_HINTS },
{ "WM_SIZE_HINTS", &ECORE_X_ATOM_WM_SIZE_HINTS },
{ "WM_HINTS", &ECORE_X_ATOM_WM_HINTS },
{ "WM_CLASS", &ECORE_X_ATOM_WM_CLASS },
{ "WM_TRANSIENT_FOR", &ECORE_X_ATOM_WM_TRANSIENT_FOR },
{ "WM_PROTOCOLS", &ECORE_X_ATOM_WM_PROTOCOLS },
{ "WM_COLORMAP_WINDOWS", &ECORE_X_ATOM_WM_COLORMAP_WINDOWS },
{ "WM_COMMAND", &ECORE_X_ATOM_WM_COMMAND },
{ "WM_CLIENT_MACHINE", &ECORE_X_ATOM_WM_CLIENT_MACHINE },
{ "WM_STATE", &ECORE_X_ATOM_WM_STATE },
{ "WM_ICON_SIZE", &ECORE_X_ATOM_WM_ICON_SIZE },
{ "WM_CHANGE_STATE", &ECORE_X_ATOM_WM_CHANGE_STATE },
{ "WM_TAKE_FOCUS", &ECORE_X_ATOM_WM_TAKE_FOCUS },
{ "WM_SAVE_YOURSELF", &ECORE_X_ATOM_WM_SAVE_YOURSELF },
{ "WM_DELETE_WINDOW", &ECORE_X_ATOM_WM_DELETE_WINDOW },
{ "WM_COLORMAP_NOTIFY", &ECORE_X_ATOM_WM_COLORMAP_NOTIFY },
{ "SM_CLIENT_ID", &ECORE_X_ATOM_SM_CLIENT_ID },
{ "WM_CLIENT_LEADER", &ECORE_X_ATOM_WM_CLIENT_LEADER },
{ "WM_WINDOW_ROLE", &ECORE_X_ATOM_WM_WINDOW_ROLE },
{ "_MOTIF_WM_HINTS", &ECORE_X_ATOM_MOTIF_WM_HINTS },
{ "_NET_SUPPORTED", &ECORE_X_ATOM_NET_SUPPORTED },
{ "_NET_CLIENT_LIST", &ECORE_X_ATOM_NET_CLIENT_LIST },
{ "_NET_CLIENT_LIST_STACKING", &ECORE_X_ATOM_NET_CLIENT_LIST_STACKING },
{ "_NET_NUMBER_OF_DESKTOPS", &ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS },
{ "_NET_DESKTOP_GEOMETRY", &ECORE_X_ATOM_NET_DESKTOP_GEOMETRY },
{ "_NET_DESKTOP_VIEWPORT", &ECORE_X_ATOM_NET_DESKTOP_VIEWPORT },
{ "_NET_CURRENT_DESKTOP", &ECORE_X_ATOM_NET_CURRENT_DESKTOP },
{ "_NET_DESKTOP_NAMES", &ECORE_X_ATOM_NET_DESKTOP_NAMES },
{ "_NET_ACTIVE_WINDOW", &ECORE_X_ATOM_NET_ACTIVE_WINDOW },
{ "_NET_WORKAREA", &ECORE_X_ATOM_NET_WORKAREA },
{ "_NET_SUPPORTING_WM_CHECK", &ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK },
{ "_NET_VIRTUAL_ROOTS", &ECORE_X_ATOM_NET_VIRTUAL_ROOTS },
{ "_NET_DESKTOP_LAYOUT", &ECORE_X_ATOM_NET_DESKTOP_LAYOUT },
{ "_NET_SHOWING_DESKTOP", &ECORE_X_ATOM_NET_SHOWING_DESKTOP },
{ "_NET_CLOSE_WINDOW", &ECORE_X_ATOM_NET_CLOSE_WINDOW },
{ "_NET_MOVERESIZE_WINDOW", &ECORE_X_ATOM_NET_MOVERESIZE_WINDOW },
{ "_NET_WM_MOVERESIZE", &ECORE_X_ATOM_NET_WM_MOVERESIZE },
{ "_NET_RESTACK_WINDOW", &ECORE_X_ATOM_NET_RESTACK_WINDOW },
{ "_NET_REQUEST_FRAME_EXTENTS", &ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS },
{ "_NET_WM_NAME", &ECORE_X_ATOM_NET_WM_NAME },
{ "_NET_WM_VISIBLE_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_NAME },
{ "_NET_WM_ICON_NAME", &ECORE_X_ATOM_NET_WM_ICON_NAME },
{ "_NET_WM_VISIBLE_ICON_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME },
{ "_NET_WM_DESKTOP", &ECORE_X_ATOM_NET_WM_DESKTOP },
{ "_NET_WM_WINDOW_TYPE", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE },
{ "_NET_WM_WINDOW_TYPE_DESKTOP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP },
{ "_NET_WM_WINDOW_TYPE_DOCK", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK },
{ "_NET_WM_WINDOW_TYPE_TOOLBAR", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR },
{ "_NET_WM_WINDOW_TYPE_MENU", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU },
{ "_NET_WM_WINDOW_TYPE_UTILITY", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY },
{ "_NET_WM_WINDOW_TYPE_SPLASH", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH },
{ "_NET_WM_WINDOW_TYPE_DIALOG", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG },
{ "_NET_WM_WINDOW_TYPE_NORMAL", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL },
{ "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
&ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU },
{ "_NET_WM_WINDOW_TYPE_POPUP_MENU",
&ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU },
{ "_NET_WM_WINDOW_TYPE_TOOLTIP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP },
{ "_NET_WM_WINDOW_TYPE_NOTIFICATION",
&ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION },
{ "_NET_WM_WINDOW_TYPE_COMBO", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO },
{ "_NET_WM_WINDOW_TYPE_DND", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND },
{ "_NET_WM_STATE", &ECORE_X_ATOM_NET_WM_STATE },
{ "_NET_WM_STATE_MODAL", &ECORE_X_ATOM_NET_WM_STATE_MODAL },
{ "_NET_WM_STATE_STICKY", &ECORE_X_ATOM_NET_WM_STATE_STICKY },
{ "_NET_WM_STATE_MAXIMIZED_VERT",
&ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT },
{ "_NET_WM_STATE_MAXIMIZED_HORZ",
&ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ },
{ "_NET_WM_STATE_SHADED", &ECORE_X_ATOM_NET_WM_STATE_SHADED },
{ "_NET_WM_STATE_SKIP_TASKBAR", &ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR },
{ "_NET_WM_STATE_SKIP_PAGER", &ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER },
{ "_NET_WM_STATE_HIDDEN", &ECORE_X_ATOM_NET_WM_STATE_HIDDEN },
{ "_NET_WM_STATE_FULLSCREEN", &ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN },
{ "_NET_WM_STATE_ABOVE", &ECORE_X_ATOM_NET_WM_STATE_ABOVE },
{ "_NET_WM_STATE_BELOW", &ECORE_X_ATOM_NET_WM_STATE_BELOW },
{ "_NET_WM_STATE_DEMANDS_ATTENTION",
&ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION },
{ "_NET_WM_ALLOWED_ACTIONS", &ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS },
{ "_NET_WM_ACTION_MOVE", &ECORE_X_ATOM_NET_WM_ACTION_MOVE },
{ "_NET_WM_ACTION_RESIZE", &ECORE_X_ATOM_NET_WM_ACTION_RESIZE },
{ "_NET_WM_ACTION_MINIMIZE", &ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE },
{ "_NET_WM_ACTION_SHADE", &ECORE_X_ATOM_NET_WM_ACTION_SHADE },
{ "_NET_WM_ACTION_STICK", &ECORE_X_ATOM_NET_WM_ACTION_STICK },
{ "_NET_WM_ACTION_MAXIMIZE_HORZ",
&ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ },
{ "_NET_WM_ACTION_MAXIMIZE_VERT",
&ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT },
{ "_NET_WM_ACTION_FULLSCREEN", &ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN },
{ "_NET_WM_ACTION_CHANGE_DESKTOP",
&ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP },
{ "_NET_WM_ACTION_CLOSE", &ECORE_X_ATOM_NET_WM_ACTION_CLOSE },
{ "_NET_WM_ACTION_ABOVE", &ECORE_X_ATOM_NET_WM_ACTION_ABOVE },
{ "_NET_WM_ACTION_BELOW", &ECORE_X_ATOM_NET_WM_ACTION_BELOW },
{ "_NET_WM_STRUT", &ECORE_X_ATOM_NET_WM_STRUT },
{ "_NET_WM_STRUT_PARTIAL", &ECORE_X_ATOM_NET_WM_STRUT_PARTIAL },
{ "_NET_WM_ICON_GEOMETRY", &ECORE_X_ATOM_NET_WM_ICON_GEOMETRY },
{ "_NET_WM_ICON", &ECORE_X_ATOM_NET_WM_ICON },
{ "_NET_WM_PID", &ECORE_X_ATOM_NET_WM_PID },
{ "_NET_WM_HANDLED_ICONS", &ECORE_X_ATOM_NET_WM_HANDLED_ICONS },
{ "_NET_WM_USER_TIME", &ECORE_X_ATOM_NET_WM_USER_TIME },
{ "_NET_STARTUP_ID", &ECORE_X_ATOM_NET_STARTUP_ID },
{ "_NET_FRAME_EXTENTS", &ECORE_X_ATOM_NET_FRAME_EXTENTS },
{ "_NET_WM_PING", &ECORE_X_ATOM_NET_WM_PING },
{ "_NET_WM_SYNC_REQUEST", &ECORE_X_ATOM_NET_WM_SYNC_REQUEST },
{ "_NET_WM_SYNC_REQUEST_COUNTER",
&ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER },
{ "_NET_WM_WINDOW_OPACITY", &ECORE_X_ATOM_NET_WM_WINDOW_OPACITY },
{ "_NET_WM_WINDOW_SHADOW", &ECORE_X_ATOM_NET_WM_WINDOW_SHADOW },
{ "_NET_WM_WINDOW_SHADE", &ECORE_X_ATOM_NET_WM_WINDOW_SHADE },
{ "TARGETS", &ECORE_X_ATOM_SELECTION_TARGETS },
{ "CLIPBOARD", &ECORE_X_ATOM_SELECTION_CLIPBOARD },
{ "PRIMARY", &ECORE_X_ATOM_SELECTION_PRIMARY },
{ "SECONDARY", &ECORE_X_ATOM_SELECTION_SECONDARY },
{ "_ECORE_SELECTION_PRIMARY", &ECORE_X_ATOM_SELECTION_PROP_PRIMARY },
{ "_ECORE_SELECTION_SECONDARY", &ECORE_X_ATOM_SELECTION_PROP_SECONDARY },
{ "_ECORE_SELECTION_CLIPBOARD", &ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD },
{ "_E_VIRTUAL_KEYBOARD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD },
{ "_E_VIRTUAL_KEYBOARD_STATE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE },
{ "_E_VIRTUAL_KEYBOARD_ON", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON },
{ "_E_VIRTUAL_KEYBOARD_OFF", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF },
{ "_E_VIRTUAL_KEYBOARD_ALPHA", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA },
{ "_E_VIRTUAL_KEYBOARD_NUMERIC", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC },
{ "_E_VIRTUAL_KEYBOARD_PIN", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN },
{ "_E_VIRTUAL_KEYBOARD_PHONE_NUMBER",
&ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER },
{ "_E_VIRTUAL_KEYBOARD_HEX", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX },
{ "_E_VIRTUAL_KEYBOARD_TERMINAL",
&ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL },
{ "_E_VIRTUAL_KEYBOARD_PASSWORD",
&ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD },
{ "_E_VIRTUAL_KEYBOARD_IP", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP },
{ "_E_VIRTUAL_KEYBOARD_HOST", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST },
{ "_E_VIRTUAL_KEYBOARD_FILE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE },
{ "_E_VIRTUAL_KEYBOARD_URL", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL },
{ "_E_VIRTUAL_KEYBOARD_KEYPAD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD },
{ "_E_VIRTUAL_KEYBOARD_J2ME", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME },
{ "_E_ILLUME_ZONE", &ECORE_X_ATOM_E_ILLUME_ZONE },
{ "_E_ILLUME_ZONE_LIST", &ECORE_X_ATOM_E_ILLUME_ZONE_LIST },
{ "_E_ILLUME_CONFORMANT", &ECORE_X_ATOM_E_ILLUME_CONFORMANT },
{ "_E_ILLUME_MODE", &ECORE_X_ATOM_E_ILLUME_MODE },
{ "_E_ILLUME_MODE_SINGLE", &ECORE_X_ATOM_E_ILLUME_MODE_SINGLE },
{ "_E_ILLUME_MODE_DUAL_TOP", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP },
{ "_E_ILLUME_MODE_DUAL_LEFT", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT },
{ "_E_ILLUME_FOCUS_BACK", &ECORE_X_ATOM_E_ILLUME_FOCUS_BACK },
{ "_E_ILLUME_FOCUS_FORWARD", &ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD },
{ "_E_ILLUME_FOCUS_HOME", &ECORE_X_ATOM_E_ILLUME_FOCUS_HOME },
{ "_E_ILLUME_CLOSE", &ECORE_X_ATOM_E_ILLUME_CLOSE },
{ "_E_ILLUME_HOME_NEW", &ECORE_X_ATOM_E_ILLUME_HOME_NEW },
{ "_E_ILLUME_HOME_DEL", &ECORE_X_ATOM_E_ILLUME_HOME_DEL },
{ "_E_ILLUME_DRAG", &ECORE_X_ATOM_E_ILLUME_DRAG },
{ "_E_ILLUME_DRAG_LOCKED", &ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED },
{ "_E_ILLUME_DRAG_START", &ECORE_X_ATOM_E_ILLUME_DRAG_START },
{ "_E_ILLUME_DRAG_END", &ECORE_X_ATOM_E_ILLUME_DRAG_END },
{ "_E_ILLUME_INDICATOR_GEOMETRY",
&ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY },
{ "_E_ILLUME_SOFTKEY_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY },
{ "_E_ILLUME_KEYBOARD_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY },
{ "_E_ILLUME_QUICKPANEL", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL },
{ "_E_ILLUME_QUICKPANEL_STATE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE },
{ "_E_ILLUME_QUICKPANEL_STATE_TOGGLE",
&ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE_TOGGLE },
{ "_E_ILLUME_QUICKPANEL_ON", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON },
{ "_E_ILLUME_QUICKPANEL_OFF", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF },
{ "_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR",
&ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR },
{ "_E_ILLUME_QUICKPANEL_PRIORITY_MINOR",
&ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR },
{ "_E_ILLUME_QUICKPANEL_ZONE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE },
{ "_E_ILLUME_QUICKPANEL_POSITION_UPDATE",
&ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE },
{ "_E_COMP_SYNC_COUNTER", &ECORE_X_ATOM_E_COMP_SYNC_COUNTER },
{ "_E_COMP_SYNC_DRAW_DONE", &ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE },
{ "_E_COMP_SYNC_SUPPORTED", &ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED },
{ "_E_COMP_SYNC_BEGIN", &ECORE_X_ATOM_E_COMP_SYNC_BEGIN },
{ "_E_COMP_SYNC_END", &ECORE_X_ATOM_E_COMP_SYNC_END },
{ "_E_COMP_SYNC_CANCEL", &ECORE_X_ATOM_E_COMP_SYNC_CANCEL },
{ "_E_COMP_FLUSH", &ECORE_X_ATOM_E_COMP_FLUSH },
{ "_E_COMP_DUMP", &ECORE_X_ATOM_E_COMP_DUMP },
{ "_E_COMP_PIXMAP", &ECORE_X_ATOM_E_COMP_PIXMAP }
};
void
_ecore_xcb_atoms_init(void)
{
int i = 0, num = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
num = (sizeof(atoms) / sizeof(Xcb_Atom));
for (i = 0; i < num; i++)
{
cookies[i] =
xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
strlen(atoms[i].name), atoms[i].name);
}
}
void
_ecore_xcb_atoms_finalize(void)
{
int i = 0, num = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
num = (sizeof(atoms) / sizeof(Xcb_Atom));
for (i = 0; i < num; i++)
{
xcb_intern_atom_reply_t *reply = NULL;
if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
continue;
*(atoms[i].atom) = reply->atom;
free(reply);
}
}
/**
* @defgroup Ecore_X_Atom_Group XCB Atom Functions
*
* Functions that operate on atoms
*/
/**
* Retrieves the atom value associated to a name.
*
* @param name Unused.
* @return Associated atom value.
*
* Retrieves the atom value associated to a name. The reply is the
* returned value of the function ecore_xcb_intern_atom_reply(). If
* @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom
* associated to the name is returned.
*
* To use this function, you must call before, and in order,
* ecore_x_atom_get_prefetch(), which sends the InternAtom request,
* then ecore_x_atom_get_fetch(), which gets the reply.
*
* @ingroup Ecore_X_Atom_Group
*/
EAPI Ecore_X_Atom
ecore_x_atom_get(const char *name)
{
xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
Ecore_X_Atom a;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie = xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(name), name);
reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return XCB_ATOM_NONE;
a = reply->atom;
free(reply);
return a;
}
/**
* Retrieves the name of the given atom.
*
* @param atom
* @return The name of the atom.
*
* @ingroup Ecore_X_Atom_Group
*/
EAPI char *
ecore_x_atom_name_get(Ecore_X_Atom atom)
{
xcb_get_atom_name_cookie_t cookie;
xcb_get_atom_name_reply_t *reply;
char *name;
int len = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return NULL;
len = xcb_get_atom_name_name_length(reply);
name = (char *)malloc(sizeof(char) * (len + 1));
if (!name)
{
free(reply);
return NULL;
}
memcpy(name, xcb_get_atom_name_name(reply), len);
name[len] = '\0';
return name;
}
EAPI void
ecore_x_atoms_get(const char **names, int num, Ecore_X_Atom *atoms)
{
xcb_intern_atom_cookie_t cookies[num];
int i = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
for (i = 0; i < num; i++)
{
cookies[i] =
xcb_intern_atom_unchecked(_ecore_xcb_conn, 0,
strlen(names[i]), names[i]);
}
for (i = 0; i < num; i++)
{
xcb_intern_atom_reply_t *reply = NULL;
if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0)))
continue;
atoms[i] = reply->atom;
free(reply);
}
}

View File

@ -1,67 +1,241 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_COMPOSITE
# include <xcb/composite.h>
#endif
/* local variables */
static Eina_Bool _composite_avail = EINA_FALSE;
void
_ecore_xcb_composite_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_composite_id);
#endif
}
void
_ecore_xcb_composite_finalize(void)
{
#ifdef ECORE_XCB_COMPOSITE
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_composite_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_composite_query_version_cookie_t cookie;
xcb_composite_query_version_reply_t *reply;
cookie =
xcb_composite_query_version_unchecked(_ecore_xcb_conn,
XCB_COMPOSITE_MAJOR_VERSION,
XCB_COMPOSITE_MINOR_VERSION);
reply =
xcb_composite_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
// if ((reply->major_version >= XCB_COMPOSITE_MAJOR_VERSION) &&
if (reply->minor_version >= XCB_COMPOSITE_MINOR_VERSION)
{
# ifdef ECORE_XCB_RENDER
if (_ecore_xcb_render_avail_get())
{
# ifdef ECORE_XCB_XFIXES
if (_ecore_xcb_xfixes_avail_get())
_composite_avail = EINA_TRUE;
# endif
}
# endif
}
free(reply);
}
}
#endif
}
/**
* @defgroup Ecore_X_Composite_Group X Composite Extension Functions
*
* Functions related to the X Composite extension.
*
* Functions related to the X Composite Extension
*/
#ifdef ECORE_XCB_COMPOSITE
static uint8_t _composite_available = 0;
static xcb_composite_query_version_cookie_t _ecore_xcb_composite_init_cookie;
#endif /* ECORE_XCB_COMPOSITE */
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_composite_init and
_ecore_xcb_composite_init_finalize. The first one gets the cookies and
the second one gets the replies. */
void
_ecore_x_composite_init(const xcb_query_extension_reply_t *reply)
{
#ifdef ECORE_XCB_COMPOSITE
if (reply && reply->present)
_ecore_xcb_composite_init_cookie = xcb_composite_query_version_unchecked(_ecore_xcb_conn, XCB_COMPOSITE_MAJOR_VERSION, XCB_COMPOSITE_MINOR_VERSION);
#endif /* ECORE_XCB_COMPOSITE */
} /* _ecore_x_composite_init */
void
_ecore_x_composite_init_finalize(void)
{
#ifdef ECORE_XCB_COMPOSITE
xcb_composite_query_version_reply_t *reply;
reply = xcb_composite_query_version_reply(_ecore_xcb_conn,
_ecore_xcb_composite_init_cookie,
NULL);
if (reply)
{
if ((reply->major_version == XCB_COMPOSITE_MAJOR_VERSION) &&
(reply->minor_version >= XCB_COMPOSITE_MINOR_VERSION))
_composite_available = 1;
free(reply);
}
#endif /* ECORE_XCB_COMPOSITE */
} /* _ecore_x_composite_init_finalize */
/**
* Return whether the Composite Extension is available.
* @return 1 if the Composite Extension is available, 0 if not.
*
* Return 1 if the X server supports the Composite Extension version 0.4
* or greater, 0 otherwise.
* Return whether the Composite Extension is available
*
* @return EINA_TRUE is the Composite Extension is available, EINA_FALSE if not
*
* @ingroup Ecore_X_Composite_Group
*/
EAPI Eina_Bool
ecore_x_composite_query(void)
EAPI Eina_Bool
ecore_x_composite_query(void)
{
#ifdef ECORE_XCB_COMPOSITE
return _composite_available;
#else /* ifdef ECORE_XCB_COMPOSITE */
return 0;
#endif /* ECORE_XCB_COMPOSITE */
} /* ecore_x_composite_query */
return _composite_avail;
}
EAPI void
ecore_x_composite_redirect_window(Ecore_X_Window win, Ecore_X_Composite_Update_Type type)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
switch (type)
{
case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
break;
case ECORE_X_COMPOSITE_UPDATE_MANUAL:
update = XCB_COMPOSITE_REDIRECT_MANUAL;
break;
}
xcb_composite_redirect_window(_ecore_xcb_conn, win, update);
#endif
}
EAPI void
ecore_x_composite_redirect_subwindows(Ecore_X_Window win, Ecore_X_Composite_Update_Type type)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
switch (type)
{
case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
break;
case ECORE_X_COMPOSITE_UPDATE_MANUAL:
update = XCB_COMPOSITE_REDIRECT_MANUAL;
break;
}
xcb_composite_redirect_subwindows(_ecore_xcb_conn, win, update);
#endif
}
EAPI void
ecore_x_composite_unredirect_window(Ecore_X_Window win, Ecore_X_Composite_Update_Type type)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
switch (type)
{
case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
break;
case ECORE_X_COMPOSITE_UPDATE_MANUAL:
update = XCB_COMPOSITE_REDIRECT_MANUAL;
break;
}
xcb_composite_unredirect_window(_ecore_xcb_conn, win, update);
#endif
}
EAPI void
ecore_x_composite_unredirect_subwindows(Ecore_X_Window win, Ecore_X_Composite_Update_Type type)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
switch (type)
{
case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
update = XCB_COMPOSITE_REDIRECT_AUTOMATIC;
break;
case ECORE_X_COMPOSITE_UPDATE_MANUAL:
update = XCB_COMPOSITE_REDIRECT_MANUAL;
break;
}
xcb_composite_unredirect_subwindows(_ecore_xcb_conn, win, update);
#endif
}
EAPI Ecore_X_Pixmap
ecore_x_composite_name_window_pixmap_get(Ecore_X_Window win)
{
Ecore_X_Pixmap pmap = XCB_NONE;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
pmap = xcb_generate_id(_ecore_xcb_conn);
xcb_composite_name_window_pixmap(_ecore_xcb_conn, win, pmap);
#endif
return pmap;
}
EAPI void
ecore_x_composite_window_events_disable(Ecore_X_Window win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
ecore_x_window_shape_input_rectangle_set(win, -1, -1, 1, 1);
#else
return;
win = 0;
#endif
}
EAPI void
ecore_x_composite_window_events_enable(Ecore_X_Window win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
ecore_x_window_shape_input_rectangle_set(win, 0, 0, 65535, 65535);
#else
return;
win = 0;
#endif
}
EAPI Ecore_X_Window
ecore_x_composite_render_window_enable(Ecore_X_Window root)
{
Ecore_X_Window win = 0;
#ifdef ECORE_XCB_COMPOSITE
xcb_composite_get_overlay_window_cookie_t cookie;
xcb_composite_get_overlay_window_reply_t *reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
cookie = xcb_composite_get_overlay_window(_ecore_xcb_conn, root);
reply =
xcb_composite_get_overlay_window_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return win;
win = reply->overlay_win;
free(reply);
ecore_x_composite_window_events_disable(win);
#endif
return win;
}
EAPI void
ecore_x_composite_render_window_disable(Ecore_X_Window win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_COMPOSITE
xcb_composite_release_overlay_window(_ecore_xcb_conn, win);
#endif
}

View File

@ -1,274 +1,364 @@
#include "ecore_xcb_private.h"
#include <xcb/shm.h>
#include <xcb/xcb_image.h>
# include <xcb/xproto.h>
# include <xcb/xcb_image.h>
#ifdef ECORE_XCB_CURSOR
# include <xcb/render.h>
# include <xcb/xcb_renderutil.h>
#endif
extern int _ecore_xcb_xcursor;
/* local function prototypes */
static xcb_image_t *_ecore_xcb_cursor_image_create(int w, int h, int *pixels);
static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, int *pixels, xcb_image_t *img);
#ifdef ECORE_XCB_CURSOR
static Ecore_X_Cursor _ecore_xcb_cursor_image_load_argb_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, xcb_image_t *img);
static xcb_render_pictforminfo_t *_ecore_xcb_cursor_find_image_format(void);
#endif
EAPI Eina_Bool
ecore_x_cursor_color_supported_get(void)
/* local variables */
#ifdef ECORE_XCB_CURSOR
static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL;
#endif
static int _ecore_xcb_cursor_size = 0;
static Eina_Bool _ecore_xcb_cursor = EINA_FALSE;
void
_ecore_xcb_cursor_init(void)
{
return _ecore_xcb_xcursor;
} /* ecore_x_cursor_color_supported_get */
EAPI Ecore_X_Cursor
ecore_x_cursor_new(Ecore_X_Window window,
int *pixels,
int w,
int h,
int hot_x,
int hot_y)
{
Ecore_X_Cursor cursor = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_CURSOR
if (_ecore_x_xcursor)
{
Cursor c;
XcursorImage *xci;
/* NB: noop */
#endif
}
xci = XcursorImageCreate(w, h);
if (xci)
{
int i;
xci->xhot = hot_x;
xci->yhot = hot_y;
xci->delay = 0;
for (i = 0; i < (w * h); i++)
{
// int r, g, b, a;
//
// a = (pixels[i] >> 24) & 0xff;
// r = (((pixels[i] >> 16) & 0xff) * a) / 0xff;
// g = (((pixels[i] >> 8 ) & 0xff) * a) / 0xff;
// b = (((pixels[i] ) & 0xff) * a) / 0xff;
xci->pixels[i] = pixels[i];
// (a << 24) | (r << 16) | (g << 8) | (b);
}
c = XcursorImageLoadCursor(_ecore_x_disp, xci);
XcursorImageDestroy(xci);
return c;
}
}
else
#endif /* ECORE_XCB_CURSOR */
{
const uint32_t dither[2][2] =
{
{0, 2},
{3, 1}
};
Ecore_X_Drawable draw;
Ecore_X_Pixmap pixmap;
Ecore_X_Pixmap mask;
Ecore_X_GC gc;
xcb_image_t *image;
uint32_t *pix;
uint8_t fr;
uint8_t fg;
uint8_t fb;
uint8_t br;
uint8_t bg;
uint8_t bb;
uint32_t brightest = 0;
uint32_t darkest = 255 * 3;
uint16_t x;
uint16_t y;
draw = window;
pixmap = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn,
1, pixmap, draw,
1, 1);
mask = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn,
1, mask, draw,
1, 1);
image = xcb_image_create_native(_ecore_xcb_conn, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP,
32, NULL, ~0, NULL);
image->data = malloc(image->size);
fr = 0x00; fg = 0x00; fb = 0x00;
br = 0xff; bg = 0xff; bb = 0xff;
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint8_t r, g, b, a;
a = (pix[0] >> 24) & 0xff;
r = (pix[0] >> 16) & 0xff;
g = (pix[0] >> 8) & 0xff;
b = (pix[0]) & 0xff;
if (a > 0)
{
if ((uint32_t)(r + g + b) > brightest)
{
brightest = r + g + b;
br = r;
bg = g;
bb = b;
}
if ((uint32_t)(r + g + b) < darkest)
{
darkest = r + g + b;
fr = r;
fg = g;
fb = b;
}
}
pix++;
}
}
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint32_t v;
uint8_t r, g, b;
int32_t d1, d2;
r = (pix[0] >> 16) & 0xff;
g = (pix[0] >> 8) & 0xff;
b = (pix[0]) & 0xff;
d1 =
((r - fr) * (r - fr)) +
((g - fg) * (g - fg)) +
((b - fb) * (b - fb));
d2 =
((r - br) * (r - br)) +
((g - bg) * (g - bg)) +
((b - bb) * (b - bb));
if (d1 + d2)
{
v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
if (v > dither[x & 0x1][y & 0x1])
v = 1;
else
v = 0;
}
else
{
v = 0;
}
xcb_image_put_pixel(image, x, y, v);
pix++;
}
}
draw = pixmap;
gc = xcb_generate_id(_ecore_xcb_conn);
xcb_create_gc(_ecore_xcb_conn, gc, draw, 0, NULL);
xcb_image_put(_ecore_xcb_conn, draw, gc, image, 0, 0, 0);
xcb_free_gc(_ecore_xcb_conn, gc);
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint32_t v;
v = (((pix[0] >> 24) & 0xff) * 5) / 256;
if (v > dither[x & 0x1][y & 0x1])
v = 1;
else
v = 0;
xcb_image_put_pixel(image, x, y, v);
pix++;
}
}
draw = mask;
gc = xcb_generate_id(_ecore_xcb_conn);
xcb_create_gc (_ecore_xcb_conn, gc, draw, 0, NULL);
xcb_image_put(_ecore_xcb_conn, draw, gc, image, 0, 0, 0);
xcb_free_gc(_ecore_xcb_conn, gc);
free(image->data);
image->data = NULL;
xcb_image_destroy(image);
cursor = xcb_generate_id(_ecore_xcb_conn);
xcb_create_cursor (_ecore_xcb_conn, cursor,
pixmap, mask,
fr << 8 | fr,
fg << 8 | fg,
fb << 8 | fb,
br << 8 | br,
bg << 8 | bg,
bb << 8 | bb,
hot_x,
hot_y);
xcb_free_pixmap(_ecore_xcb_conn, pixmap);
xcb_free_pixmap(_ecore_xcb_conn, mask);
return cursor;
}
return 0;
} /* ecore_x_cursor_new */
EAPI void
ecore_x_cursor_free(Ecore_X_Cursor cursor)
void
_ecore_xcb_cursor_finalize(void)
{
xcb_free_cursor(_ecore_xcb_conn, cursor);
} /* ecore_x_cursor_free */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_CURSOR
_ecore_xcb_cursor = _ecore_xcb_render_argb_get();
#endif
}
/*
* Returns the cursor for the given shape.
* Note that the return value must not be freed with
* ecore_x_cursor_free()!
*/
EAPI Ecore_X_Cursor
ecore_x_cursor_shape_get(int shape)
EAPI Ecore_X_Cursor
ecore_x_cursor_shape_get(int shape)
{
Ecore_X_Cursor cursor;
Ecore_X_Cursor cursor = 0;
xcb_font_t font;
/* Shapes are defined in Ecore_X_Cursor.h */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
font = xcb_generate_id(_ecore_xcb_conn);
xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor");
cursor = xcb_generate_id(_ecore_xcb_conn);
xcb_create_glyph_cursor (_ecore_xcb_conn,
cursor,
font,
font,
shape,
shape + 1,
0, 0, 0,
65535, 65535, 65535);
xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font,
shape, shape + 1, 0, 0, 0, 65535, 65535, 65535);
xcb_close_font(_ecore_xcb_conn, font);
return cursor;
} /* ecore_x_cursor_shape_get */
}
EAPI void
ecore_x_cursor_size_set(int size)
EAPI void
ecore_x_cursor_free(Ecore_X_Cursor cursor)
{
#ifdef ECORE_XCB_CURSOR
XcursorSetDefaultSize(_ecore_x_disp, size);
#else /* ifdef ECORE_XCB_CURSOR */
size = 0;
#endif /* ECORE_XCB_CURSOR */
} /* ecore_x_cursor_size_set */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
EAPI int
ecore_x_cursor_size_get(void)
xcb_free_cursor(_ecore_xcb_conn, cursor);
}
EAPI Eina_Bool
ecore_x_cursor_color_supported_get(void)
{
#ifdef ECORE_XCB_CURSOR
return XcursorGetDefaultSize(_ecore_x_disp);
#else /* ifdef ECORE_XCB_CURSOR */
return 0;
#endif /* ECORE_XCB_CURSOR */
} /* ecore_x_cursor_size_get */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_cursor;
}
EAPI Ecore_X_Cursor
ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, int h, int hot_x, int hot_y)
{
Ecore_X_Cursor cursor = 0;
xcb_image_t *img;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (_ecore_xcb_cursor) // argb
{
if ((img = _ecore_xcb_cursor_image_create(w, h, pixels)))
{
#ifdef ECORE_XCB_CURSOR
cursor =
_ecore_xcb_cursor_image_load_argb_cursor(win, w, h,
hot_x, hot_y, img);
#else
cursor =
_ecore_xcb_cursor_image_load_cursor(win, w, h,
hot_x, hot_y, pixels, img);
#endif
}
else
DBG("Failed to create new cursor image");
}
else
{
if ((img = _ecore_xcb_cursor_image_create(w, h, pixels)))
{
cursor =
_ecore_xcb_cursor_image_load_cursor(win, w, h,
hot_x, hot_y, pixels, img);
}
else
DBG("Failed to create new cursor image");
}
if (cursor)
{
uint32_t mask, list;
mask = XCB_CW_CURSOR;
list = cursor;
xcb_change_window_attributes(_ecore_xcb_conn, win, mask, &list);
}
return cursor;
}
EAPI void
ecore_x_cursor_size_set(int size)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
// NB: size_set only needed for non-argb cursors
_ecore_xcb_cursor_size = size;
}
EAPI int
ecore_x_cursor_size_get(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_cursor_size;
}
/* local functions */
static xcb_image_t *
_ecore_xcb_cursor_image_create(int w, int h, int *pixels)
{
// NB: May be able to use shm here, but the image NEEDS to be in
// native format
if (_ecore_xcb_cursor)
{
#ifdef ECORE_XCB_CURSOR
return xcb_image_create_native(_ecore_xcb_conn, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP,
32, pixels, (w * h * sizeof(int)), // 32
(uint8_t *)pixels);
#else
return xcb_image_create_native(_ecore_xcb_conn, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP,
1, pixels, (w * h * sizeof(int)), // 32
(uint8_t *)pixels);
#endif
}
else
{
return xcb_image_create_native(_ecore_xcb_conn, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP, 1,
NULL, ~0, NULL);
}
}
static Ecore_X_Cursor
_ecore_xcb_cursor_image_load_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, int *pixels, xcb_image_t *img)
{
xcb_pixmap_t pixmap, mask;
Ecore_X_Cursor cursor;
Ecore_X_GC gc;
uint32_t *pix;
uint8_t fr = 0x00, fg = 0x00, fb = 0x00;
uint8_t br = 0xff, bg = 0xff, bb = 0xff;
uint32_t brightest = 0, darkest = 255 * 3;
uint16_t x, y;
const uint32_t dither[2][2] =
{
{0, 2},
{3, 1}
};
pixmap = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn, 1, pixmap, win, w, h);
mask = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h);
img->data = malloc(img->size);
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint8_t r, g, b, a;
a = (pix[0] >> 24) & 0xff;
r = (pix[0] >> 16) & 0xff;
g = (pix[0] >> 8) & 0xff;
b = (pix[0]) & 0xff;
if (a > 0)
{
if ((uint32_t)(r + g + b) > brightest)
{
brightest = r + g + b;
br = r;
bg = g;
bb = b;
}
if ((uint32_t)(r + g + b) < darkest)
{
darkest = r + g + b;
fr = r;
fg = g;
fb = b;
}
}
pix++;
}
}
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint32_t v;
uint8_t r, g, b;
int32_t d1, d2;
r = (pix[0] >> 16) & 0xff;
g = (pix[0] >> 8) & 0xff;
b = (pix[0]) & 0xff;
d1 =
((r - fr) * (r - fr)) +
((g - fg) * (g - fg)) +
((b - fb) * (b - fb));
d2 =
((r - br) * (r - br)) +
((g - bg) * (g - bg)) +
((b - bb) * (b - bb));
if (d1 + d2)
{
v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
if (v > dither[x & 0x1][y & 0x1])
v = 1;
else
v = 0;
}
else
v = 0;
xcb_image_put_pixel(img, x, y, v);
pix++;
}
}
// img->depth was 1
gc = ecore_x_gc_new(pixmap, 0, NULL);
xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
pixmap, gc, w, h, 0, 0, 0, img->depth, img->size, img->data);
ecore_x_gc_free(gc);
pix = (uint32_t *)pixels;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
uint32_t v;
v = (((pix[0] >> 24) & 0xff) * 5) / 256;
if (v > dither[x & 0x1][y & 0x1])
v = 1;
else
v = 0;
xcb_image_put_pixel(img, x, y, v);
pix++;
}
}
// img->depth was 1
gc = ecore_x_gc_new(mask, 0, NULL);
xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
mask, gc, w, h, 0, 0, 0, img->depth, img->size, img->data);
ecore_x_gc_free(gc);
cursor = xcb_generate_id(_ecore_xcb_conn);
xcb_create_cursor(_ecore_xcb_conn, cursor, pixmap, mask,
fr << 8 | fr, fg << 8 | fg, fb << 8 | fb,
br << 8 | br, bg << 8 | bg, bb << 8 | bb,
hot_x, hot_y);
xcb_free_pixmap(_ecore_xcb_conn, pixmap);
xcb_free_pixmap(_ecore_xcb_conn, mask);
return cursor;
}
#ifdef ECORE_XCB_CURSOR
static Ecore_X_Cursor
_ecore_xcb_cursor_image_load_argb_cursor(Ecore_X_Window win, int w, int h, int hot_x, int hot_y, xcb_image_t *img)
{
xcb_pixmap_t pixmap;
xcb_render_picture_t pict;
Ecore_X_Cursor cursor;
Ecore_X_GC gc;
if (!_ecore_xcb_cursor_format)
_ecore_xcb_cursor_format = _ecore_xcb_cursor_find_image_format();
pixmap = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn, 32, pixmap, win, w, h);
// img->depth was 32
gc = ecore_x_gc_new(pixmap, 0, NULL);
xcb_put_image(_ecore_xcb_conn, XCB_IMAGE_FORMAT_Z_PIXMAP,
pixmap, gc, w, h, 0, 0, 0,
img->depth, img->size, img->data);
ecore_x_gc_free(gc);
pict = xcb_generate_id(_ecore_xcb_conn);
xcb_render_create_picture(_ecore_xcb_conn, pict, pixmap,
_ecore_xcb_cursor_format->id, 0, NULL);
xcb_free_pixmap(_ecore_xcb_conn, pixmap);
cursor = xcb_generate_id(_ecore_xcb_conn);
xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y);
xcb_render_free_picture(_ecore_xcb_conn, pict);
return cursor;
}
static xcb_render_pictforminfo_t *
_ecore_xcb_cursor_find_image_format(void)
{
const xcb_render_query_pict_formats_reply_t *reply;
xcb_render_pictforminfo_t *ret = NULL;
reply = xcb_render_util_query_formats(_ecore_xcb_conn);
if (reply)
{
ret = xcb_render_util_find_standard_format(reply,
XCB_PICT_STANDARD_ARGB_32);
// free(reply);
}
return ret;
}
#endif

View File

@ -1,113 +1,122 @@
#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_DAMAGE
# include <xcb/damage.h>
# endif
/* local variables */
static Eina_Bool _damage_avail = EINA_FALSE;
/* external variables */
int _ecore_xcb_event_damage = -1;
void
_ecore_xcb_damage_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DAMAGE
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_damage_id);
#endif
}
void
_ecore_xcb_damage_finalize(void)
{
#ifdef ECORE_XCB_DAMAGE
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DAMAGE
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_damage_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_damage_query_version_cookie_t cookie;
xcb_damage_query_version_reply_t *reply;
cookie =
xcb_damage_query_version_unchecked(_ecore_xcb_conn,
XCB_DAMAGE_MAJOR_VERSION,
XCB_DAMAGE_MINOR_VERSION);
reply = xcb_damage_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if (reply->major_version >= XCB_DAMAGE_MAJOR_VERSION)
_damage_avail = EINA_TRUE;
free(reply);
}
if (_damage_avail)
_ecore_xcb_event_damage = ext_reply->first_event;
}
#endif
}
/**
* @defgroup Ecore_X_Damage_Group X Damage Extension Functions
*
* Functions related to the X Damage extension.
*
* Functions related to the X Damage Extension.
*/
#ifdef ECORE_XCB_DAMAGE
static uint8_t _damage_available = 0;
static xcb_damage_query_version_cookie_t _ecore_xcb_damage_init_cookie;
#endif /* ECORE_XCB_DAMAGE */
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_damage_init and
_ecore_xcb_damage_init_finalize. The first one gets the cookies and
the second one gets the replies. */
void
_ecore_x_damage_init(const xcb_query_extension_reply_t *reply)
EAPI Eina_Bool
ecore_x_damage_query(void)
{
#ifdef ECORE_XCB_DAMAGE
if (reply && (reply->present))
_ecore_xcb_damage_init_cookie = xcb_damage_query_version_unchecked(_ecore_xcb_conn, 1, 1);
#endif /* ECORE_XCB_DAMAGE */
} /* _ecore_x_damage_init */
void
_ecore_x_damage_init_finalize(void)
{
#ifdef ECORE_XCB_DAMAGE
xcb_damage_query_version_reply_t *reply;
reply = xcb_damage_query_version_reply(_ecore_xcb_conn,
_ecore_xcb_damage_init_cookie,
NULL);
if (reply)
{
if (reply->major_version >= 1)
_damage_available = 1;
free(reply);
}
#endif /* ECORE_XCB_DAMAGE */
} /* _ecore_x_damage_init_finalize */
return _damage_avail;
}
/**
* Return whether the Damage Extension is available.
* @return 1 if the Damage Extension is available, 0 if not.
*
* Return 1 if the X server supports the Damage Extension version 1.0,
* 0 otherwise.
* Create a damage object
*
* @param drawable The drawable to monitor
* @param level The level of the damage report
* @return The damage object
*
* Creates a damage object to monitor changes to @p drawable,
* with the level @p level.
*
* @ingroup Ecore_X_Damage_Group
*/
EAPI Eina_Bool
ecore_x_damage_query(void)
{
#ifdef ECORE_XCB_DAMAGE
return _damage_available;
#else /* ifdef ECORE_XCB_DAMAGE */
return 0;
#endif /* ECORE_XCB_DAMAGE */
} /* ecore_x_damage_query */
/**
* Creates a damage object.
* @param drawable The drawable to monotor.
* @param level The level of the damage report.
* @return The damage object.
*
* Creates a damage object to monitor changes to @p drawable, with the
* level @p level.
* @ingroup Ecore_X_Damage_Group
*/
EAPI Ecore_X_Damage
ecore_x_damage_new(Ecore_X_Drawable drawable,
Ecore_X_Damage_Report_Level level)
EAPI Ecore_X_Damage
ecore_x_damage_new(Ecore_X_Drawable drawable, Ecore_X_Damage_Report_Level level)
{
Ecore_X_Damage damage = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DAMAGE
damage = xcb_generate_id(_ecore_xcb_conn);
xcb_damage_create(_ecore_xcb_conn, damage, drawable, level);
#endif /* ECORE_XCB_DAMAGE */
#endif
return damage;
} /* ecore_x_damage_new */
}
/**
* Destroys a damage object.
* @param damage The damage object to destroy.
*
* Destroys the damage object @p damage.
* Destroy a damage object
*
* @param The damage object to destroy
*
* Destroys the damage object @p damage
*
* @ingroup Ecore_X_Damage_Group
*/
EAPI void
ecore_x_damage_free(Ecore_X_Damage damage)
EAPI void
ecore_x_damage_free(Ecore_X_Damage damage)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DAMAGE
xcb_damage_destroy(_ecore_xcb_conn, damage);
#endif /* ECORE_XCB_DAMAGE */
} /* ecore_x_damage_free */
#endif
}
/**
* Synchronously modifies the region.
* @param damage The damage object to destroy.
* @param repair The repair region.
* @param parts The parts region.
* Synchronously modifies the region
*
* @param damage The damage object to destroy
* @param repair The repair region
* @param parts The parts region
*
* Synchronously modifies the regions in the following manner:
* If @p repair is @c XCB_NONE:
@ -117,15 +126,15 @@ ecore_x_damage_free(Ecore_X_Damage damage)
* 1) parts = damage INTERSECT repair
* 2) damage = damage - parts
* 3) Generate DamageNotify for remaining damage areas
*
* @ingroup Ecore_X_Damage_Group
*/
EAPI void
ecore_x_damage_subtract(Ecore_X_Damage damage,
Ecore_X_Region repair,
Ecore_X_Region parts)
EAPI void
ecore_x_damage_subtract(Ecore_X_Damage damage, Ecore_X_Region repair, Ecore_X_Region parts)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DAMAGE
xcb_damage_subtract(_ecore_xcb_conn, damage, repair, parts);
#endif /* ECORE_XCB_DAMAGE */
} /* ecore_x_damage_subtract */
#endif
}

File diff suppressed because it is too large Load Diff

View File

@ -1,253 +1,156 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_DAMAGE
# include <xcb/dpms.h>
#endif
/* local variables */
static Eina_Bool _dpms_avail = EINA_FALSE;
void
_ecore_xcb_dpms_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DPMS
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
#endif
}
void
_ecore_xcb_dpms_finalize(void)
{
#ifdef ECORE_XCB_DPMS
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DPMS
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_dpms_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_dpms_get_version_cookie_t cookie;
xcb_dpms_get_version_reply_t *reply;
cookie =
xcb_dpms_get_version_unchecked(_ecore_xcb_conn,
XCB_DPMS_MAJOR_VERSION,
XCB_DPMS_MINOR_VERSION);
reply = xcb_dpms_get_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if (reply->server_major_version >= 1)
_dpms_avail = EINA_TRUE;
free(reply);
}
}
#endif
}
/**
* @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
*
* Functions related to the X DPMS extension.
*
* Functions related to the X DPMS Extension
*/
#ifdef ECORE_XCB_DPMS
static int _dpms_available = 0;
static xcb_dpms_get_version_cookie_t _ecore_xcb_dpms_init_cookie;
#endif /* ECORE_XCB_DPMS */
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_dpms_init and
_ecore_xcb_dpms_init_finalize. The first one gets the cookies and
the second one gets the replies. */
void
_ecore_x_dpms_init(const xcb_query_extension_reply_t *reply)
{
#ifdef ECORE_XCB_DPMS
if (reply && (reply->present))
_ecore_xcb_dpms_init_cookie = xcb_dpms_get_version_unchecked(_ecore_xcb_conn, 0, 0);
#endif /* ECORE_XCB_DPMS */
} /* _ecore_x_dpms_init */
void
_ecore_x_dpms_init_finalize(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_version_reply_t *reply;
reply = xcb_dpms_get_version_reply(_ecore_xcb_conn,
_ecore_xcb_dpms_init_cookie, NULL);
if (reply)
{
if (reply->server_major_version >= 1)
_dpms_available = 1;
free(reply);
}
#endif /* ECORE_XCB_DPMS */
} /* _ecore_x_dpms_init_finalize */
/**
* Checks if the DPMS extension is available or not.
* @return @c 1 if the DPMS extension is available, @c 0 otherwise.
*
* @return @c EINA_TRUE if the DPMS extension is available,
* @c EINA_FALSE otherwise.
*
* Return 1 if the X server supports the DPMS Extension version 1.0,
* 0 otherwise.
* Return EINA_TRUE if the X server supports the DPMS Extension version 1.0,
* EINA_FALSE otherwise.
*
* @ingroup Ecore_X_DPMS_Group
*/
EAPI Eina_Bool
ecore_x_dpms_query(void)
EAPI Eina_Bool
ecore_x_dpms_query(void)
{
#ifdef ECORE_XCB_DPMS
return _dpms_available;
#else /* ifdef ECORE_XCB_DPMS */
return 0;
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_query */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
/**
* Sends the DPMSCapable request.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_capable_get_prefetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_capable_cookie_t cookie;
cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_capable_get_prefetch */
/**
* Gets the reply of the DPMSCapable request sent by ecore_x_dpms_capable_get_prefetch().
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_capable_get_fetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_capable_cookie_t cookie;
xcb_dpms_capable_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_capable_get_fetch */
return _dpms_avail;
}
/**
* Checks if the X server is capable of DPMS.
* @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_capable_get_prefetch(), which sends the DPMSCapable request,
* then ecore_x_dpms_capable_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI Eina_Bool
ecore_x_dpms_capable_get(void)
EAPI Eina_Bool
ecore_x_dpms_capable_get(void)
{
int capable = 0;
int ret = EINA_FALSE;
#ifdef ECORE_XCB_DPMS
xcb_dpms_capable_cookie_t cookie;
xcb_dpms_capable_reply_t *reply;
#endif
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
capable = reply->capable;
#endif /* ECORE_XCB_DPMS */
if (!_dpms_avail) return EINA_FALSE;
return capable;
} /* ecore_x_dpms_capable_get */
/**
* Sends the DPMSInfo request.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_enable_get_prefetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_info_cookie_t cookie;
cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn);
reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
ret = reply->capable;
free(reply);
}
#endif
cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_enable_get_prefetch */
/**
* Gets the reply of the DPMSInfo request sent by ecore_x_dpms_enable_get_prefetch().
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_enable_get_fetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_info_cookie_t cookie;
xcb_dpms_info_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_enable_get_fetch */
return ret;
}
/**
* Checks the DPMS state of the display.
* @return @c 1 if DPMS is enabled, @c 0 otherwise.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_enapable_get_prefetch(), which sends the DPMSInfo request,
* then ecore_x_dpms_enapable_get_fetch(), which gets the reply.
* @return @c EINA_TRUE if DPMS is enabled, @c EINA_FALSE otherwise.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI int
ecore_x_dpms_enable_get(void)
EAPI Eina_Bool
ecore_x_dpms_enabled_get(void)
{
int enable = 0;
int ret = EINA_FALSE;
#ifdef ECORE_XCB_DPMS
xcb_dpms_info_cookie_t cookie;
xcb_dpms_info_reply_t *reply;
#endif
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
enable = reply->state;
#endif /* ECORE_XCB_DPMS */
if (!_dpms_avail) return EINA_FALSE;
return enable;
} /* ecore_x_dpms_enable_get */
#ifdef ECORE_XCB_DPMS
cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn);
reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return EINA_FALSE;
if (reply->state) ret = EINA_TRUE;
free(reply);
#endif
return ret;
}
/**
* Sets the DPMS state of the display.
* @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_enabled_set(int enabled)
EAPI void
ecore_x_dpms_enabled_set(int enabled)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_dpms_avail) return;
#ifdef ECORE_XCB_DPMS
if (enabled)
xcb_dpms_enable(_ecore_xcb_conn);
else
xcb_dpms_disable(_ecore_xcb_conn);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_enabled_set */
/**
* Sets the timeouts. The values are in unit of seconds.
* @param standby Amount of time of inactivity before standby mode will be invoked.
* @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
* @param off Amount of time of inactivity before the monitor is shut off.
* @return Returns always 1.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI Eina_Bool
ecore_x_dpms_timeouts_set(unsigned int standby,
unsigned int suspend,
unsigned int off)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
#endif /* ECORE_XCB_DPMS */
return 1;
} /* ecore_x_dpms_timeouts_set */
/**
* Sends the DPMSGetTimeouts request.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeouts_get_prefetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_cookie_t cookie;
cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_timeouts_get_prefetch */
/**
* Gets the reply of the DPMSGetTimeouts request sent by ecore_x_dpms_timeouts_get_prefetch().
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeouts_get_fetch(void)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_cookie_t cookie;
xcb_dpms_get_timeouts_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_timeouts_get_fetch */
if (enabled)
xcb_dpms_enable(_ecore_xcb_conn);
else
xcb_dpms_disable(_ecore_xcb_conn);
#endif
}
/**
* Gets the timeouts. The values are in unit of seconds.
@ -256,195 +159,149 @@ ecore_x_dpms_timeouts_get_fetch(void)
* @param off Amount of time of inactivity before the monitor is shut off.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeouts_get(unsigned int *standby,
unsigned int *suspend,
unsigned int *off)
EAPI void
ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_cookie_t cookie;
xcb_dpms_get_timeouts_reply_t *reply;
#endif
reply = _ecore_xcb_reply_get();
if (reply)
{
if (standby)
*standby = reply->standby_timeout;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (suspend)
*suspend = reply->suspend_timeout;
if (standby) *standby = 0;
if (suspend) *suspend = 0;
if (off) *off = 0;
if (off)
*off = 0;
}
else
#endif /* ECORE_XCB_DPMS */
{
if (standby)
*standby = 0;
if (!_dpms_avail) return;
if (suspend)
*suspend = 0;
#ifdef ECORE_XCB_DPMS
cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn);
reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
if (standby) *standby = reply->standby_timeout;
if (suspend) *suspend = reply->suspend_timeout;
if (off) *off = reply->off_timeout;
free(reply);
#endif
}
if (off)
*off = 0;
}
} /* ecore_x_dpms_timeouts_get */
/**
* Sets the timeouts. The values are in unit of seconds.
* @param standby Amount of time of inactivity before standby mode will be invoked.
* @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
* @param off Amount of time of inactivity before the monitor is shut off.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI Eina_Bool
ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_dpms_avail) return EINA_FALSE;
#ifdef ECORE_XCB_DPMS
xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off);
return EINA_TRUE;
#endif
return EINA_FALSE;
}
/**
* Returns the amount of time of inactivity before standby mode is invoked.
* @return The standby timeout value.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI unsigned int
ecore_x_dpms_timeout_standby_get(void)
EAPI unsigned int
ecore_x_dpms_timeout_standby_get(void)
{
int standby = 0;
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int standby = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
standby = reply->standby_timeout;
#endif /* ECORE_XCB_DPMS */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_x_dpms_timeouts_get(&standby, NULL, NULL);
return standby;
} /* ecore_x_dpms_timeout_standby_get */
}
/**
* Returns the amount of time of inactivity before the second level of
* power saving is invoked.
* @return The suspend timeout value.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI unsigned int
ecore_x_dpms_timeout_suspend_get(void)
EAPI unsigned int
ecore_x_dpms_timeout_suspend_get(void)
{
int suspend = 0;
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int suspend = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
suspend = reply->suspend_timeout;
#endif /* ECORE_XCB_DPMS */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_x_dpms_timeouts_get(NULL, &suspend, NULL);
return suspend;
} /* ecore_x_dpms_timeout_suspend_get */
}
/**
* Returns the amount of time of inactivity before the third and final
* level of power saving is invoked.
* @return The off timeout value.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI unsigned int
ecore_x_dpms_timeout_off_get(void)
EAPI unsigned int
ecore_x_dpms_timeout_off_get(void)
{
int off = 0;
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int off = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
off = reply->off_timeout;
#endif /* ECORE_XCB_DPMS */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_x_dpms_timeouts_get(NULL, NULL, &off);
return off;
} /* ecore_x_dpms_timeout_off_get */
}
/**
* Sets the standby timeout (in unit of seconds).
* @param new_standby Amount of time of inactivity before standby mode will be invoked.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeout_standby_set(unsigned int new_standby)
EAPI void
ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int standby = 0, suspend = 0, off = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_dpms_set_timeouts(_ecore_xcb_conn,
new_standby,
reply->suspend_timeout,
reply->off_timeout);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_timeout_standby_set */
ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
ecore_x_dpms_timeouts_set(new_timeout, suspend, off);
}
/**
* Sets the suspend timeout (in unit of seconds).
* @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeout_suspend_set(unsigned int new_suspend)
EAPI void
ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int standby = 0, suspend = 0, off = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_dpms_set_timeouts(_ecore_xcb_conn,
reply->standby_timeout,
new_suspend,
reply->off_timeout);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_timeout_suspend_set */
ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
ecore_x_dpms_timeouts_set(standby, new_timeout, off);
}
/**
* Sets the off timeout (in unit of seconds).
* @param off Amount of time of inactivity before the monitor is shut off.
*
* To use this function, you must call before, and in order,
* ecore_x_dpms_timeouts_get_prefetch(), which sends the DPMSGetTimeouts request,
* then ecore_x_dpms_timeouts_get_fetch(), which gets the reply.
* @ingroup Ecore_X_DPMS_Group
*/
EAPI void
ecore_x_dpms_timeout_off_set(unsigned int new_off)
EAPI void
ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
{
#ifdef ECORE_XCB_DPMS
xcb_dpms_get_timeouts_reply_t *reply;
unsigned int standby = 0, suspend = 0, off = 0;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
xcb_dpms_set_timeouts(_ecore_xcb_conn,
reply->standby_timeout,
reply->suspend_timeout,
new_off);
#endif /* ECORE_XCB_DPMS */
} /* ecore_x_dpms_timeout_off_set */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_x_dpms_timeouts_get(&standby, &suspend, &off);
ecore_x_dpms_timeouts_set(standby, suspend, new_timeout);
}

View File

@ -1,5 +1,4 @@
#include "ecore_xcb_private.h"
#include <xcb/xcb.h>
/**
* @defgroup Ecore_X_Drawable_Group X Drawable Functions
@ -7,132 +6,6 @@
* Functions that operate on drawables.
*/
/**
* Sends the GetGeometry request.
* @param drawable Drawable whose characteristics are sought.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI void
ecore_x_drawable_geometry_get_prefetch(Ecore_X_Drawable drawable)
{
xcb_get_geometry_cookie_t cookie;
cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, drawable);
_ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_drawable_geometry_get_prefetch */
/**
* Gets the reply of the GetGeometry request sent by ecore_x_atom_get_prefetch().
* @ingroup Ecore_X_Drawable_Group
*/
EAPI void
ecore_x_drawable_geometry_get_fetch(void)
{
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
} /* ecore_x_drawable_geometry_get_fetch */
/**
* Retrieves the geometry of the given drawable.
* @param drawable Unused.
* @param x Pointer to an integer into which the X position is to be stored.
* @param y Pointer to an integer into which the Y position is to be stored.
* @param width Pointer to an integer into which the width is to be stored.
* @param height Pointer to an integer into which the height is to be stored.
*
* To use this function, you must call before, and in order,
* ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
* then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI void
ecore_x_drawable_geometry_get(Ecore_X_Drawable drawable __UNUSED__,
int *x,
int *y,
int *width,
int *height)
{
xcb_get_geometry_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
{
if (x)
*x = 0;
if (y)
*y = 0;
if (width)
*width = 0;
if (height)
*height = 0;
return;
}
if (x)
*x = reply->x;
if (y)
*y = reply->y;
if (width)
*width = reply->width;
if (height)
*height = reply->height;
} /* ecore_x_drawable_geometry_get */
/**
* Retrieves the width of the border of the given drawable.
* @param drawable Unused.
* @return The border width of the given drawable.
*
* To use this function, you must call before, and in order,
* ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
* then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI int
ecore_x_drawable_border_width_get(Ecore_X_Drawable drawable __UNUSED__)
{
xcb_get_geometry_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
return reply->border_width;
} /* ecore_x_drawable_border_width_get */
/**
* Retrieves the depth of the given drawable.
* @param drawable Unused.
* @return The depth of the given drawable.
*
* To use this function, you must call before, and in order,
* ecore_x_drawable_geometry_get_prefetch(), which sends the GetGeometry request,
* then ecore_x_drawable_geometry_get_fetch(), which gets the reply.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI int
ecore_x_drawable_depth_get(Ecore_X_Drawable drawable __UNUSED__)
{
xcb_get_geometry_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
return reply->depth;
} /* ecore_x_drawable_depth_get */
/**
* Fill the specified rectangle on a drawable.
* @param d The given drawable.
@ -142,15 +15,94 @@ ecore_x_drawable_depth_get(Ecore_X_Drawable drawable __UNUSED__)
* @param width The width of the rectangle.
* @param height The height of the rectangle.
*/
EAPI void
ecore_x_drawable_rectangle_fill(Ecore_X_Drawable d, Ecore_X_GC gc, int x, int y, int width, int height)
EAPI void
ecore_x_drawable_rectangle_fill(Ecore_X_Drawable draw, Ecore_X_GC gc, int x, int y, int w, int h)
{
xcb_rectangle_t rectangle;
xcb_rectangle_t rect;
rectangle.x = x;
rectangle.y = y;
rectangle.width = width;
rectangle.height = height;
xcb_poly_fill_rectangle(_ecore_xcb_conn, d, gc, 1, &rectangle);
} /* ecore_x_drawable_rectangle_fill */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_poly_fill_rectangle(_ecore_xcb_conn, draw, gc, 1,
(const xcb_rectangle_t *)&rect);
}
/**
* Retrieves the geometry of the given drawable.
* @param d The given drawable.
* @param x Pointer to an integer into which the X position is to be stored.
* @param y Pointer to an integer into which the Y position is to be stored.
* @param w Pointer to an integer into which the width is to be stored.
* @param h Pointer to an integer into which the height is to be stored.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI void
ecore_x_drawable_geometry_get(Ecore_X_Drawable draw, int *x, int *y, int *w, int *h)
{
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (x) *x = 0;
if (y) *y = 0;
if (w) *w = 0;
if (h) *h = 0;
cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw);
reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
if (x) *x = reply->x;
if (y) *y = reply->y;
if (w) *w = (int)reply->width;
if (h) *h = (int)reply->height;
free(reply);
}
/**
* Retrieves the width of the border of the given drawable.
* @param d The given drawable.
* @return The border width of the given drawable.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI int
ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
{
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
int ret = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
ret = (int)reply->border_width;
free(reply);
return ret;
}
/**
* Retrieves the depth of the given drawable.
* @param d The given drawable.
* @return The depth of the given drawable.
* @ingroup Ecore_X_Drawable_Group
*/
EAPI int
ecore_x_drawable_depth_get(Ecore_X_Drawable d)
{
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
int ret = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d);
reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
ret = (int)reply->depth;
free(reply);
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,95 @@
#include "ecore_xcb_private.h"
#include <xcb/xcb_event.h>
/* local variables */
static void (*_error_func)(void *data) = NULL;
static void *_error_data = NULL;
static void (*_io_error_func)(void *data) = NULL;
static void *_io_error_data = NULL;
static int _error_request_code = 0;
static int _error_code = 0;
/**
* Set the error handler.
* @param func The error handler function
* @param data The data to be passed to the handler function
*
* Set the X error handler function
*/
EAPI void
ecore_x_error_handler_set(void (*func)(void *data), const void *data)
{
_error_func = func;
_error_data = (void *)data;
}
/**
* Set the I/O error handler.
* @param func The I/O error handler function
* @param data The data to be passed to the handler function
*
* Set the X I/O error handler function
*/
EAPI void
ecore_x_io_error_handler_set(void (*func)(void *data), const void *data)
{
_io_error_func = func;
_io_error_data = (void *)data;
}
/**
* Get the request code that caused the error.
* @return The request code causing the X error
*
* Return the X request code that caused the last X error
*/
EAPI int
ecore_x_error_request_get(void)
{
return _error_request_code;
}
/**
* Get the error code from the error.
* @return The error code from the X error
*
* Return the error code from the last X error
*/
EAPI int
ecore_x_error_code_get(void)
{
return _error_code;
}
int
_ecore_xcb_error_handle(xcb_generic_error_t *err)
{
WRN("Got Error:");
WRN("\tEvent: %s", xcb_event_get_request_label(err->major_code));
WRN("\tError: %s", xcb_event_get_error_label(err->error_code));
if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE)
WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value);
else if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW)
WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value);
_error_request_code = err->sequence;
_error_code = err->error_code;
if (_error_func)
_error_func(_error_data);
return 0;
}
int
_ecore_xcb_io_error_handle(xcb_generic_error_t *err)
{
CRIT("IO Error:");
CRIT("\tRequest: %d", err->sequence);
CRIT("\tCode: %d", err->error_code);
if (_io_error_func)
_io_error_func(_io_error_data);
else
exit(-1);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,139 @@
#include "ecore_xcb_private.h"
void
_ecore_xcb_extensions_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_big_requests_id);
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_shm_id);
#ifdef ECORE_XCB_SHAPE
_ecore_xcb_shape_init();
#endif
#ifdef ECORE_XCB_SCREENSAVER
_ecore_xcb_screensaver_init();
#endif
#ifdef ECORE_XCB_SYNC
_ecore_xcb_sync_init();
#endif
#ifdef ECORE_XCB_RANDR
_ecore_xcb_randr_init();
#endif
#ifdef ECORE_XCB_XFIXES
_ecore_xcb_xfixes_init();
#endif
#ifdef ECORE_XCB_DAMAGE
_ecore_xcb_damage_init();
#endif
#ifdef ECORE_XCB_RENDER
_ecore_xcb_render_init();
#endif
#ifdef ECORE_XCB_COMPOSITE
_ecore_xcb_composite_init();
#endif
#ifdef ECORE_XCB_DPMS
_ecore_xcb_dpms_init();
#endif
#ifdef ECORE_XCB_DPMS
_ecore_xcb_dpms_init();
#endif
#ifdef ECORE_XCB_CURSOR
_ecore_xcb_cursor_init();
#endif
#ifdef ECORE_XCB_XINERAMA
_ecore_xcb_xinerama_init();
#endif
#ifdef ECORE_XCB_XINPUT
_ecore_xcb_input_init();
#endif
#ifdef ECORE_XCB_DRI
_ecore_xcb_dri_init();
#endif
#ifdef ECORE_XCB_XTEST
_ecore_xcb_xtest_init();
#endif
xcb_prefetch_maximum_request_length(_ecore_xcb_conn);
}
void
_ecore_xcb_extensions_finalize(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_get_extension_data(_ecore_xcb_conn, &xcb_big_requests_id);
xcb_get_extension_data(_ecore_xcb_conn, &xcb_shm_id);
#ifdef ECORE_XCB_SHAPE
_ecore_xcb_shape_finalize();
#endif
#ifdef ECORE_XCB_SCREENSAVER
_ecore_xcb_screensaver_finalize();
#endif
#ifdef ECORE_XCB_SYNC
_ecore_xcb_sync_finalize();
#endif
#ifdef ECORE_XCB_RANDR
_ecore_xcb_randr_finalize();
#endif
#ifdef ECORE_XCB_XFIXES
_ecore_xcb_xfixes_finalize();
#endif
#ifdef ECORE_XCB_DAMAGE
_ecore_xcb_damage_finalize();
#endif
#ifdef ECORE_XCB_RENDER
_ecore_xcb_render_finalize();
#endif
#ifdef ECORE_XCB_COMPOSITE
_ecore_xcb_composite_finalize();
#endif
#ifdef ECORE_XCB_DPMS
_ecore_xcb_dpms_finalize();
#endif
#ifdef ECORE_XCB_CURSOR
_ecore_xcb_cursor_finalize();
#endif
#ifdef ECORE_XCB_XINERAMA
_ecore_xcb_xinerama_finalize();
#endif
#ifdef ECORE_XCB_XINPUT
_ecore_xcb_input_finalize();
#endif
#ifdef ECORE_XCB_DRI
_ecore_xcb_dri_finalize();
#endif
#ifdef ECORE_XCB_XTEST
_ecore_xcb_xtest_finalize();
#endif
xcb_get_maximum_request_length(_ecore_xcb_conn);
}

View File

@ -3,42 +3,136 @@
/**
* Creates a new default graphics context associated with the given
* drawable.
* @param drawable Drawable to create graphics context with. If @c 0 is
* given instead, the default root window is used.
* @param draw Drawable to create graphics context with. If @c 0 is
* given instead, the default root window is used.
* @param value_mask Bitmask values.
* @param value_list List of values. The order of values must be the
* same than the corresponding bitmaks.
* @return The new default graphics context.
*
* Creates a new default graphics context associated with @p
* drawable. The graphic context can be used with any destination
* drawable having the same root and depth as @p drawable. Use with
* other drawables results in a BadMatch error.
* @return The new default graphics context.
*/
EAPI Ecore_X_GC
ecore_x_gc_new(Ecore_X_Drawable drawable, Ecore_X_GC_Value_Mask value_mask, const unsigned int *value_list)
EAPI Ecore_X_GC
ecore_x_gc_new(Ecore_X_Drawable drawable, Ecore_X_GC_Value_Mask value_mask, const unsigned int *value_list)
{
xcb_gcontext_t gc;
uint32_t vmask = 0;
int i = 0, mask = 0;
if (!drawable)
drawable = ((xcb_screen_t *)_ecore_xcb_screen)->root;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!drawable) drawable = ((xcb_screen_t *)_ecore_xcb_screen)->root;
for (i = 0, mask = 1; i <= 22; i++, mask <<= 1)
{
switch (mask & value_mask)
{
case ECORE_X_GC_VALUE_MASK_FUNCTION:
vmask |= XCB_GC_FUNCTION;
break;
case ECORE_X_GC_VALUE_MASK_PLANE_MASK:
vmask |= XCB_GC_PLANE_MASK;
break;
case ECORE_X_GC_VALUE_MASK_FOREGROUND:
vmask |= XCB_GC_FOREGROUND;
break;
case ECORE_X_GC_VALUE_MASK_BACKGROUND:
vmask |= XCB_GC_BACKGROUND;
break;
case ECORE_X_GC_VALUE_MASK_LINE_WIDTH:
vmask |= XCB_GC_LINE_WIDTH;
break;
case ECORE_X_GC_VALUE_MASK_LINE_STYLE:
vmask |= XCB_GC_LINE_STYLE;
break;
case ECORE_X_GC_VALUE_MASK_CAP_STYLE:
vmask |= XCB_GC_CAP_STYLE;
break;
case ECORE_X_GC_VALUE_MASK_JOIN_STYLE:
vmask |= XCB_GC_JOIN_STYLE;
break;
case ECORE_X_GC_VALUE_MASK_FILL_STYLE:
vmask |= XCB_GC_FILL_STYLE;
break;
case ECORE_X_GC_VALUE_MASK_FILL_RULE:
vmask |= XCB_GC_FILL_RULE;
break;
case ECORE_X_GC_VALUE_MASK_TILE:
vmask |= XCB_GC_TILE;
break;
case ECORE_X_GC_VALUE_MASK_STIPPLE:
vmask |= XCB_GC_STIPPLE;
break;
case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_X:
vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_X;
break;
case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_Y:
vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_Y;
break;
case ECORE_X_GC_VALUE_MASK_FONT:
vmask |= XCB_GC_FONT;
break;
case ECORE_X_GC_VALUE_MASK_SUBWINDOW_MODE:
vmask |= XCB_GC_SUBWINDOW_MODE;
break;
case ECORE_X_GC_VALUE_MASK_GRAPHICS_EXPOSURES:
vmask |= XCB_GC_GRAPHICS_EXPOSURES;
break;
case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_X:
vmask |= XCB_GC_CLIP_ORIGIN_X;
break;
case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_Y:
vmask |= XCB_GC_CLIP_ORIGIN_Y;
break;
case ECORE_X_GC_VALUE_MASK_CLIP_MASK:
vmask |= XCB_GC_CLIP_MASK;
break;
case ECORE_X_GC_VALUE_MASK_DASH_OFFSET:
vmask |= XCB_GC_DASH_OFFSET;
break;
case ECORE_X_GC_VALUE_MASK_DASH_LIST:
vmask |= XCB_GC_DASH_LIST;
break;
case ECORE_X_GC_VALUE_MASK_ARC_MODE:
vmask |= XCB_GC_ARC_MODE;
break;
}
}
gc = xcb_generate_id(_ecore_xcb_conn);
xcb_create_gc(_ecore_xcb_conn, gc, drawable, value_mask, value_list);
xcb_create_gc(_ecore_xcb_conn, gc, drawable, vmask, value_list);
return gc;
} /* ecore_x_gc_new */
}
/**
* Deletes and frees the given graphics context.
* @param gc The given graphics context.
*
* Destroyes the graphic context @p gc as well as the associated
* storage.
*/
EAPI void
ecore_x_gc_free(Ecore_X_GC gc)
EAPI void
ecore_x_gc_free(Ecore_X_GC gc)
{
xcb_free_gc(_ecore_xcb_conn, gc);
} /* ecore_x_gc_free */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_free_gc(_ecore_xcb_conn, gc);
}
EAPI void
ecore_x_gc_foreground_set(Ecore_X_GC gc, unsigned long foreground)
{
uint32_t list;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
list = foreground;
xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list);
}
EAPI void
ecore_x_gc_background_set(Ecore_X_GC gc, unsigned long background)
{
uint32_t list;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
list = background;
xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_BACKGROUND, &list);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,670 @@
#include "ecore_xcb_private.h"
#include <sys/ipc.h>
#include <sys/shm.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_event.h>
struct _Ecore_X_Image
{
xcb_shm_segment_info_t shminfo;
xcb_image_t *xim;
Ecore_X_Visual vis;
int depth, w, h;
int bpl, bpp, rows;
unsigned char *data;
Eina_Bool shm : 1;
};
/* local function prototypes */
static void _ecore_xcb_image_shm_check(void);
static void _ecore_xcb_image_shm_create(Ecore_X_Image *im);
static xcb_image_t *_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data);
static xcb_format_t *_ecore_xcb_image_find_format(const xcb_setup_t *setup, uint8_t depth);
/* local variables */
static int _ecore_xcb_image_shm_can = -1;
EAPI Ecore_X_Image *
ecore_x_image_new(int w, int h, Ecore_X_Visual vis, int depth)
{
Ecore_X_Image *im;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!(im = calloc(1, sizeof(Ecore_X_Image)))) return NULL;
im->w = w;
im->h = h;
im->vis = vis;
im->depth = depth;
_ecore_xcb_image_shm_check();
im->shm = _ecore_xcb_image_shm_can;
return im;
}
EAPI void
ecore_x_image_free(Ecore_X_Image *im)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!im) return;
if (im->shm)
{
if (im->xim)
{
xcb_shm_detach(_ecore_xcb_conn, im->shminfo.shmseg);
xcb_image_destroy(im->xim);
shmdt(im->shminfo.shmaddr);
shmctl(im->shminfo.shmid, IPC_RMID, 0);
}
}
else if (im->xim)
{
if (im->xim->data) free(im->xim->data);
im->xim->data = NULL;
xcb_image_destroy(im->xim);
}
free(im);
}
EAPI Eina_Bool
ecore_x_image_get(Ecore_X_Image *im, Ecore_X_Drawable draw, int x, int y, int sx, int sy, int w, int h)
{
Eina_Bool ret = EINA_TRUE;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (im->shm)
{
if (!im->xim) _ecore_xcb_image_shm_create(im);
if (!im->xim) return EINA_FALSE;
if ((sx == 0) && (w == im->w))
{
im->xim->data = (uint8_t *)im->data + (im->xim->stride * sy) +
(sx * im->bpp);
im->xim->width = w;
im->xim->height = h;
ecore_x_grab();
if (!xcb_image_shm_get(_ecore_xcb_conn, draw, im->xim,
im->shminfo, x, y, 0xffffffff))
{
DBG("\tImage Shm Get Failed");
ret = EINA_FALSE;
}
ecore_x_ungrab();
ecore_x_sync(); // needed
}
else
{
Ecore_X_Image *tim;
tim = ecore_x_image_new(w, h, im->vis, im->depth);
if (tim)
{
ret = ecore_x_image_get(tim, draw, x, y, 0, 0, w, h);
if (ret)
{
unsigned char *spixels, *pixels;
int sbpp = 0, sbpl = 0, srows = 0;
int bpp = 0, bpl = 0, rows = 0;
spixels =
ecore_x_image_data_get(tim, &sbpl, &srows, &sbpp);
pixels = ecore_x_image_data_get(im, &bpl, &rows, &bpp);
if ((spixels) && (pixels))
{
unsigned char *p, *sp;
int r = 0;
p = (pixels + (sy * bpl) + (sx * bpp));
sp = spixels;
for (r = srows; r > 0; r--)
{
memcpy(p, sp, sbpl);
p += bpl;
sp += sbpl;
}
}
}
ecore_x_image_free(tim);
}
}
}
else
{
ret = EINA_FALSE;
ecore_x_grab();
im->xim =
xcb_image_get(_ecore_xcb_conn, draw, x, y, w, h,
0xffffffff, XCB_IMAGE_FORMAT_Z_PIXMAP);
if (!im->xim) ret = EINA_FALSE;
ecore_x_ungrab();
if (im->xim)
{
im->data = (unsigned char *)im->xim->data;
im->bpl = im->xim->stride;
im->rows = im->xim->height;
if (im->xim->bpp <= 8)
im->bpp = 1;
else if (im->xim->bpp <= 16)
im->bpp = 2;
else
im->bpp = 4;
}
}
return ret;
}
EAPI void *
ecore_x_image_data_get(Ecore_X_Image *im, int *bpl, int *rows, int *bpp)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!im) return NULL;
if (!im->xim) _ecore_xcb_image_shm_create(im);
if (!im->xim) return NULL;
if (bpl) *bpl = im->bpl;
if (rows) *rows = im->rows;
if (bpp) *bpp = im->bpp;
return im->data;
}
EAPI void
ecore_x_image_put(Ecore_X_Image *im, Ecore_X_Drawable draw, Ecore_X_GC gc, int x, int y, int sx, int sy, int w, int h)
{
Ecore_X_GC tgc = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!gc)
{
uint32_t mask, values[1];
tgc = xcb_generate_id(_ecore_xcb_conn);
mask = XCB_GC_SUBWINDOW_MODE;
values[0] = XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS;
xcb_create_gc(_ecore_xcb_conn, tgc, draw, mask, values);
gc = tgc;
}
if (!im->xim) _ecore_xcb_image_shm_create(im);
if (im->xim)
{
if (im->shm)
xcb_image_shm_put(_ecore_xcb_conn, draw, gc, im->xim,
im->shminfo, sx, sy, x, y, w, h, 0);
else
xcb_image_put(_ecore_xcb_conn, draw, gc, im->xim, sx, sy, 0);
}
if (tgc) ecore_x_gc_free(tgc);
}
EAPI Eina_Bool
ecore_x_image_is_argb32_get(Ecore_X_Image *im)
{
xcb_visualtype_t *vis;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
vis = (xcb_visualtype_t *)im->vis;
if (!im->xim) _ecore_xcb_image_shm_create(im);
if (((vis->_class == XCB_VISUAL_CLASS_TRUE_COLOR) ||
(vis->_class == XCB_VISUAL_CLASS_DIRECT_COLOR)) &&
(im->depth >= 24) && (vis->red_mask == 0xff0000) &&
(vis->green_mask == 0x00ff00) && (vis->blue_mask == 0x0000ff))
{
#ifdef WORDS_BIGENDIAN
if (im->xim->byte_order == XCB_IMAGE_ORDER_LSB_FIRST)
return EINA_TRUE;
#else
if (im->xim->byte_order == XCB_IMAGE_ORDER_MSB_FIRST)
return EINA_TRUE;
#endif
}
return EINA_FALSE;
}
EAPI Eina_Bool
ecore_x_image_to_argb_convert(void *src, int sbpp, int sbpl, Ecore_X_Colormap c, Ecore_X_Visual v, int x, int y, int w, int h, unsigned int *dst, int dbpl, int dx, int dy)
{
xcb_visualtype_t *vis;
uint32_t *cols;
int n = 0, nret = 0, i, row, mode = 0;
unsigned int pal[256], r, g, b;
enum
{
rgbnone = 0,
rgb565,
bgr565,
rgbx555,
argbx888,
abgrx888,
rgba888x,
bgra888x,
argbx666
};
LOGFN(__FILE__, __LINE__, __FUNCTION__);
sbpp *= 8;
vis = (xcb_visualtype_t *)v;
n = vis->colormap_entries;
if ((n <= 256) &&
((vis->_class == XCB_VISUAL_CLASS_PSEUDO_COLOR) ||
(vis->_class == XCB_VISUAL_CLASS_STATIC_COLOR) ||
(vis->_class == XCB_VISUAL_CLASS_GRAY_SCALE) ||
(vis->_class == XCB_VISUAL_CLASS_STATIC_GRAY)))
{
xcb_query_colors_cookie_t cookie;
xcb_query_colors_reply_t *reply;
if (!c)
{
c = (xcb_colormap_t)((xcb_screen_t *)
_ecore_xcb_screen)->default_colormap;
}
cols = alloca(n * sizeof(uint32_t));
for (i = 0; i < n; i++)
cols[i] = i;
cookie = xcb_query_colors_unchecked(_ecore_xcb_conn, c, n, cols);
reply = xcb_query_colors_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
xcb_rgb_iterator_t iter;
xcb_rgb_t *ret;
iter = xcb_query_colors_colors_iterator(reply);
ret = xcb_query_colors_colors(reply);
if (ret)
{
for (i = 0; iter.rem; xcb_rgb_next(&iter), i++)
{
pal[i] = 0xff000000 |
((iter.data->red >> 8) << 16) |
((iter.data->green >> 8) << 8) |
((iter.data->blue >> 8));
}
nret = n;
}
free(reply);
}
}
else if ((vis->_class == XCB_VISUAL_CLASS_TRUE_COLOR) ||
(vis->_class == XCB_VISUAL_CLASS_DIRECT_COLOR))
{
if ((vis->red_mask == 0x00ff0000) &&
(vis->green_mask == 0x0000ff00) &&
(vis->blue_mask == 0x000000ff))
mode = argbx888;
else if ((vis->red_mask == 0x000000ff) &&
(vis->green_mask == 0x0000ff00) &&
(vis->blue_mask == 0x00ff0000))
mode = abgrx888;
else if ((vis->red_mask == 0xff000000) &&
(vis->green_mask == 0x00ff0000) &&
(vis->blue_mask == 0x0000ff00))
mode = rgba888x;
else if ((vis->red_mask == 0x0000ff00) &&
(vis->green_mask == 0x00ff0000) &&
(vis->blue_mask == 0xff000000))
mode = bgra888x;
else if ((vis->red_mask == 0x0003f000) &&
(vis->green_mask == 0x00000fc0) &&
(vis->blue_mask == 0x0000003f))
mode = argbx666;
else if ((vis->red_mask == 0x0000f800) &&
(vis->green_mask == 0x000007e0) &&
(vis->blue_mask == 0x0000001f))
mode = rgb565;
else if ((vis->red_mask == 0x0000001f) &&
(vis->green_mask == 0x000007e0) &&
(vis->blue_mask == 0x0000f800))
mode = bgr565;
else if ((vis->red_mask == 0x00007c00) &&
(vis->green_mask == 0x000003e0) &&
(vis->blue_mask == 0x0000001f))
mode = rgbx555;
else
return EINA_FALSE;
}
for (row = 0; row < h; row++)
{
unsigned char *s8;
unsigned short *s16;
unsigned int *s32, *dp, *de;
dp = ((unsigned int *)(((unsigned char *)dst) +
((dy + row) * dbpl))) + dx;
de = dp + w;
switch (sbpp)
{
case 8:
s8 = ((unsigned char *)(((unsigned char *)src) +
((y + row) * sbpl))) + x;
if (nret > 0)
{
while (dp < de)
{
*dp = pal[*s8];
s8++; dp++;
}
}
else
return EINA_FALSE;
break;
case 16:
s16 = ((unsigned short *)(((unsigned char *)src) +
((y + row) * sbpl))) + x;
switch (mode)
{
case rgb565:
while (dp < de)
{
r = (*s16 & 0xf800) << 8;
g = (*s16 & 0x07e0) << 5;
b = (*s16 & 0x001f) << 3;
r |= (r >> 5) & 0xff0000;
g |= (g >> 6) & 0x00ff00;
b |= (b >> 5);
*dp = 0xff000000 | r | g | b;
s16++; dp++;
}
break;
case bgr565:
while (dp < de)
{
r = (*s16 & 0x001f) << 19;
g = (*s16 & 0x07e0) << 5;
b = (*s16 & 0xf800) >> 8;
r |= (r >> 5) & 0xff0000;
g |= (g >> 6) & 0x00ff00;
b |= (b >> 5);
*dp = 0xff000000 | r | g | b;
s16++; dp++;
}
break;
case rgbx555:
while (dp < de)
{
r = (*s16 & 0x7c00) << 9;
g = (*s16 & 0x03e0) << 6;
b = (*s16 & 0x001f) << 3;
r |= (r >> 5) & 0xff0000;
g |= (g >> 5) & 0x00ff00;
b |= (b >> 5);
*dp = 0xff000000 | r | g | b;
s16++; dp++;
}
break;
default:
return EINA_FALSE;
break;
}
break;
case 24:
case 32:
s32 = ((unsigned int *)(((unsigned char *)src) +
((y + row) * sbpl))) + x;
switch (mode)
{
case argbx888:
while (dp < de)
{
*dp = 0xff000000 | *s32;
s32++; dp++;
}
break;
case abgrx888:
while (dp < de)
{
r = *s32 & 0x000000ff;
g = *s32 & 0x0000ff00;
b = *s32 & 0x00ff0000;
*dp = 0xff000000 | (r << 16) | (g) | (b >> 16);
s32++; dp++;
}
break;
case rgba888x:
while (dp < de)
{
*dp = 0xff000000 | (*s32 >> 8);
s32++; dp++;
}
break;
case bgra888x:
while (dp < de)
{
r = *s32 & 0x0000ff00;
g = *s32 & 0x00ff0000;
b = *s32 & 0xff000000;
*dp = 0xff000000 | (r << 8) | (g >> 8) | (b >> 24);
s32++; dp++;
}
break;
case argbx666:
while (dp < de)
{
r = (*s32 & 0x3f000) << 6;
g = (*s32 & 0x00fc0) << 4;
b = (*s32 & 0x0003f) << 2;
r |= (r >> 6) & 0xff0000;
g |= (g >> 6) & 0x00ff00;
b |= (b >> 6);
*dp = 0xff000000 | r | g | b;
s32++; dp++;
}
break;
default:
return EINA_FALSE;
break;
}
break;
break;
default:
return EINA_FALSE;
break;
}
}
return EINA_TRUE;
}
/* local functions */
static void
_ecore_xcb_image_shm_check(void)
{
xcb_shm_query_version_reply_t *reply;
xcb_shm_segment_info_t shminfo;
xcb_shm_get_image_cookie_t cookie;
xcb_shm_get_image_reply_t *ireply;
xcb_image_t *img = 0;
uint8_t depth = 0;
if (_ecore_xcb_image_shm_can != -1) return;
reply =
xcb_shm_query_version_reply(_ecore_xcb_conn,
xcb_shm_query_version(_ecore_xcb_conn), NULL);
if (!reply)
{
_ecore_xcb_image_shm_can = 0;
return;
}
if ((reply->major_version < 1) ||
((reply->major_version == 1) && (reply->minor_version == 0)))
{
_ecore_xcb_image_shm_can = 0;
free(reply);
return;
}
free(reply);
depth = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth;
ecore_x_sync(); // needed
img = _ecore_xcb_image_create_native(1, 1, XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (!img)
{
_ecore_xcb_image_shm_can = 0;
return;
}
shminfo.shmid =
shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0666));
if (shminfo.shmid == (uint32_t)-1)
{
xcb_image_destroy(img);
_ecore_xcb_image_shm_can = 0;
return;
}
shminfo.shmaddr = shmat(shminfo.shmid, 0, 0);
img->data = shminfo.shmaddr;
if (img->data == (uint8_t *)-1)
{
xcb_image_destroy(img);
_ecore_xcb_image_shm_can = 0;
return;
}
shminfo.shmseg = xcb_generate_id(_ecore_xcb_conn);
xcb_shm_attach(_ecore_xcb_conn, shminfo.shmseg, shminfo.shmid, 0);
cookie =
xcb_shm_get_image(_ecore_xcb_conn,
((xcb_screen_t *)_ecore_xcb_screen)->root,
0, 0, img->width, img->height,
0xffffffff, img->format,
shminfo.shmseg, img->data - shminfo.shmaddr);
ecore_x_sync(); // needed
ireply = xcb_shm_get_image_reply(_ecore_xcb_conn, cookie, NULL);
if (ireply)
{
_ecore_xcb_image_shm_can = 1;
free(ireply);
}
else
_ecore_xcb_image_shm_can = 0;
xcb_shm_detach(_ecore_xcb_conn, shminfo.shmseg);
xcb_image_destroy(img);
shmdt(shminfo.shmaddr);
shmctl(shminfo.shmid, IPC_RMID, 0);
}
static void
_ecore_xcb_image_shm_create(Ecore_X_Image *im)
{
im->xim =
_ecore_xcb_image_create_native(im->w, im->h, XCB_IMAGE_FORMAT_Z_PIXMAP,
im->depth, NULL, ~0, NULL);
if (!im->xim) return;
im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666));
// shmget(IPC_PRIVATE, im->xim->stride * im->xim->height, (IPC_CREAT | 0666));
if (im->shminfo.shmid == (uint32_t)-1)
{
xcb_image_destroy(im->xim);
return;
}
im->shminfo.shmaddr = shmat(im->shminfo.shmid, 0, 0);
im->xim->data = im->shminfo.shmaddr;
if ((!im->xim->data) || (im->xim->data == (uint8_t *)-1))
{
DBG("Shm Create No Image Data");
xcb_image_destroy(im->xim);
shmdt(im->shminfo.shmaddr);
shmctl(im->shminfo.shmid, IPC_RMID, 0);
return;
}
im->shminfo.shmseg = xcb_generate_id(_ecore_xcb_conn);
xcb_shm_attach(_ecore_xcb_conn, im->shminfo.shmseg, im->shminfo.shmid, 0);
im->data = (unsigned char *)im->xim->data;
im->bpl = im->xim->stride;
im->rows = im->xim->height;
if (im->xim->bpp <= 8)
im->bpp = 1;
else if (im->xim->bpp <= 16)
im->bpp = 2;
else
im->bpp = 4;
}
static xcb_image_t *
_ecore_xcb_image_create_native(int w, int h, xcb_image_format_t format, uint8_t depth, void *base, uint32_t bytes, uint8_t *data)
{
const xcb_setup_t *setup;
xcb_format_t *fmt = NULL;
xcb_image_format_t xif;
/* NB: We cannot use xcb_image_create_native as it only creates images
* using MSB_FIRST, so this routine recreates that function and checks
* endian-ness correctly */
setup = xcb_get_setup(_ecore_xcb_conn);
xif = format;
if ((xif == XCB_IMAGE_FORMAT_Z_PIXMAP) && (depth == 1))
xif = XCB_IMAGE_FORMAT_XY_PIXMAP;
fmt = _ecore_xcb_image_find_format(setup, depth);
if (!fmt) return 0;
switch (xif)
{
case XCB_IMAGE_FORMAT_XY_BITMAP:
if (depth != 1) return 0;
case XCB_IMAGE_FORMAT_XY_PIXMAP:
return xcb_image_create(w, h, xif,
fmt->scanline_pad,
fmt->depth, fmt->bits_per_pixel,
setup->bitmap_format_scanline_unit,
setup->image_byte_order,
setup->bitmap_format_bit_order,
base, bytes, data);
case XCB_IMAGE_FORMAT_Z_PIXMAP:
return xcb_image_create(w, h, xif,
fmt->scanline_pad,
fmt->depth, fmt->bits_per_pixel,
setup->bitmap_format_scanline_unit,
setup->image_byte_order,
setup->bitmap_format_bit_order,
base, bytes, data);
default:
break;
}
return 0;
}
static xcb_format_t *
_ecore_xcb_image_find_format(const xcb_setup_t *setup, uint8_t depth)
{
xcb_format_t *fmt, *fmtend;
fmt = xcb_setup_pixmap_formats(setup);
fmtend = fmt + xcb_setup_pixmap_formats_length(setup);
for (; fmt != fmtend; ++fmt)
if (fmt->depth == depth)
return fmt;
return 0;
}

View File

@ -0,0 +1,188 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_XINPUT
# include <xcb/xinput.h>
# include <xcb/xcb_event.h>
#endif
/* local variables */
static Eina_Bool _input_avail = EINA_FALSE;
/* external variables */
int _ecore_xcb_event_input = 0;
void
_ecore_xcb_input_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XINPUT
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_input_id);
#endif
}
void
_ecore_xcb_input_finalize(void)
{
#ifdef ECORE_XCB_XINPUT
xcb_input_get_extension_version_cookie_t cookie;
xcb_input_get_extension_version_reply_t *reply;
char buff[128];
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XINPUT
cookie =
xcb_input_get_extension_version_unchecked(_ecore_xcb_conn, 127, buff);
reply =
xcb_input_get_extension_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
_input_avail = EINA_TRUE;
free(reply);
}
if (_input_avail)
{
const xcb_query_extension_reply_t *ext_reply;
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_input_id);
if (ext_reply)
_ecore_xcb_event_input = ext_reply->first_event;
}
#endif
}
void
_ecore_xcb_input_shutdown(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
}
void
#ifdef ECORE_XCB_XINPUT
_ecore_xcb_input_handle_event(xcb_generic_event_t *event)
#else
_ecore_xcb_input_handle_event(xcb_generic_event_t *event __UNUSED__)
#endif
{
#ifdef ECORE_XCB_XINPUT
xcb_ge_event_t *ev;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XINPUT
ev = (xcb_ge_event_t *)event;
switch (ev->event_type)
{
case XCB_INPUT_DEVICE_MOTION_NOTIFY:
{
xcb_input_device_motion_notify_event_t *de;
unsigned int child_win = 0;
de = (xcb_input_device_motion_notify_event_t *)ev->pad1;
child_win = (de->child ? de->child : de->event);
_ecore_xcb_event_mouse_move(de->time, de->state, de->event_x,
de->event_y, de->root_x, de->root_y,
de->event, child_win, de->root,
de->same_screen, de->device_id,
1, 1, 1.0, 0.0,
de->event_x, de->event_y,
de->root_x, de->root_y);
}
break;
case XCB_INPUT_DEVICE_BUTTON_PRESS:
{
xcb_input_device_button_press_event_t *de;
unsigned int child_win = 0;
de = (xcb_input_device_button_press_event_t *)ev->pad1;
child_win = (de->child ? de->child : de->event);
_ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN,
de->time, de->state, de->detail,
de->event_x, de->event_y,
de->root_x, de->root_y, de->event,
child_win, de->root,
de->same_screen, de->device_id,
1, 1, 1.0, 0.0,
de->event_x, de->event_y,
de->root_x, de->root_y);
}
break;
case XCB_INPUT_DEVICE_BUTTON_RELEASE:
{
xcb_input_device_button_release_event_t *de;
unsigned int child_win = 0;
de = (xcb_input_device_button_release_event_t *)ev->pad1;
child_win = (de->child ? de->child : de->event);
_ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP,
de->time, de->state, de->detail,
de->event_x, de->event_y,
de->root_x, de->root_y, de->event,
child_win, de->root,
de->same_screen, de->device_id,
1, 1, 1.0, 0.0,
de->event_x, de->event_y,
de->root_x, de->root_y);
}
break;
default:
break;
}
#endif
}
EAPI Eina_Bool
ecore_x_input_multi_select(Ecore_X_Window win)
{
Eina_Bool find = EINA_FALSE;
#ifdef ECORE_XCB_XINPUT
xcb_input_list_input_devices_cookie_t dcookie;
xcb_input_list_input_devices_reply_t *dreply;
xcb_input_device_info_iterator_t diter;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_input_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XINPUT
dcookie = xcb_input_list_input_devices_unchecked(_ecore_xcb_conn);
dreply =
xcb_input_list_input_devices_reply(_ecore_xcb_conn, dcookie, NULL);
if (!dreply) return EINA_FALSE;
diter = xcb_input_list_input_devices_devices_iterator(dreply);
while (diter.rem)
{
xcb_input_device_info_t *dev;
const xcb_input_event_class_t iclass =
{
XCB_INPUT_DEVICE_BUTTON_PRESS |
XCB_INPUT_DEVICE_BUTTON_RELEASE |
XCB_INPUT_DEVICE_MOTION_NOTIFY
};
dev = diter.data;
if (dev->device_use == XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_DEVICE)
{
DBG("Device %d", dev->device_id);
DBG("\tType: %d", dev->device_type);
DBG("\tNum Classes: %d", dev->num_class_info);
DBG("\tUse: %d", dev->device_use);
/* FIXME: This may not be correct !!
* I have no extra Input Devices to test with */
xcb_input_select_extension_event(_ecore_xcb_conn, win, 1, &iclass);
find = EINA_TRUE;
}
xcb_input_device_info_next(&diter);
}
free(dreply);
#endif
return find;
win = 0;
}

View File

@ -0,0 +1,447 @@
#include "ecore_xcb_private.h"
#define NEED_KEYSYM_TABLE
#define NEED_VTABLE
#include "ecore_xcb_keysym_table.h"
#include <xcb/xcb_keysyms.h>
#include <X11/keysym.h>
/* local function prototypes */
static int _ecore_xcb_keymap_mask_get(void *reply, xcb_keysym_t sym);
static xcb_keysym_t _ecore_xcb_keymap_string_to_keysym(const char *str);
static int _ecore_xcb_keymap_translate_key(xcb_keycode_t keycode, unsigned int modifiers, unsigned int *modifiers_return, xcb_keysym_t *keysym_return);
static int _ecore_xcb_keymap_translate_keysym(xcb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes);
/* local variables */
static xcb_key_symbols_t *_ecore_xcb_keysyms;
static int _ecore_xcb_mode_switch = 0;
/* public variables */
EAPI int ECORE_X_MODIFIER_SHIFT = 0;
EAPI int ECORE_X_MODIFIER_CTRL = 0;
EAPI int ECORE_X_MODIFIER_ALT = 0;
EAPI int ECORE_X_MODIFIER_WIN = 0;
EAPI int ECORE_X_LOCK_SCROLL = 0;
EAPI int ECORE_X_LOCK_NUM = 0;
EAPI int ECORE_X_LOCK_CAPS = 0;
EAPI int ECORE_X_LOCK_SHIFT = 0;
void
_ecore_xcb_keymap_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
_ecore_xcb_keysyms = xcb_key_symbols_alloc(_ecore_xcb_conn);
}
void
_ecore_xcb_keymap_finalize(void)
{
xcb_get_modifier_mapping_cookie_t cookie;
xcb_get_modifier_mapping_reply_t *reply;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie = xcb_get_modifier_mapping_unchecked(_ecore_xcb_conn);
reply = xcb_get_modifier_mapping_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply)
{
xcb_key_symbols_free(_ecore_xcb_keysyms);
return;
}
_ecore_xcb_mode_switch = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch);
ECORE_X_MODIFIER_SHIFT = _ecore_xcb_keymap_mask_get(reply, XK_Shift_L);
ECORE_X_MODIFIER_CTRL = _ecore_xcb_keymap_mask_get(reply, XK_Control_L);
ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Alt_L);
if (!ECORE_X_MODIFIER_ALT)
ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Meta_L);
if (!ECORE_X_MODIFIER_ALT)
ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Super_L);
ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Super_L);
if (!ECORE_X_MODIFIER_WIN)
ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch);
if (!ECORE_X_MODIFIER_WIN)
ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Meta_L);
if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT)
ECORE_X_MODIFIER_WIN = 0;
if (ECORE_X_MODIFIER_ALT == ECORE_X_MODIFIER_CTRL)
ECORE_X_MODIFIER_ALT = 0;
ECORE_X_LOCK_SCROLL = _ecore_xcb_keymap_mask_get(reply, XK_Scroll_Lock);
ECORE_X_LOCK_NUM = _ecore_xcb_keymap_mask_get(reply, XK_Num_Lock);
ECORE_X_LOCK_CAPS = _ecore_xcb_keymap_mask_get(reply, XK_Caps_Lock);
ECORE_X_LOCK_SHIFT = _ecore_xcb_keymap_mask_get(reply, XK_Shift_Lock);
}
void
_ecore_xcb_keymap_shutdown(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (_ecore_xcb_keysyms) xcb_key_symbols_free(_ecore_xcb_keysyms);
}
void
_ecore_xcb_keymap_refresh(xcb_mapping_notify_event_t *event)
{
xcb_refresh_keyboard_mapping(_ecore_xcb_keysyms, event);
}
xcb_keysym_t
_ecore_xcb_keymap_keycode_to_keysym(xcb_keycode_t keycode, int col)
{
xcb_keysym_t key0, key1;
if (col & _ecore_xcb_mode_switch)
{
key0 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 4);
key1 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 5);
}
else
{
key0 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 0);
key1 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 1);
}
if (key1 == XCB_NO_SYMBOL)
key1 = key0;
if ((col & ECORE_X_LOCK_NUM) &&
((xcb_is_keypad_key(key1)) || (xcb_is_private_keypad_key(key1))))
{
if ((col & XCB_MOD_MASK_SHIFT) ||
((col & XCB_MOD_MASK_LOCK) && (col & ECORE_X_LOCK_SHIFT)))
return key0;
else
return key1;
}
else if (!(col & XCB_MOD_MASK_SHIFT) && !(col & XCB_MOD_MASK_LOCK))
return key0;
else if (!(col & XCB_MOD_MASK_SHIFT) &&
(col & XCB_MOD_MASK_LOCK && (col & ECORE_X_LOCK_CAPS)))
return key1;
else if ((col & XCB_MOD_MASK_SHIFT) &&
(col & XCB_MOD_MASK_LOCK) && (col & ECORE_X_LOCK_CAPS))
return key0;
else if ((col & XCB_MOD_MASK_SHIFT) ||
(col & XCB_MOD_MASK_LOCK && (col & ECORE_X_LOCK_SHIFT)))
return key1;
return XCB_NO_SYMBOL;
}
xcb_keycode_t *
_ecore_xcb_keymap_keysym_to_keycode(xcb_keysym_t keysym)
{
return xcb_key_symbols_get_keycode(_ecore_xcb_keysyms, keysym);
}
char *
_ecore_xcb_keymap_keysym_to_string(xcb_keysym_t keysym)
{
int i = 0, n = 0, h = 0, idx = 0;
const unsigned char *entry;
unsigned char val1, val2, val3, val4;
if (!keysym) return NULL;
if (keysym == XK_VoidSymbol) keysym = 0;
if (keysym <= 0x1fffffff)
{
val1 = (keysym >> 24);
val2 = ((keysym >> 16) & 0xff);
val3 = ((keysym >> 8) & 0xff);
val4 = (keysym & 0xff);
i = keysym % VTABLESIZE;
h = i + 1;
n = VMAXHASH;
while ((idx = hashKeysym[i]))
{
entry = &_ecore_xcb_keytable[idx];
if ((entry[0] == val1) && (entry[1] == val2) &&
(entry[2] == val3) && (entry[3] == val4))
return ((char *)entry + 4);
if (!--n) break;
i += h;
if (i >= VTABLESIZE) i -= VTABLESIZE;
}
}
if ((keysym >= 0x01000100) && (keysym <= 0x0110ffff))
{
xcb_keysym_t val;
char *s = NULL;
int i = 0;
val = (keysym & 0xffffff);
if (val & 0xff0000)
i = 10;
else
i = 6;
if (!(s = malloc(i))) return NULL;
i--;
s[i--] = '\0';
for (; i; i--)
{
val1 = (val & 0xf);
val >>= 4;
if (val1 < 10)
s[i] = '0' + val1;
else
s[i] = 'A' + val1 - 10;
}
s[i] = 'U';
return s;
}
return NULL;
}
xcb_keycode_t
_ecore_xcb_keymap_string_to_keycode(const char *key)
{
if (!strncmp(key, "Keycode-", 8))
return atoi(key + 8);
else
{
xcb_keysym_t keysym = XCB_NO_SYMBOL;
xcb_keycode_t *keycodes, keycode = 0;
int i = 0;
keysym = _ecore_xcb_keymap_string_to_keysym(key);
if (keysym == XCB_NO_SYMBOL) return XCB_NO_SYMBOL;
keycodes = _ecore_xcb_keymap_keysym_to_keycode(keysym);
if (!keycodes) return XCB_NO_SYMBOL;
while (keycodes[i] != XCB_NO_SYMBOL)
{
if (keycodes[i] != 0)
{
keycode = keycodes[i];
break;
}
i++;
}
return keycode;
}
}
int
_ecore_xcb_keymap_lookup_string(xcb_keycode_t keycode, int state, char *buffer, int bytes, xcb_keysym_t *sym)
{
unsigned int modifiers = 0;
xcb_keysym_t keysym;
if (!_ecore_xcb_keymap_translate_key(keycode, state, &modifiers, &keysym))
return 0;
if (sym) *sym = keysym;
return _ecore_xcb_keymap_translate_keysym(keysym, state, buffer, bytes);
}
EAPI const char *
ecore_x_keysym_string_get(int keysym)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_keymap_keysym_to_string(keysym);
}
/* local functions */
static int
_ecore_xcb_keymap_mask_get(void *reply, xcb_keysym_t sym)
{
xcb_get_modifier_mapping_reply_t *rep;
xcb_keysym_t sym2;
int mask = 0;
const int masks[8] =
{
XCB_MOD_MASK_SHIFT, XCB_MOD_MASK_LOCK, XCB_MOD_MASK_CONTROL,
XCB_MOD_MASK_1, XCB_MOD_MASK_2, XCB_MOD_MASK_3, XCB_MOD_MASK_4,
XCB_MOD_MASK_5
};
LOGFN(__FILE__, __LINE__, __FUNCTION__);
rep = (xcb_get_modifier_mapping_reply_t *)reply;
if ((rep) && (rep->keycodes_per_modifier > 0))
{
int i = 0;
xcb_keycode_t *modmap;
modmap = xcb_get_modifier_mapping_keycodes(rep);
for (i = 0; i < (8 * rep->keycodes_per_modifier); i++)
{
int j = 0;
for (j = 0; j < 8; j++)
{
sym2 =
xcb_key_symbols_get_keysym(_ecore_xcb_keysyms,
modmap[i], j);
if (sym2 != 0) break;
}
if (sym2 == sym)
{
mask = masks[i / rep->keycodes_per_modifier];
break;
}
}
}
return mask;
}
static xcb_keysym_t
_ecore_xcb_keymap_string_to_keysym(const char *str)
{
int i = 0, n = 0, h = 0;
unsigned long sig = 0;
const char *p = NULL;
int c = 0, idx = 0;
const unsigned char *entry;
unsigned char sig1, sig2;
long unsigned int val;
p = str;
while ((c = *p++))
sig = (sig << 1) + c;
i = (sig % KTABLESIZE);
h = i + 1;
sig1 = (sig >> 8) & 0xff;
sig2 = sig & 0xff;
n = KMAXHASH;
while ((idx = hashString[i]))
{
entry = &_ecore_xcb_keytable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) &&
!strcmp(str, (char *)entry + 6))
{
val = ((entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | (entry[5]));
if (!val) val = 0xffffff;
return val;
}
if (!--n) break;
i += h;
if (i >= KTABLESIZE) i-= KTABLESIZE;
}
if (*str == 'U')
{
val = 0;
for (p = &str[1]; *p; p++)
{
c = *p;
if (('0' <= c) && (c <= '9'))
val = (val << 4) + c - '0';
else if (('a' <= c) && (c <= 'f'))
val = (val << 4) + c - 'a' + 10;
else if (('A' <= c) && (c <= 'F'))
val = (val << 4) + c - 'A' + 10;
else
return XCB_NO_SYMBOL;
if (val > 0x10ffff) return XCB_NO_SYMBOL;
}
if ((val < 0x20) || ((val > 0x7e) && (val < 0xa0)))
return XCB_NO_SYMBOL;
if (val < 0x100) return val;
return (val | 0x01000000);
}
if ((strlen(str) > 2) && (str[0] == '0') && (str[1] == 'x'))
{
char *tmp = NULL;
val = strtoul(str, &tmp, 16);
if ((val == ULONG_MAX) || ((tmp) && (*tmp != '\0')))
return XCB_NO_SYMBOL;
else
return val;
}
if (!strncmp(str, "XF86_", 5))
{
long unsigned int ret;
char *tmp;
tmp = strdup(str);
if (!tmp) return XCB_NO_SYMBOL;
memmove(&tmp[4], &tmp[5], strlen(str) - 5 + 1);
ret = _ecore_xcb_keymap_string_to_keysym(tmp);
free(tmp);
return ret;
}
return XCB_NO_SYMBOL;
}
static int
_ecore_xcb_keymap_translate_key(xcb_keycode_t keycode, unsigned int modifiers, unsigned int *modifiers_return, xcb_keysym_t *keysym_return)
{
xcb_keysym_t sym;
if (!_ecore_xcb_keysyms) return 0;
sym = _ecore_xcb_keymap_keycode_to_keysym(keycode, modifiers);
if (modifiers_return)
*modifiers_return = ((XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK) |
_ecore_xcb_mode_switch | ECORE_X_LOCK_NUM);
if (keysym_return)
*keysym_return = sym;
return 1;
}
static int
_ecore_xcb_keymap_translate_keysym(xcb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes)
{
unsigned long hbytes = 0;
unsigned char c;
if (!keysym) return 0;
hbytes = (keysym >> 8);
if (!(bytes &&
((hbytes == 0) ||
((hbytes == 0xFF) &&
(((keysym >= XK_BackSpace) && (keysym <= XK_Clear)) ||
(keysym == XK_Return) || (keysym == XK_Escape) ||
(keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
(keysym == XK_KP_Enter) ||
((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
(keysym == XK_KP_Equal) || (keysym == XK_Delete))))))
return 0;
if (keysym == XK_KP_Space)
c = (XK_space & 0x7F);
else if (hbytes == 0xFF)
c = (keysym & 0x7F);
else
c = (keysym & 0xFF);
if (modifiers & ECORE_X_MODIFIER_CTRL)
{
if (((c >= '@') && (c < '\177')) || c == ' ')
c &= 0x1F;
else if (c == '2')
c = '\000';
else if ((c >= '3') && (c <= '7'))
c -= ('3' - '\033');
else if (c == '8')
c = '\177';
else if (c == '/')
c = '_' & 0x1F;
}
buffer[0] = c;
return 1;
}

View File

@ -1,12 +1,19 @@
/*
* Various MWM related functions.
*
* This is ALL the code involving anything MWM related. for both WM and
* client.
*/
#include "ecore_xcb_private.h"
#include "Ecore_X_Atoms.h"
//#include "Ecore_X_Atoms.h"
#define ECORE_X_MWM_HINTS_FUNCTIONS (1 << 0)
#define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1)
#define ECORE_X_MWM_HINTS_INPUT_MODE (1 << 2)
#define ECORE_X_MWM_HINTS_STATUS (1 << 3)
typedef struct _mwmhints
{
uint32_t flags;
uint32_t functions;
uint32_t decorations;
int32_t inputmode;
uint32_t status;
} MWMHints;
/**
* @defgroup Ecore_X_MWM_Group MWM related functions.
@ -14,138 +21,78 @@
* Functions related to MWM.
*/
#define ECORE_X_MWM_HINTS_FUNCTIONS (1 << 0)
#define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1)
#define ECORE_X_MWM_HINTS_INPUT_MODE (1 << 2)
#define ECORE_X_MWM_HINTS_STATUS (1 << 3)
typedef struct _mwmhints
{
uint32_t flags;
uint32_t functions;
uint32_t decorations;
int32_t inputmode;
uint32_t status;
}
MWMHints;
/**
* Sends the GetProperty request.
* @param window Window whose MWM hints are requested.
* @ingroup Ecore_X_MWM_Group
*/
EAPI void
ecore_x_mwm_hints_get_prefetch(Ecore_X_Window window)
{
xcb_get_property_cookie_t cookie;
cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0,
window ? window : ((xcb_screen_t *)_ecore_xcb_screen)->root,
ECORE_X_ATOM_MOTIF_WM_HINTS,
ECORE_X_ATOM_MOTIF_WM_HINTS,
0, LONG_MAX);
_ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_mwm_hints_get_prefetch */
/**
* Gets the reply of the GetProperty request sent by ecore_x_mwm_hints_get_prefetch().
* @ingroup Ecore_X_MWM_Group
*/
EAPI void
ecore_x_mwm_hints_get_fetch(void)
{
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
} /* ecore_x_mwm_hints_get_fetch */
/**
* To document.
* @param window Unused.
* @param fhint To document.
* @param dhint To document.
* @param ihint To document.
* @return 1 on success, 0 otherwise.
*
* To use this function, you must call before, and in order,
* ecore_x_mwm_hints_get_prefetch(), which sends the GetProperty request,
* then ecore_x_mwm_hints_get_fetch(), which gets the reply.
* @ingroup Ecore_X_MWM_Group
*/
EAPI Eina_Bool
ecore_x_mwm_hints_get(Ecore_X_Window window __UNUSED__,
Ecore_X_MWM_Hint_Func *fhint,
Ecore_X_MWM_Hint_Decor *dhint,
Ecore_X_MWM_Hint_Input *ihint)
{
MWMHints *mwmhints = NULL;
int ret = 0;
xcb_get_property_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
if ((reply->format != 32) ||
(reply->value_len == 0))
return 0;
mwmhints = xcb_get_property_value(reply);
if (reply->value_len >= 4)
{
if (dhint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
*dhint = mwmhints->decorations;
else
*dhint = ECORE_X_MWM_HINT_DECOR_ALL;
}
if (fhint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
*fhint = mwmhints->functions;
else
*fhint = ECORE_X_MWM_HINT_FUNC_ALL;
}
if (ihint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
*ihint = mwmhints->inputmode;
else
*ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
}
ret = 1;
}
return ret;
} /* ecore_x_mwm_hints_get */
/**
* Sets the borderless flag of a window using MWM.
* @param window The window.
*
* @param win The window.
* @param borderless The borderless flag.
*
* @ingroup Ecore_X_MWM_Group
*/
EAPI void
ecore_x_mwm_borderless_set(Ecore_X_Window window,
Eina_Bool borderless)
EAPI void
ecore_x_mwm_borderless_set(Ecore_X_Window win, Eina_Bool borderless)
{
uint32_t data[5] = {0, 0, 0, 0, 0};
uint32_t data[5] = { 0, 0, 0, 0, 0 };
data[0] = 2; /* just set the decorations hint! */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
data[0] = 2;
data[2] = !borderless;
if (window == 0)
window = ((xcb_screen_t *)_ecore_xcb_screen)->root;
ecore_x_window_prop_property_set(win ? win : ((xcb_screen_t *)_ecore_xcb_screen)->root,
ECORE_X_ATOM_MOTIF_WM_HINTS,
ECORE_X_ATOM_MOTIF_WM_HINTS, 32,
(void *)data, 5);
}
xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, window,
ECORE_X_ATOM_MOTIF_WM_HINTS, ECORE_X_ATOM_MOTIF_WM_HINTS,
32, 5, data);
} /* ecore_x_mwm_borderless_set */
EAPI Eina_Bool
ecore_x_mwm_hints_get(Ecore_X_Window win, Ecore_X_MWM_Hint_Func *fhint, Ecore_X_MWM_Hint_Decor *dhint, Ecore_X_MWM_Hint_Input *ihint)
{
xcb_get_property_cookie_t cookie;
xcb_get_property_reply_t *reply;
MWMHints *mwmhints = NULL;
int ret = EINA_FALSE;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
cookie =
xcb_get_property_unchecked(_ecore_xcb_conn, 0, win,
ECORE_X_ATOM_MOTIF_WM_HINTS,
ECORE_X_ATOM_MOTIF_WM_HINTS, 0, LONG_MAX);
reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return EINA_FALSE;
if ((reply->format != 32) || (reply->value_len == 0))
{
free(reply);
return EINA_FALSE;
}
mwmhints = xcb_get_property_value(reply);
if (reply->value_len >= 4)
{
if (dhint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
*dhint = mwmhints->decorations;
else
*dhint = ECORE_X_MWM_HINT_DECOR_ALL;
}
if (fhint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
*fhint = mwmhints->functions;
else
*fhint = ECORE_X_MWM_HINT_FUNC_ALL;
}
if (ihint)
{
if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
*ihint = mwmhints->inputmode;
else
*ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
}
ret = EINA_TRUE;
}
free(reply);
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -18,25 +18,21 @@
* @return New pixmap.
* @ingroup Ecore_X_Pixmap_Group
*/
EAPI Ecore_X_Pixmap
ecore_x_pixmap_new(Ecore_X_Window win,
int w,
int h,
int dep)
EAPI Ecore_X_Pixmap
ecore_x_pixmap_new(Ecore_X_Window win, int w, int h, int dep)
{
Ecore_X_Pixmap pmap;
if (win == 0)
win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (dep == 0)
dep = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth;
if (win == 0) win = ((xcb_screen_t *)_ecore_xcb_screen)->root;
if (dep == 0) dep = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth;
pmap = xcb_generate_id(_ecore_xcb_conn);
xcb_create_pixmap(_ecore_xcb_conn, dep, pmap, win, w, h);
return pmap;
} /* ecore_x_pixmap_new */
}
/**
* Deletes the reference to the given pixmap.
@ -47,11 +43,13 @@ ecore_x_pixmap_new(Ecore_X_Window win,
* @param pmap The given pixmap.
* @ingroup Ecore_X_Pixmap_Group
*/
EAPI void
ecore_x_pixmap_free(Ecore_X_Pixmap pmap)
EAPI void
ecore_x_pixmap_free(Ecore_X_Pixmap pmap)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_free_pixmap(_ecore_xcb_conn, pmap);
} /* ecore_x_pixmap_free */
}
/**
* Pastes a rectangular area of the given pixmap onto the given drawable.
@ -67,19 +65,13 @@ ecore_x_pixmap_free(Ecore_X_Pixmap pmap)
* @param dy The Y position at which to paste the area on @p dest.
* @ingroup Ecore_X_Pixmap_Group
*/
EAPI void
ecore_x_pixmap_paste(Ecore_X_Pixmap pmap,
Ecore_X_Drawable dest,
Ecore_X_GC gc,
int sx,
int sy,
int w,
int h,
int dx,
int dy)
EAPI void
ecore_x_pixmap_paste(Ecore_X_Pixmap pmap, Ecore_X_Drawable dest, Ecore_X_GC gc, int sx, int sy, int w, int h, int dx, int dy)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
xcb_copy_area(_ecore_xcb_conn, pmap, dest, gc, sx, sy, dx, dy, w, h);
} /* ecore_x_pixmap_paste */
}
/**
* Retrieves the size of the given pixmap.
@ -90,12 +82,14 @@ ecore_x_pixmap_paste(Ecore_X_Pixmap pmap,
* @param h Pointer to an integer in which to store the height.
* @ingroup Ecore_X_Pixmap_Group
*/
EAPI void
ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap, int *x, int *y, int *w, int *h)
EAPI void
ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap, int *x, int *y, int *w, int *h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (pmap)
ecore_x_drawable_geometry_get(pmap, x, y, w, h);
} /* ecore_x_pixmap_geometry_get */
ecore_x_drawable_geometry_get(pmap, x, y, w, h);
}
/**
* Retrieves the depth of the given pixmap.
@ -103,9 +97,10 @@ ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap, int *x, int *y, int *w, int *h)
* @return The depth of the pixmap.
* @ingroup Ecore_X_Pixmap_Group
*/
EAPI int
ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap)
EAPI int
ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap)
{
return ecore_x_drawable_depth_get(pmap);
} /* ecore_x_pixmap_depth_get */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return ecore_x_drawable_depth_get(pmap);
}

View File

@ -1,352 +1,337 @@
#ifndef __ECORE_XCB_PRIVATE_H__
#define __ECORE_XCB_PRIVATE_H__
# define __ECORE_XCB_PRIVATE_H__
#include "config.h"
//# define LOGFNS 1
#include <sys/param.h>
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
#endif /* ifndef MAXHOSTNAMELEN */
# include <unistd.h> // included for close & gethostname functions
#ifndef XK_MISCELLANY
# define XK_MISCELLANY 1
#endif /* XK_MISCELLANY */
/* generic xcb includes */
# include <xcb/xcb.h>
# include <xcb/bigreq.h>
# include <xcb/shm.h>
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_keysyms.h>
#include <xcb/bigreq.h>
#ifdef ECORE_XCB_CURSOR
# include <xcb/cursor.h>
#endif /* ECORE_XCB_CURSOR */
#ifdef ECORE_XCB_DAMAGE
# include <xcb/damage.h>
#endif /* ECORE_XCB_DAMAGE */
#ifdef ECORE_XCB_COMPOSITE
# include <xcb/composite.h>
#endif /* ECORE_XCB_COMPOSITE */
#ifdef ECORE_XCB_DPMS
# include <xcb/dpms.h>
#endif /* ECORE_XCB_DPMS */
#ifdef ECORE_XCB_RANDR
# include <xcb/randr.h>
#endif /* ECORE_XCB_RANDR */
#ifdef ECORE_XCB_RENDER
# include <xcb/render.h>
#endif /* ECORE_XCB_RENDER */
#ifdef ECORE_XCB_SCREENSAVER
# include <xcb/screensaver.h>
#endif /* ECORE_XCB_SCREENSAVER */
#ifdef ECORE_XCB_SHAPE
# include <xcb/shape.h>
#endif /* ECORE_XCB_SHAPE */
#ifdef ECORE_XCB_SYNC
# include <xcb/sync.h>
#endif /* ECORE_XCB_SYNC */
#ifdef ECORE_XCB_XFIXES
# include <xcb/xfixes.h>
#endif /* ECORE_XCB_XFIXES */
#ifdef ECORE_XCB_XINERAMA
# include <xcb/xinerama.h>
#endif /* ECORE_XCB_XINERAMA */
#ifdef ECORE_XCB_XPRINT
# include <xcb/xprint.h>
#endif /* ECORE_XCB_XPRINT */
/* EFL includes */
# include "Ecore.h"
# include "Ecore_Input.h"
# include "Ecore_X.h"
#include "Ecore.h"
#include "ecore_private.h"
#include "Ecore_X.h"
/* logging */
extern int _ecore_xcb_log_dom;
extern int _ecore_x11xcb_log_dom;
# ifdef ECORE_XCB_DEFAULT_LOG_COLOR
# undef ECORE_XCB_DEFAULT_LOG_COLOR
# endif
# define ECORE_XCB_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
#ifdef ECORE_XLIB_XCB_DEFAULT_LOG_COLOR
# undef ECORE_XLIB_XCB_DEFAULT_LOG_COLOR
#endif /* ifdef ECORE_XLIB_XCB_DEFAULT_LOG_COLOR */
#define ECORE_XLIB_XCB_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
# ifdef ERR
# undef ERR
# endif
# define ERR(...) EINA_LOG_DOM_ERR(_ecore_xcb_log_dom, __VA_ARGS__)
#ifdef ERR
# undef ERR
#endif /* ifdef ERR */
#define ERR(...) EINA_LOG_DOM_ERR(_ecore_x11xcb_log_dom, __VA_ARGS__)
# ifdef DBG
# undef DBG
# endif
# define DBG(...) EINA_LOG_DOM_DBG(_ecore_xcb_log_dom, __VA_ARGS__)
#ifdef DBG
# undef DBG
#endif /* ifdef DBG */
#define DBG(...) EINA_LOG_DOM_DBG(_ecore_x11xcb_log_dom, __VA_ARGS__)
# ifdef INF
# undef INF
# endif
# define INF(...) EINA_LOG_DOM_INFO(_ecore_xcb_log_dom, __VA_ARGS__)
#ifdef INF
# undef INF
#endif /* ifdef INF */
#define INF(...) EINA_LOG_DOM_INFO(_ecore_x11xcb_log_dom, __VA_ARGS__)
# ifdef WRN
# undef WRN
# endif
# define WRN(...) EINA_LOG_DOM_WARN(_ecore_xcb_log_dom, __VA_ARGS__)
#ifdef WRN
# undef WRN
#endif /* ifdef WRN */
#define WRN(...) EINA_LOG_DOM_WARN(_ecore_x11xcb_log_dom, __VA_ARGS__)
# ifdef CRIT
# undef CRIT
# endif
# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_xcb_log_dom, __VA_ARGS__)
#ifdef CRIT
# undef CRIT
#endif /* ifdef CRIT */
#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_x11xcb_log_dom, __VA_ARGS__)
# ifdef LOGFNS
# include <stdio.h>
# define LOGFN(fl, ln, fn) printf("-ECORE-XCB: %25s: %5i - %s\n", fl, ln, fn);
# else
# define LOGFN(fl, ln, fn)
# endif
typedef struct _Ecore_X_Selection_Intern Ecore_X_Selection_Intern;
# ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 256
# endif
struct _Ecore_X_Selection_Intern
# ifndef MIN
# define MIN(x, y) (((x) > (y)) ? (y) : (x))
# endif
# ifndef MAX
# define MAX(a, b) ((a < b) ? b : a)
# endif
/* enums */
typedef enum _Ecore_Xcb_Encoding_Style Ecore_Xcb_Encoding_Style;
enum _Ecore_Xcb_Encoding_Style
{
Ecore_X_Window win;
Ecore_X_Atom selection;
unsigned char *data;
int length;
Ecore_X_Time time;
XcbStringStyle,
XcbCompoundTextStyle,
XcbTextStyle,
XcbStdICCTextStyle,
XcbUTF8StringStyle
};
typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter;
/* structures */
typedef struct _Ecore_X_DND_Source Ecore_X_DND_Source;
typedef struct _Ecore_X_DND_Target Ecore_X_DND_Target;
typedef struct _Ecore_X_Selection_Intern Ecore_X_Selection_Intern;
typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter;
typedef struct _Ecore_X_Selection_Parser Ecore_X_Selection_Parser;
typedef struct _Ecore_Xcb_Textproperty Ecore_Xcb_Textproperty;
struct _Ecore_X_Selection_Converter
struct _Ecore_X_DND_Source
{
Ecore_X_Atom target;
int (*convert)(char *target, void *data, int size,
void **data_ret, int *size_ret,
Ecore_X_Atom *type, int *typeseize);
int version;
Ecore_X_Window win, dest;
enum
{
ECORE_X_DND_SOURCE_IDLE,
ECORE_X_DND_SOURCE_DRAGGING,
ECORE_X_DND_SOURCE_DROPPED,
ECORE_X_DND_SOURCE_CONVERTING
} state;
struct
{
short x, y;
unsigned short width, height;
} rectangle;
struct
{
Ecore_X_Window window;
int x, y;
} prev;
Ecore_X_Time time;
Ecore_X_Atom action, accepted_action;
int will_accept, suppress;
int await_status;
};
struct _Ecore_X_DND_Target
{
int version;
Ecore_X_Window win, source;
enum
{
ECORE_X_DND_TARGET_IDLE,
ECORE_X_DND_TARGET_ENTERED
} state;
struct
{
int x, y;
} pos;
Ecore_X_Time time;
Ecore_X_Atom action, accepted_action;
int will_accept;
};
struct _Ecore_X_Selection_Intern
{
Ecore_X_Window win;
Ecore_X_Atom selection;
unsigned char *data;
int length;
Ecore_X_Time time;
};
struct _Ecore_X_Selection_Converter
{
Ecore_X_Atom target;
Eina_Bool (*convert) (char *target, void *data, int size, void **data_ret,
int *size_ret, Ecore_X_Atom *type, int *size_type);
Ecore_X_Selection_Converter *next;
};
typedef struct _Ecore_X_Selection_Parser Ecore_X_Selection_Parser;
struct _Ecore_X_Selection_Parser
struct _Ecore_X_Selection_Parser
{
char *target;
void *(*parse)(const char *target, void *data, int size, int format);
char *target;
void *(*parse) (const char *target, void *data, int size, int format);
Ecore_X_Selection_Parser *next;
};
typedef struct _Ecore_X_DND_Source
struct _Ecore_Xcb_Textproperty
{
int version;
Ecore_X_Window win, dest;
char *value;
Ecore_X_Atom encoding;
unsigned int format, nitems;
};
enum {
ECORE_X_DND_SOURCE_IDLE,
ECORE_X_DND_SOURCE_DRAGGING,
ECORE_X_DND_SOURCE_DROPPED,
ECORE_X_DND_SOURCE_CONVERTING
} state;
/* external variables */
extern Ecore_X_Connection *_ecore_xcb_conn;
extern Ecore_X_Screen *_ecore_xcb_screen;
extern double _ecore_xcb_double_click_time;
extern int16_t _ecore_xcb_event_last_root_x;
extern int16_t _ecore_xcb_event_last_root_y;
struct
{
short x, y;
unsigned short width, height;
} rectangle;
struct
{
Ecore_X_Window window;
int x, y;
} prev;
Ecore_X_Time time;
Ecore_X_Atom action, accepted_action;
int will_accept;
int suppress;
int await_status;
} Ecore_X_DND_Source;
typedef struct _Ecore_X_DND_Target
{
int version;
Ecore_X_Window win, source;
enum {
ECORE_X_DND_TARGET_IDLE,
ECORE_X_DND_TARGET_ENTERED
} state;
struct
{
int x, y;
} pos;
Ecore_X_Time time;
Ecore_X_Atom action, accepted_action;
int will_accept;
} Ecore_X_DND_Target;
/* external variables for extension events */
extern int _ecore_xcb_event_damage;
extern int _ecore_xcb_event_randr;
extern int _ecore_xcb_event_screensaver;
extern int _ecore_xcb_event_shape;
extern int _ecore_xcb_event_sync;
extern int _ecore_xcb_event_xfixes;
extern int _ecore_xcb_event_input;
extern int ECORE_X_MODIFIER_SHIFT;
extern int ECORE_X_MODIFIER_CTRL;
extern int ECORE_X_MODIFIER_ALT;
extern int ECORE_X_MODIFIER_WIN;
extern int ECORE_X_LOCK_SCROLL;
extern int ECORE_X_LOCK_NUM;
extern int ECORE_X_LOCK_CAPS;
extern int ECORE_X_LOCK_SHIFT;
extern Ecore_X_Connection *_ecore_xcb_conn;
extern Ecore_X_Screen *_ecore_xcb_screen;
extern double _ecore_xcb_double_click_time;
extern Ecore_X_Time _ecore_xcb_event_last_time;
extern Ecore_X_Window _ecore_xcb_event_last_window;
extern int16_t _ecore_xcb_event_last_root_x;
extern int16_t _ecore_xcb_event_last_root_y;
extern int _ecore_xcb_xcursor;
extern Ecore_X_Atom _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_NUM];
extern Ecore_X_Atom _ecore_xcb_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
extern int _ecore_xcb_button_grabs_num;
extern int _ecore_xcb_key_grabs_num;
extern Ecore_X_Window *_ecore_xcb_button_grabs;
extern Ecore_X_Window *_ecore_xcb_key_grabs;
extern Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data, int type, void *event);
extern void *_ecore_xcb_window_grab_replay_data;
extern int _ecore_window_grabs_num;
extern Ecore_X_Window *_ecore_window_grabs;
extern Eina_Bool (*_ecore_window_grab_replay_func)(void *data, int event_type, void *event);
extern void *_ecore_window_grab_replay_data;
/* private function prototypes */
void _ecore_xcb_error_handler_init(void);
void _ecore_xcb_error_handler_shutdown(void);
extern Ecore_X_Window _ecore_xcb_private_window;
void _ecore_xcb_atoms_init(void);
void _ecore_xcb_atoms_finalize(void);
void _ecore_x_error_handler_init(void);
void _ecore_xcb_extensions_init(void);
void _ecore_xcb_extensions_finalize(void);
void _ecore_x_event_handle_any_event (xcb_generic_event_t *event);
void _ecore_x_event_handle_key_press (xcb_generic_event_t *event);
void _ecore_x_event_handle_key_release (xcb_generic_event_t *event);
void _ecore_x_event_handle_button_press (xcb_generic_event_t *event);
void _ecore_x_event_handle_button_release (xcb_generic_event_t *event);
void _ecore_x_event_handle_motion_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_enter_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_leave_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_focus_in (xcb_generic_event_t *event);
void _ecore_x_event_handle_focus_out (xcb_generic_event_t *event);
void _ecore_x_event_handle_keymap_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_expose (xcb_generic_event_t *event);
void _ecore_x_event_handle_graphics_expose (xcb_generic_event_t *event);
void _ecore_x_event_handle_visibility_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_create_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_destroy_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_unmap_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_map_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_map_request (xcb_generic_event_t *event);
void _ecore_x_event_handle_reparent_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_configure_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_configure_request (xcb_generic_event_t *event);
void _ecore_x_event_handle_gravity_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_resize_request (xcb_generic_event_t *event);
void _ecore_x_event_handle_circulate_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_circulate_request (xcb_generic_event_t *event);
void _ecore_x_event_handle_property_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_selection_clear (xcb_generic_event_t *event);
void _ecore_x_event_handle_selection_request (xcb_generic_event_t *event);
void _ecore_x_event_handle_selection_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_colormap_notify (xcb_generic_event_t *event);
void _ecore_x_event_handle_client_message (xcb_generic_event_t *event);
void _ecore_x_event_handle_mapping_notify (xcb_generic_event_t *event);
#ifdef ECORE_XCB_DAMAGE
void _ecore_x_event_handle_damage_notify (xcb_generic_event_t *event);
#endif /* ECORE_XCB_DAMAGE */
#ifdef ECORE_XCB_RANDR
void _ecore_x_event_handle_randr_change (xcb_generic_event_t *event);
#endif /* ECORE_XCB_RANDR */
#ifdef ECORE_XCB_SCREENSAVER
void _ecore_x_event_handle_screensaver_notify (xcb_generic_event_t *event);
#endif /* ECORE_XCB_SCREENSAVER */
#ifdef ECORE_XCB_SHAPE
void _ecore_x_event_handle_shape_change (xcb_generic_event_t *event);
#endif /* ECORE_XCB_SHAPE */
#ifdef ECORE_XCB_SYNC
void _ecore_x_event_handle_sync_counter (xcb_generic_event_t *event);
void _ecore_x_event_handle_sync_alarm (xcb_generic_event_t *event);
#endif /* ECORE_XCB_SYNC */
#ifdef ECORE_XCB_FIXES
void _ecore_x_event_handle_fixes_selection_notify(xcb_generic_event_t *event);
#endif /* ECORE_XCB_FIXES */
void _ecore_xcb_shape_init(void);
void _ecore_xcb_shape_finalize(void);
/* requests / replies */
int _ecore_x_reply_init ();
void _ecore_x_reply_shutdown ();
void _ecore_xcb_cookie_cache (unsigned int cookie);
unsigned int _ecore_xcb_cookie_get (void);
void _ecore_xcb_reply_cache (void *reply);
void * _ecore_xcb_reply_get (void);
void _ecore_xcb_screensaver_init(void);
void _ecore_xcb_screensaver_finalize(void);
/* atoms */
extern Ecore_X_Atom ECORE_X_ATOM_ATOM;
extern Ecore_X_Atom ECORE_X_ATOM_CARDINAL;
extern Ecore_X_Atom ECORE_X_ATOM_STRING;
extern Ecore_X_Atom ECORE_X_ATOM_WINDOW;
extern Ecore_X_Atom ECORE_X_ATOM_E_FRAME_SIZE;
extern Ecore_X_Atom ECORE_X_ATOM_WM_SIZE_HINTS;
void _ecore_xcb_sync_init(void);
void _ecore_xcb_sync_finalize(void);
void _ecore_xcb_sync_magic_send(int val, Ecore_X_Window win);
#define ECORE_X_ATOMS_COUNT 117
void _ecore_xcb_render_init(void);
void _ecore_xcb_render_finalize(void);
Eina_Bool _ecore_xcb_render_argb_get(void);
Eina_Bool _ecore_xcb_render_anim_get(void);
Eina_Bool _ecore_xcb_render_avail_get(void);
void _ecore_x_atom_init (xcb_intern_atom_cookie_t *);
void _ecore_x_atom_init_finalize (xcb_intern_atom_cookie_t *);
Eina_Bool _ecore_xcb_render_visual_supports_alpha(Ecore_X_Visual visual);
uint32_t _ecore_xcb_render_find_visual_id(int type, Eina_Bool check_alpha);
Ecore_X_Visual *_ecore_xcb_render_visual_get(int visual_id);
/* damage */
void _ecore_x_damage_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_damage_init_finalize (void);
void _ecore_xcb_randr_init(void);
void _ecore_xcb_randr_finalize(void);
/* composite */
void _ecore_x_composite_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_composite_init_finalize (void);
void _ecore_xcb_xfixes_init(void);
void _ecore_xcb_xfixes_finalize(void);
Eina_Bool _ecore_xcb_xfixes_avail_get(void);
/* from dnd */
void _ecore_x_dnd_init (void);
void _ecore_x_dnd_shutdown (void);
Ecore_X_DND_Source * _ecore_x_dnd_source_get (void);
Ecore_X_DND_Target * _ecore_x_dnd_target_get (void);
void _ecore_x_dnd_drag (Ecore_X_Window root,
int x,
int y);
void _ecore_xcb_damage_init(void);
void _ecore_xcb_damage_finalize(void);
/* dpms */
void _ecore_x_dpms_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_dpms_init_finalize (void);
void _ecore_xcb_composite_init(void);
void _ecore_xcb_composite_finalize(void);
/* netwm */
Ecore_X_Window_State _ecore_x_netwm_state_get(Ecore_X_Atom a);
int _ecore_x_netwm_startup_info_begin(Ecore_X_Window win, char *data);
int _ecore_x_netwm_startup_info(Ecore_X_Window win, char *data);
void _ecore_xcb_dpms_init(void);
void _ecore_xcb_dpms_finalize(void);
/* randr */
void _ecore_x_randr_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_randr_init_finalize (void);
void _ecore_xcb_cursor_init(void);
void _ecore_xcb_cursor_finalize(void);
/* selection */
void _ecore_x_selection_init(void);
void _ecore_x_selection_shutdown(void);
Ecore_X_Atom _ecore_x_selection_target_atom_get(const char *target);
char * _ecore_x_selection_target_get(Ecore_X_Atom target);
Ecore_X_Selection_Intern * _ecore_x_selection_get(Ecore_X_Atom selection);
int _ecore_x_selection_set(Ecore_X_Window w, const void *data, int len, Ecore_X_Atom selection);
int _ecore_x_selection_convert(Ecore_X_Atom selection, Ecore_X_Atom target, void **data_ret);
void * _ecore_x_selection_parse(const char *target, void *data, int size, int format);
void _ecore_xcb_xinerama_init(void);
void _ecore_xcb_xinerama_finalize(void);
/* screensaver */
void _ecore_x_screensaver_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_screensaver_init_finalize (void);
void _ecore_xcb_dnd_init(void);
void _ecore_xcb_dnd_shutdown(void);
Ecore_X_DND_Source *_ecore_xcb_dnd_source_get(void);
Ecore_X_DND_Target *_ecore_xcb_dnd_target_get(void);
void _ecore_xcb_dnd_drag(Ecore_X_Window root, int x, int y);
/* shape */
void _ecore_x_shape_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_shape_init_finalize (void);
void _ecore_xcb_selection_init(void);
void _ecore_xcb_selection_shutdown(void);
void *_ecore_xcb_selection_parse(const char *target, void *data, int size, int format);
char *_ecore_xcb_selection_target_get(Ecore_X_Atom target);
Ecore_X_Selection_Intern *_ecore_xcb_selection_get(Ecore_X_Atom selection);
/* sync */
void _ecore_x_sync_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_sync_init_finalize (void);
# ifdef HAVE_ICONV
Eina_Bool _ecore_xcb_utf8_textlist_to_textproperty(char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret);
# endif
Eina_Bool _ecore_xcb_mb_textlist_to_textproperty(char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret);
Eina_Bool _ecore_xcb_textlist_to_textproperty(const char *type, char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret);
/* xfixes */
void _ecore_x_xfixes_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_xfixes_init_finalize (void);
# ifdef HAVE_ICONV
Eina_Bool _ecore_xcb_utf8_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, char ***list_ret, int *count_ret);
# endif
Eina_Bool _ecore_xcb_mb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, char ***list_ret, int *count_ret);
Eina_Bool _ecore_xcb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, const char *type, char ***list_ret, int *count_ret);
/* xinerama */
void _ecore_x_xinerama_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_xinerama_init_finalize (void);
void _ecore_xcb_events_init(void);
void _ecore_xcb_events_shutdown(void);
void _ecore_xcb_events_handle(xcb_generic_event_t *ev);
Ecore_X_Time _ecore_xcb_events_last_time_get(void);
unsigned int _ecore_xcb_events_modifiers_get(unsigned int state);
void _ecore_xcb_event_mouse_move(uint16_t timestamp, uint16_t modifiers, int16_t x, int16_t y, int16_t root_x, int16_t root_y, xcb_window_t event_win, xcb_window_t win, xcb_window_t root_win, uint8_t same_screen, int dev, double radx, double rady, double pressure, double angle, int16_t mx, int16_t my, int16_t mrx, int16_t mry);
Ecore_Event_Mouse_Button *_ecore_xcb_event_mouse_button(int event, uint16_t timestamp, uint16_t modifiers, xcb_button_t buttons, int16_t x, int16_t y, int16_t root_x, int16_t root_y, xcb_window_t event_win, xcb_window_t win, xcb_window_t root_win, uint8_t same_screen, int dev, double radx, double rady, double pressure, double angle, int16_t mx, int16_t my, int16_t mrx, int16_t mry);
/* xprint */
void _ecore_x_xprint_init (const xcb_query_extension_reply_t *reply);
void _ecore_x_xprint_init_finalize (void);
void _ecore_xcb_keymap_init(void);
void _ecore_xcb_keymap_finalize(void);
void _ecore_xcb_keymap_shutdown(void);
void _ecore_xcb_keymap_refresh(xcb_mapping_notify_event_t *event);
xcb_keysym_t _ecore_xcb_keymap_keycode_to_keysym(xcb_keycode_t keycode, int col);
xcb_keycode_t *_ecore_xcb_keymap_keysym_to_keycode(xcb_keysym_t keysym);
char *_ecore_xcb_keymap_keysym_to_string(xcb_keysym_t keysym);
xcb_keycode_t _ecore_xcb_keymap_string_to_keycode(const char *key);
int _ecore_xcb_keymap_lookup_string(xcb_keycode_t keycode, int state, char *buffer, int bytes, xcb_keysym_t *sym);
/* to categorize */
void _ecore_x_sync_magic_send(int val, Ecore_X_Window swin);
void _ecore_x_window_grab_remove(Ecore_X_Window win);
void _ecore_x_key_grab_remove(Ecore_X_Window win);
void _ecore_xcb_input_init(void);
void _ecore_xcb_input_finalize(void);
void _ecore_xcb_input_shutdown(void);
# ifdef ECORE_XCB_XINPUT
void _ecore_xcb_input_handle_event(xcb_generic_event_t *event);
# else
void _ecore_xcb_input_handle_event(xcb_generic_event_t *event __UNUSED__);
# endif
#endif /* __ECORE_XCB_PRIVATE_H__*/
void _ecore_xcb_dri_init(void);
void _ecore_xcb_dri_finalize(void);
void _ecore_xcb_xtest_init(void);
void _ecore_xcb_xtest_finalize(void);
Ecore_X_Window _ecore_xcb_window_root_of_screen_get(int screen);
void _ecore_xcb_window_prop_string_utf8_set(Ecore_X_Window win, Ecore_X_Atom atom, const char *str);
Ecore_X_Visual _ecore_xcb_window_visual_get(Ecore_X_Window win);
void _ecore_xcb_window_button_grab_remove(Ecore_X_Window win);
void _ecore_xcb_window_key_grab_remove(Ecore_X_Window win);
void _ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win, Ecore_X_Window child_win, int type, void *event, Ecore_X_Time timestamp);
int _ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__, uint8_t data __UNUSED__);
int _ecore_xcb_netwm_startup_info(Ecore_X_Window win __UNUSED__, uint8_t data __UNUSED__);
Ecore_X_Window_State _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom);
int _ecore_xcb_error_handle(xcb_generic_error_t *err);
int _ecore_xcb_io_error_handle(xcb_generic_error_t *err);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +1,11 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* ifdef HAVE_CONFIG_H */
#include "ecore_xcb_private.h"
#include <pixman.h>
#include "ecore_xcb_private.h"
/*
* [x] XCreateRegion
* [ ] XPolygonRegion
* [x] XSetRegion
* [x] XDestroyRegion
*
* [x] XOffsetRegion
* [ ] XShrinkRegion
*
* [ ] XClipBox
* [x] XIntersectRegion
* [x] XUnionRegion
* [x] XUnionRectWithRegion
* [x] XSubtractRegion
* [ ] XXorRegion
*
* [x] XEmptyRegion
* [x] XEqualRegion
*
* [x] XPointInRegion
* [x] XRectInRegion
*/
EAPI Ecore_X_XRegion *
@ -34,44 +13,37 @@ ecore_x_xregion_new()
{
pixman_region16_t *region;
region = (pixman_region16_t *)malloc (sizeof (pixman_region16_t));
if (!region)
return NULL;
region = (pixman_region16_t *)malloc(sizeof(pixman_region16_t));
if (!region) return NULL;
pixman_region_init(region);
return (Ecore_X_XRegion *)region;
} /* ecore_x_xregion_new */
}
EAPI void
ecore_x_xregion_free(Ecore_X_XRegion *region)
{
if (!region)
return;
if (!region) return;
pixman_region_fini(region);
free(region);
} /* ecore_x_xregion_free */
}
EAPI Eina_Bool
ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc)
{
xcb_rectangle_t *rects;
pixman_box16_t *boxes;
int num;
int i;
int num = 0, i = 0;
if (!region)
return 0;
if (!region) return EINA_FALSE;
boxes = pixman_region_rectangles ((pixman_region16_t *)region, &num);
if (!boxes || (num == 0))
return 0;
boxes = pixman_region_rectangles((pixman_region16_t *)region, &num);
if ((!boxes) || (num == 0)) return EINA_FALSE;
rects = (xcb_rectangle_t *)malloc(sizeof(xcb_rectangle_t) * num);
if (!rects)
return 0;
if (!rects) return EINA_FALSE;
for (i = 0; i < num; i++)
{
@ -81,83 +53,83 @@ ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc)
rects[i].height = boxes[i].y2 - boxes[i].y1 + 1;
}
xcb_set_clip_rectangles(_ecore_xcb_conn,
XCB_CLIP_ORDERING_YX_BANDED,
gc,
0, 0,
num,
rects);
return 1;
} /* ecore_x_xregion_set */
xcb_set_clip_rectangles(_ecore_xcb_conn, XCB_CLIP_ORDERING_YX_BANDED,
gc, 0, 0, num, rects);
return EINA_TRUE;
}
EAPI void
ecore_x_xregion_translate(Ecore_X_XRegion *region, int x, int y)
{
if (!region)
return;
if (!region) return;
pixman_region_translate((pixman_region16_t *)region, x, y);
} /* ecore_x_xregion_translate */
}
EAPI Eina_Bool
ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
{
return pixman_region_intersect((pixman_region16_t *)dst, (pixman_region16_t *)r1, (pixman_region16_t *)r2);
} /* ecore_x_xregion_intersect */
return pixman_region_intersect((pixman_region16_t *)dst,
(pixman_region16_t *)r1,
(pixman_region16_t *)r2);
}
EAPI Eina_Bool
ecore_x_xregion_union(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
{
return pixman_region_union((pixman_region16_t *)dst, (pixman_region16_t *)r1, (pixman_region16_t *)r2);
} /* ecore_x_xregion_union */
return pixman_region_union((pixman_region16_t *)dst,
(pixman_region16_t *)r1,
(pixman_region16_t *)r2);
}
EAPI Eina_Bool
ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect)
{
return pixman_region_union_rect((pixman_region16_t *)dst, (pixman_region16_t *)src,
return pixman_region_union_rect((pixman_region16_t *)dst,
(pixman_region16_t *)src,
rect->x, rect->y, rect->width, rect->height);
} /* ecore_x_xregion_union_rect */
}
EAPI Eina_Bool
ecore_x_xregion_subtract(Ecore_X_XRegion *dst, Ecore_X_XRegion *rm, Ecore_X_XRegion *rs)
{
return pixman_region_subtract((pixman_region16_t *)dst, (pixman_region16_t *)rm, (pixman_region16_t *)rs);
} /* ecore_x_xregion_subtract */
return pixman_region_subtract((pixman_region16_t *)dst,
(pixman_region16_t *)rm,
(pixman_region16_t *)rs);
}
EAPI Eina_Bool
ecore_x_xregion_is_empty(Ecore_X_XRegion *region)
{
if (!region)
return 1;
if (!region) return EINA_TRUE;
return !pixman_region_not_empty((pixman_region16_t *)region);
} /* ecore_x_xregion_is_empty */
}
EAPI Eina_Bool
ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2)
{
if (!r1 || !r2)
return 0;
if ((!r1) || (!r2)) return EINA_FALSE;
return pixman_region_equal((pixman_region16_t *)r1, (pixman_region16_t *)r2);
} /* ecore_x_xregion_is_equal */
return pixman_region_equal((pixman_region16_t *)r1,
(pixman_region16_t *)r2);
}
EAPI Eina_Bool
ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y)
{
if (!region)
return 0;
if (!region) return EINA_FALSE;
return pixman_region_contains_point((pixman_region16_t *)region, x, y, NULL);
} /* ecore_x_xregion_point_contain */
}
EAPI Eina_Bool
ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect)
{
pixman_box16_t box;
if (!region || !rect)
return 0;
if ((!region) || (!rect)) return EINA_FALSE;
box.x1 = rect->x;
box.y1 = rect->y;
@ -165,5 +137,4 @@ ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect)
box.y2 = rect->y + rect->height - 1;
return pixman_region_contains_rectangle((pixman_region16_t *)region, &box);
} /* ecore_x_xregion_rect_contain */
}

View File

@ -0,0 +1,229 @@
#include "ecore_xcb_private.h"
#include <ctype.h>
#ifdef ECORE_XCB_RENDER
# include <xcb/render.h>
# include <xcb/xcb_renderutil.h>
#endif
/* local function prototypes */
static Eina_Bool _ecore_xcb_render_parse_boolean(char *v);
static char *_ecore_xcb_render_get_resource(const char *prog __UNUSED__, const char *name __UNUSED__);
/* local variables */
static Eina_Bool _render_avail = EINA_FALSE;
static Eina_Bool _render_argb = EINA_FALSE;
static Eina_Bool _render_anim = EINA_FALSE;
void
_ecore_xcb_render_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_RENDER
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_render_id);
#endif
}
void
_ecore_xcb_render_finalize(void)
{
#ifdef ECORE_XCB_RENDER
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_RENDER
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_render_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_render_query_version_cookie_t cookie;
xcb_render_query_version_reply_t *reply;
cookie =
xcb_render_query_version_unchecked(_ecore_xcb_conn,
XCB_RENDER_MAJOR_VERSION,
XCB_RENDER_MINOR_VERSION);
reply = xcb_render_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
// if ((reply->major_version >= XCB_RENDER_MAJOR_VERSION) &&
if (reply->minor_version >= XCB_RENDER_MINOR_VERSION)
{
char *v = NULL;
_render_avail = EINA_TRUE;
if ((reply->major_version > 0) || (reply->minor_version >= 5))
{
_render_argb = EINA_TRUE;
v = getenv("XCURSOR_CORE");
if (!v)
{
// TODO: check xgetdefault when xcb supports resources
v = _ecore_xcb_render_get_resource("Xcursor", "core");
}
if ((v) && (_ecore_xcb_render_parse_boolean(v)))
_render_argb = EINA_FALSE;
}
if ((_render_argb) &&
((reply->major_version > 0) || (reply->minor_version >= 8)))
{
_render_anim = EINA_TRUE;
v = getenv("XCURSOR_ANIM");
if (!v)
{
// TODO: check xgetdefault when xcb supports resources
v = _ecore_xcb_render_get_resource("Xcursor", "anim");
}
if ((v) && (_ecore_xcb_render_parse_boolean(v)))
_render_anim = EINA_FALSE;
}
}
}
free(reply);
}
#endif
}
Eina_Bool
_ecore_xcb_render_avail_get(void)
{
return _render_avail;
}
Eina_Bool
_ecore_xcb_render_argb_get(void)
{
return _render_argb;
}
Eina_Bool
_ecore_xcb_render_anim_get(void)
{
return _render_anim;
}
Eina_Bool
_ecore_xcb_render_visual_supports_alpha(Ecore_X_Visual visual)
{
Eina_Bool ret = EINA_FALSE;
#ifdef ECORE_XCB_RENDER
const xcb_render_query_pict_formats_reply_t *reply;
xcb_render_pictvisual_t *vis;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!visual) return EINA_FALSE;
#ifdef ECORE_XCB_RENDER
reply = xcb_render_util_query_formats(_ecore_xcb_conn);
if (!reply) return EINA_FALSE;
vis =
xcb_render_util_find_visual_format(reply,
((xcb_visualtype_t *)visual)->visual_id);
if (vis)
{
xcb_render_pictforminfo_t temp;
xcb_render_pictforminfo_t *format;
temp.id = vis->format;
format =
xcb_render_util_find_format(reply, XCB_PICT_FORMAT_ID, &temp, 0);
if ((format->type == XCB_RENDER_PICT_TYPE_DIRECT) &&
(format->direct.alpha_mask))
ret = EINA_TRUE;
}
#endif
return ret;
}
uint32_t
_ecore_xcb_render_find_visual_id(int type, Eina_Bool check_alpha)
{
#ifdef ECORE_XCB_RENDER
const xcb_render_query_pict_formats_reply_t *reply;
xcb_render_pictvisual_t *visual = NULL;
xcb_render_pictscreen_iterator_t screens;
xcb_render_pictdepth_iterator_t depths;
xcb_render_pictvisual_iterator_t visuals;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_RENDER
reply = xcb_render_util_query_formats(_ecore_xcb_conn);
if (!reply) return 0;
for (screens = xcb_render_query_pict_formats_screens_iterator(reply);
screens.rem; xcb_render_pictscreen_next(&screens))
{
for (depths = xcb_render_pictscreen_depths_iterator(screens.data);
depths.rem; xcb_render_pictdepth_next(&depths))
{
for (visuals = xcb_render_pictdepth_visuals_iterator(depths.data);
visuals.rem; xcb_render_pictvisual_next(&visuals))
{
xcb_render_pictforminfo_t temp;
xcb_render_pictforminfo_t *format;
visual = visuals.data;
temp.id = visual->format;
format =
xcb_render_util_find_format(reply, XCB_PICT_FORMAT_ID,
&temp, 0);
if (!format) continue;
if (format->type == type)
{
if (check_alpha)
{
if (format->direct.alpha_mask)
return visual->visual;
}
else
return visual->visual;
}
}
}
}
#endif
return 0;
}
/* local function prototypes */
static Eina_Bool
_ecore_xcb_render_parse_boolean(char *v)
{
char c;
c = *v;
if (isupper((int)c))
c = tolower(c);
if ((c == 't') || (c == 'y') || (c == '1'))
return EINA_TRUE;
if ((c == 'f') || (c == 'n') || (c == '0'))
return EINA_FALSE;
if (c == 'o')
{
char d;
d = v[1];
if (isupper((int)d))
d = tolower(d);
if (d == 'n') return EINA_TRUE;
if (d == 'f') return EINA_FALSE;
}
return EINA_FALSE;
}
static char *
_ecore_xcb_render_get_resource(const char *prog __UNUSED__, const char *name __UNUSED__)
{
return NULL;
}

View File

@ -1,114 +0,0 @@
#include <stdlib.h>
#include <Eina.h>
/*
* FIXME:
* - in ecore_xcb_cookie_cache, should provide better error management
* when memory allocation fails
* - Use an array instead of a list
* - Is ecore_xcb_reply_free really needed ?
* _ecore_xcb_reply_cache frees the current reply and
* _ecore_x_reply_shutdown frees the last reply to free.
* I keep it in case it is need for memory improvements,
* but its code is commented.
*/
static Eina_List *_ecore_xcb_cookies = NULL;
static void *_ecore_xcb_reply = NULL;
typedef struct _Ecore_Xcb_Data Ecore_Xcb_Data;
struct _Ecore_Xcb_Data
{
unsigned int cookie;
};
int
_ecore_x_reply_init ()
{
return 1;
} /* _ecore_x_reply_init */
void
_ecore_x_reply_shutdown ()
{
Ecore_Xcb_Data *data;
if (_ecore_xcb_reply)
free(_ecore_xcb_reply);
if (!_ecore_xcb_cookies)
return;
EINA_LIST_FREE(_ecore_xcb_cookies, data)
free(data);
} /* _ecore_x_reply_shutdown */
void
_ecore_xcb_cookie_cache (unsigned int cookie)
{
Ecore_Xcb_Data *data;
if (!_ecore_xcb_cookies)
return;
data = (Ecore_Xcb_Data *)malloc(sizeof(Ecore_Xcb_Data));
if (!data)
return;
data->cookie = cookie;
_ecore_xcb_cookies = eina_list_append(_ecore_xcb_cookies, data);
if (!eina_list_data_find(_ecore_xcb_cookies, data))
{
free(data);
return;
}
} /* _ecore_xcb_cookie_cache */
unsigned int
_ecore_xcb_cookie_get (void)
{
Ecore_Xcb_Data *data;
unsigned int cookie;
if (!_ecore_xcb_cookies)
return 0;
data = eina_list_data_get(_ecore_xcb_cookies);
if (!data)
return 0;
_ecore_xcb_cookies = eina_list_remove_list(_ecore_xcb_cookies, _ecore_xcb_cookies);
cookie = data->cookie;
free(data);
return cookie;
} /* _ecore_xcb_cookie_get */
void
_ecore_xcb_reply_cache (void *reply)
{
if (_ecore_xcb_reply)
free(_ecore_xcb_reply);
_ecore_xcb_reply = reply;
} /* _ecore_xcb_reply_cache */
void *
_ecore_xcb_reply_get (void)
{
return _ecore_xcb_reply;
} /* _ecore_xcb_reply_get */
EAPI void
ecore_xcb_reply_free()
{
/* if (_ecore_xcb_reply) */
/* { */
/* free(_ecore_xcb_reply); */
/* _ecore_xcb_reply = NULL; */
/* } */
} /* ecore_xcb_reply_free */

View File

@ -1,401 +1,301 @@
#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_SCREENSAVER
# include <xcb/screensaver.h>
# endif
/**
* @defgroup Ecore_X_ScreenSaver_Group X ScreenSaver extension
*
* These functions use the ScreenSaver extension of the X server
*/
/* local variables */
static Eina_Bool _screensaver_avail = EINA_FALSE;
/* external variables */
int _ecore_xcb_event_screensaver = -1;
void
_ecore_xcb_screensaver_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
static int _screensaver_available = 0;
static xcb_screensaver_query_version_cookie_t _ecore_xcb_screensaver_init_cookie;
#endif /* ECORE_XCB_SCREENSAVER */
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_screensaver_id);
#endif
}
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_screensaver_init and
_ecore_xcb_screensaver_init_finalize. The first one gets the cookies and
the second one gets the replies and set the atoms. */
void
_ecore_x_screensaver_init(const xcb_query_extension_reply_t *reply)
void
_ecore_xcb_screensaver_finalize(void)
{
#ifdef ECORE_XCB_SCREENSAVER
if (reply && (reply->present))
_ecore_xcb_screensaver_init_cookie = xcb_screensaver_query_version_unchecked(_ecore_xcb_conn, 1, 1);
const xcb_query_extension_reply_t *ext_reply;
#endif
#endif /* ECORE_XCB_SCREENSAVER */
} /* _ecore_x_screensaver_init */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
void
_ecore_x_screensaver_init_finalize(void)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_screensaver_query_version_reply_t *reply;
reply = xcb_screensaver_query_version_reply(_ecore_xcb_conn,
_ecore_xcb_screensaver_init_cookie, NULL);
if (reply)
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_screensaver_id);
if ((ext_reply) && (ext_reply->present))
{
if ((reply->server_major_version >= 1) &&
(reply->server_minor_version >= 1))
_screensaver_available = 1;
xcb_screensaver_query_version_cookie_t cookie;
xcb_screensaver_query_version_reply_t *reply;
free(reply);
cookie =
xcb_screensaver_query_version_unchecked(_ecore_xcb_conn,
XCB_SCREENSAVER_MAJOR_VERSION,
XCB_SCREENSAVER_MINOR_VERSION);
reply =
xcb_screensaver_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if ((reply->server_major_version >= XCB_SCREENSAVER_MAJOR_VERSION) &&
(reply->server_minor_version >= XCB_SCREENSAVER_MINOR_VERSION))
_screensaver_avail = EINA_TRUE;
free(reply);
}
if (_screensaver_avail)
_ecore_xcb_event_screensaver = ext_reply->first_event;
}
#endif
}
#endif /* ECORE_XCB_SCREENSAVER */
} /* _ecore_x_screensaver_init_finalize */
/**
* Return whether the X server supports the ScreenSaver Extension.
* @return 1 if the X ScreenSaver Extension is available, 0 otherwise.
*
* Return 1 if the X server supports the ScreenSaver Extension version 1.0,
* 0 otherwise.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI Eina_Bool
ecore_x_screensaver_event_available_get(void)
{
return 1;
} /* ecore_x_screensaver_event_available_get */
/**
* Sends the QueryInfo request.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_idle_time_prefetch(void)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_screensaver_query_info_cookie_t cookie;
cookie = xcb_screensaver_query_info_unchecked(_ecore_xcb_conn, ((xcb_screen_t *)_ecore_xcb_screen)->root);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_SCREENSAVER */
} /* ecore_x_screensaver_idle_time_prefetch */
/**
* Gets the reply of the QueryInfo request sent by ecore_x_get_screensaver_prefetch().
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_idle_time_fetch(void)
EAPI int
ecore_x_screensaver_idle_time_get(void)
{
int ret = 0;
#ifdef ECORE_XCB_SCREENSAVER
xcb_screensaver_query_info_cookie_t cookie;
xcb_screensaver_query_info_reply_t *reply;
Ecore_X_Window root;
#endif
cookie.sequence = _ecore_xcb_cookie_get();
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
cookie = xcb_screensaver_query_info_unchecked(_ecore_xcb_conn, root);
reply = xcb_screensaver_query_info_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_SCREENSAVER */
} /* ecore_x_screensaver_idle_time_fetch */
if (!reply) return 0;
ret = (reply->ms_until_server / 1000);
free(reply);
#endif
/**
* Get the number of seconds since the last input was received.
* @return The number of seconds.
*
* Get the number of milliseconds since the last input was received
* from the user on any of the input devices.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI int
ecore_x_screensaver_idle_time_get(void)
return ret;
}
EAPI void
ecore_x_screensaver_set(int timeout, int interval, int prefer_blanking, int allow_exposures)
{
int idle = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
xcb_screensaver_query_info_reply_t *reply;
xcb_set_screen_saver(_ecore_xcb_conn,
timeout, interval, prefer_blanking, allow_exposures);
#endif
}
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
/* FIXME: check if it is ms_since_user_input or ms_until_server */
idle = reply->ms_since_user_input / 1000;
#endif /* ECORE_XCB_SCREENSAVER */
return idle;
} /* ecore_x_screensaver_idle_time_get */
/**
* Set the parameters of the screen saver.
* @param timeout The timeout, in second.
* @param interval The interval, in seconds.
* @param blank 0 to disable screen blanking, otherwise enable it.
* @param expose Allow Expose generation event or not.
*
* Set the parameters of the screen saver. @p timeout is the timeout,
* in seconds, until the screen saver turns on. @p interval is the
* interval, in seconds, between screen saver alterations. @p blank
* specifies how to enable screen blanking. @p expose specifies the
* screen save control values.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_set(int timeout,
int interval,
int blank,
int expose)
{
xcb_set_screen_saver(_ecore_xcb_conn,
(int16_t)timeout,
(int16_t)interval,
(uint8_t)blank,
(uint8_t)expose);
} /* ecore_x_screensaver_set */
/**
* Sends the GetScreenSaver request.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_get_screensaver_prefetch(void)
EAPI void
ecore_x_screensaver_timeout_set(int timeout)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
uint16_t pint;
uint8_t pblank, pexpo;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
_ecore_xcb_cookie_cache(cookie.sequence);
} /* ecore_x_get_screensaver_prefetch */
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
pint = reply->interval;
pblank = reply->prefer_blanking;
pexpo = reply->allow_exposures;
free(reply);
xcb_set_screen_saver(_ecore_xcb_conn, timeout, pint, pblank, pexpo);
#endif
}
/**
* Gets the reply of the GetScreenSaver request sent by ecore_x_get_screensaver_prefetch().
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_get_screensaver_fetch(void)
EAPI int
ecore_x_screensaver_timeout_get(void)
{
int timeout = 0;
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
#endif
cookie.sequence = _ecore_xcb_cookie_get();
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
} /* ecore_x_get_screensaver_fetch */
if (!reply) return 0;
timeout = reply->timeout;
free(reply);
#endif
/**
* Set the timeout of the screen saver.
* @param timeout The timeout to set.
*
* Set the @p timeout, in seconds, until the screen saver turns on.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_timeout_set(int timeout)
{
xcb_get_screen_saver_reply_t *reply;
return timeout;
}
reply = _ecore_xcb_reply_get();
if (!reply)
return;
xcb_set_screen_saver(_ecore_xcb_conn,
(int16_t)timeout,
reply->interval,
reply->prefer_blanking,
reply->allow_exposures);
} /* ecore_x_screensaver_timeout_set */
/**
* Get the timeout of the screen saver.
* @return The timeout.
*
* Get the @p timeout, in seconds, until the screen saver turns on.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI int
ecore_x_screensaver_timeout_get(void)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0.0;
return (int)reply->timeout;
} /* ecore_x_screensaver_timeout_get */
/**
* Set the interval of the screen saver.
* @param interval The interval to set.
*
* Set the @p interval, in seconds, between screen saver alterations.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_interval_set(int interval)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
xcb_set_screen_saver(_ecore_xcb_conn,
reply->timeout,
(int16_t)interval,
reply->prefer_blanking,
reply->allow_exposures);
} /* ecore_x_screensaver_interval_set */
/**
* Get the interval of the screen saver.
* @return The interval.
*
* Get the @p interval, in seconds, between screen saver alterations.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI int
ecore_x_screensaver_interval_get(void)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0.0;
return (int)reply->interval;
} /* ecore_x_screensaver_interval_get */
/**
* Set the screen blanking.
* @param blank The blank to set.
*
* @p blank specifies how to enable screen blanking.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_blank_set(int blank)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
xcb_set_screen_saver(_ecore_xcb_conn,
reply->timeout,
reply->interval,
(uint8_t)blank,
reply->allow_exposures);
} /* ecore_x_screensaver_blank_set */
/**
* Get the screen blanking.
* @return The blanking.
*
* Get the screen blanking.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI int
ecore_x_screensaver_blank_get(void)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0.0;
return (int)reply->prefer_blanking;
} /* ecore_x_screensaver_blank_get */
/**
* Set the screen save control values.
* @param expose The expose to set.
*
* Set the screen save control values.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_expose_set(int expose)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return;
xcb_set_screen_saver(_ecore_xcb_conn,
reply->timeout,
reply->interval,
reply->prefer_blanking,
(uint8_t)expose);
} /* ecore_x_screensaver_expose_set */
/**
* Get the screen save control values.
* @return The expose.
*
* Get the screen save control values.
*
* To use this function, you must call before, and in order,
* ecore_x_get_screensaver_prefetch(), which sends the GetScreenSaver request,
* then ecore_x_get_screensaver_fetch(), which gets the reply.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI int
ecore_x_screensaver_expose_get(void)
{
xcb_get_screen_saver_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0.0;
return (int)reply->allow_exposures;
} /* ecore_x_screensaver_expose_get */
/**
* Specifies if the Screen Saver NotifyMask event should be generated.
* @param on 0 to disable the generation of the event, otherwise enable it.
*
* Specifies if the Screen Saver NotifyMask event on the screen
* associated with drawable should be generated for this client. If
* @p on is set to @c 0, the generation is disabled, otherwise, it is
* enabled.
* @ingroup Ecore_X_ScreenSaver_Group
*/
EAPI void
ecore_x_screensaver_event_listen_set(Eina_Bool on)
EAPI void
ecore_x_screensaver_blank_set(int blank)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_screensaver_select_input(_ecore_xcb_conn,
((xcb_screen_t *)_ecore_xcb_screen)->root,
on ? XCB_SCREENSAVER_EVENT_NOTIFY_MASK : 0);
#endif /* ECORE_XCB_SCREENSAVER */
} /* ecore_x_screensaver_event_listen_set */
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
uint16_t pint, pto;
uint8_t pexpo;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
pto = reply->timeout;
pint = reply->interval;
pexpo = reply->allow_exposures;
free(reply);
xcb_set_screen_saver(_ecore_xcb_conn, pto, pint, blank, pexpo);
#endif
}
EAPI int
ecore_x_screensaver_blank_get(void)
{
int blank = 0;
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
blank = reply->prefer_blanking;
free(reply);
#endif
return blank;
}
EAPI void
ecore_x_screensaver_expose_set(int expose)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
uint16_t pint, pto;
uint8_t pblank;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
pto = reply->timeout;
pint = reply->interval;
pblank = reply->prefer_blanking;
free(reply);
xcb_set_screen_saver(_ecore_xcb_conn, pto, pint, pblank, expose);
#endif
}
EAPI int
ecore_x_screensaver_expose_get(void)
{
int expose = 0;
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
expose = reply->allow_exposures;
free(reply);
#endif
return expose;
}
EAPI void
ecore_x_screensaver_interval_set(int interval)
{
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
uint16_t pto;
uint8_t pblank, pexpose;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
pto = reply->timeout;
pblank = reply->prefer_blanking;
pexpose = reply->allow_exposures;
free(reply);
xcb_set_screen_saver(_ecore_xcb_conn, pto, interval, pblank, pexpose);
#endif
}
EAPI int
ecore_x_screensaver_interval_get(void)
{
int interval = 0;
#ifdef ECORE_XCB_SCREENSAVER
xcb_get_screen_saver_cookie_t cookie;
xcb_get_screen_saver_reply_t *reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn);
reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
interval = reply->interval;
free(reply);
#endif
return interval;
}
EAPI void
ecore_x_screensaver_event_listen_set(Eina_Bool on)
{
#ifdef ECORE_XCB_SCREENSAVER
Ecore_X_Window root;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SCREENSAVER
root = ((xcb_screen_t *)_ecore_xcb_screen)->root;
if (on)
xcb_screensaver_select_input(_ecore_xcb_conn, root,
XCB_SCREENSAVER_EVENT_NOTIFY_MASK);
else
xcb_screensaver_select_input(_ecore_xcb_conn, root, 0);
#endif
}
EAPI Eina_Bool
ecore_x_screensaver_event_available_get(void)
{
return _screensaver_avail;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,289 +1,51 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_SHAPE
# include <xcb/shape.h>
#endif
/**
* @defgroup Ecore_X_Shape_Group X Shape extension
*
* Functions that use the shape extension of the X server to change shape of given windows.
*/
/* external variables */
int _ecore_xcb_event_shape = -1;
void
_ecore_xcb_shape_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
static int _shape_available = 0;
static xcb_shape_query_version_cookie_t _ecore_xcb_shape_init_cookie;
#endif /* ECORE_XCB_SHAPE */
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_shape_id);
#endif
}
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_shape_init and
_ecore_xcb_shape_init_finalize. The first one gets the cookies and
the second one gets the replies. */
void
_ecore_x_shape_init(const xcb_query_extension_reply_t *reply)
void
_ecore_xcb_shape_finalize(void)
{
#ifdef ECORE_XCB_SHAPE
if (reply && (reply->present))
_ecore_xcb_shape_init_cookie = xcb_shape_query_version_unchecked(_ecore_xcb_conn);
const xcb_query_extension_reply_t *ext_reply;
#endif
#endif /* ECORE_XCB_SHAPE */
} /* _ecore_x_shape_init */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
void
_ecore_x_shape_init_finalize(void)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_query_version_reply_t *reply;
reply = xcb_shape_query_version_reply(_ecore_xcb_conn,
_ecore_xcb_shape_init_cookie,
NULL);
if (reply)
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_shape_id);
if ((ext_reply) && (ext_reply->present))
{
_shape_available = 1;
free(reply);
xcb_shape_query_version_cookie_t cookie;
xcb_shape_query_version_reply_t *reply;
Eina_Bool _shape_avail = EINA_FALSE;
cookie = xcb_shape_query_version_unchecked(_ecore_xcb_conn);
reply = xcb_shape_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if ((reply->major_version >= XCB_SHAPE_MAJOR_VERSION) &&
(reply->minor_version >= XCB_SHAPE_MINOR_VERSION))
_shape_avail = EINA_TRUE;
free(reply);
}
if (_shape_avail)
_ecore_xcb_event_shape = ext_reply->first_event;
}
#endif /* ECORE_XCB_SHAPE */
} /* _ecore_x_shape_init_finalize */
/**
* Sets the shape of the given window to the given pixmap.
* @param dest_win The given window.
* @param source_mask A 2-bit depth pixmap that provides the new shape of the window.
*
* Sets the shape of the window @p dest_win to the pixmap @p source_mask.
* @ingroup Ecore_X_Shape_Group
*/
EAPI void
ecore_x_window_shape_mask_set(Ecore_X_Window dest_win,
Ecore_X_Pixmap source_mask)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, source_mask);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_mask_set */
EAPI void
ecore_x_window_shape_window_set(Ecore_X_Window dest_win,
Ecore_X_Window shape_win)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_window_set */
EAPI void
ecore_x_window_shape_window_set_xy(Ecore_X_Window dest_win,
Ecore_X_Window shape_win,
int x,
int y)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_window_set_xy */
/**
* Sets the shape of the given window to a rectangle.
* @param dest_win The given window.
* @param x The X coordinate of the top left corner of the rectangle.
* @param y The Y coordinate of the top left corner of the rectangle.
* @param width The width of the rectangle.
* @param height The height of the rectangle.
*
* Sets the shape of the window @p dest_win to a rectangle defined by
* @p x, @p y, @p width and @p height.
* @ingroup Ecore_X_Shape_Group
*/
EAPI void
ecore_x_window_shape_rectangle_set(Ecore_X_Window dest_win,
int x,
int y,
int width,
int height)
{
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangle_set */
EAPI void
ecore_x_window_shape_rectangles_set(Ecore_X_Window dest_win,
Ecore_X_Rectangle *rects,
int num)
{
#ifdef ECORE_XCB_SHAPE
if (num > 0)
xcb_shape_rectangles(_ecore_xcb_conn,
XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
0, dest_win, 0, 0, num, (xcb_rectangle_t *)rects);
else
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangles_set */
EAPI void
ecore_x_window_shape_window_add(Ecore_X_Window dest_win,
Ecore_X_Window shape_win)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, 0, 0, shape_win);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_window_add */
EAPI void
ecore_x_window_shape_window_add_xy(Ecore_X_Window dest_win,
Ecore_X_Window shape_win,
int x,
int y)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, dest_win, x, y, shape_win);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_window_add_xy */
EAPI void
ecore_x_window_shape_rectangle_add(Ecore_X_Window dest_win,
int x,
int y,
int width,
int height)
{
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 1, &rect);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangle_add */
EAPI void
ecore_x_window_shape_rectangle_clip(Ecore_X_Window dest_win,
int x,
int y,
int width,
int height)
{
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
xcb_shape_rectangles(_ecore_xcb_conn,
XCB_SHAPE_SO_INTERSECT, XCB_SHAPE_SK_BOUNDING,
0, dest_win, 0, 0, 1, &rect);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangle_clip */
EAPI void
ecore_x_window_shape_rectangles_add(Ecore_X_Window dest_win,
Ecore_X_Rectangle *rects,
int num)
{
#ifdef ECORE_XCB_SHAPE
if (num > 0)
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, num, (const xcb_rectangle_t *)rects);
else
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_BOUNDING, 0, dest_win, 0, 0, 0, NULL);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangles_add */
/**
* Sends the ShapeGetRectangles request.
* @param window Requested window.
* @ingroup Ecore_X_Shape_Group
*/
EAPI void
ecore_x_window_shape_rectangles_get_prefetch(Ecore_X_Window window)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_get_rectangles_cookie_t cookie;
cookie = xcb_shape_get_rectangles_unchecked(_ecore_xcb_conn, window, XCB_SHAPE_SK_BOUNDING);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangles_get_prefetch */
/**
* Gets the reply of the ShapeGetRectangles request sent by ecore_x_window_shape_rectangles_get_prefetch().
* @ingroup Ecore_X_Shape_Group
*/
EAPI void
ecore_x_window_shape_rectangles_get_fetch(void)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_get_rectangles_cookie_t cookie;
xcb_shape_get_rectangles_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_rectangles_get_fetch */
/**
* To document.
* @param window Unused.
* @param num_ret To document.
* @return To document.
*
* To use this function, you must call before, and in order,
* ecore_x_window_shape_rectangles_get_prefetch(), which sends the ShapeGetRectangles request,
* then ecore_x_window_shape_rectangles_get_fetch(), which gets the reply.
* @ingroup Ecore_X_Shape_Group
*/
EAPI Ecore_X_Rectangle *
ecore_x_window_shape_rectangles_get(Ecore_X_Window window __UNUSED__,
int *num_ret)
{
Ecore_X_Rectangle *rects = NULL;
uint32_t num = 0;
#ifdef ECORE_XCB_SHAPE
xcb_shape_get_rectangles_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
{
if (num_ret)
*num_ret = 0;
return NULL;
}
num = reply->rectangles_len;
rects = malloc(sizeof(Ecore_X_Rectangle) * num);
if (rects)
memcpy (rects,
xcb_shape_get_rectangles_rectangles(reply),
num * sizeof (Ecore_X_Rectangle));
else
num = 0;
#endif /* ECORE_XCB_SHAPE */
if (num_ret)
*num_ret = num;
return rects;
} /* ecore_x_window_shape_rectangles_get */
EAPI void
ecore_x_window_shape_events_select(Ecore_X_Window dest_win,
Eina_Bool on)
{
#ifdef ECORE_XCB_SHAPE
xcb_shape_select_input(_ecore_xcb_conn, dest_win, on ? 1 : 0);
#endif /* ECORE_XCB_SHAPE */
} /* ecore_x_window_shape_events_select */
#endif
}

View File

@ -1,221 +1,298 @@
#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_SYNC
# include <xcb/sync.h>
# endif
/**
* @defgroup Ecore_X_Sync_Group X Sync Extension Functions
*
* Functions related to the X Sync extension.
*/
/* local variables */
static Eina_Bool _sync_avail = EINA_FALSE;
/* external variables */
int _ecore_xcb_event_sync = -1;
void
_ecore_xcb_sync_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SYNC
static int _sync_available = 0;
static xcb_sync_initialize_cookie_t _ecore_xcb_sync_init_cookie;
#endif /* ECORE_XCB_SYNC */
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_sync_id);
#endif
}
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_sync_init and
_ecore_xcb_sync_init_finalize. The first one gets the cookies and
the second one gets the replies and set the atoms. */
void
_ecore_x_sync_init(const xcb_query_extension_reply_t *reply)
void
_ecore_xcb_sync_finalize(void)
{
#ifdef ECORE_XCB_SYNC
if (reply && (reply->present))
_ecore_xcb_sync_init_cookie = xcb_sync_initialize_unchecked(_ecore_xcb_conn,
XCB_SYNC_MAJOR_VERSION,
XCB_SYNC_MINOR_VERSION);
const xcb_query_extension_reply_t *ext_reply;
#endif
#endif /* ECORE_XCB_SYNC */
} /* _ecore_x_sync_init */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
void
_ecore_x_sync_init_finalize(void)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_initialize_reply_t *reply;
reply = xcb_sync_initialize_reply(_ecore_xcb_conn,
_ecore_xcb_sync_init_cookie, NULL);
if (reply)
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_sync_id);
if ((ext_reply) && (ext_reply->present))
{
if (reply->major_version >= 3)
_sync_available = 1;
xcb_sync_initialize_cookie_t cookie;
xcb_sync_initialize_reply_t *reply;
free(reply);
cookie =
xcb_sync_initialize_unchecked(_ecore_xcb_conn,
XCB_SYNC_MAJOR_VERSION,
XCB_SYNC_MINOR_VERSION);
reply = xcb_sync_initialize_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if (reply->major_version >= 3) _sync_avail = EINA_TRUE;
free(reply);
}
if (_sync_avail)
_ecore_xcb_event_sync = ext_reply->first_event;
}
#endif
}
#endif /* ECORE_XCB_SYNC */
} /* _ecore_x_sync_init_finalize */
void
_ecore_xcb_sync_magic_send(int val, Ecore_X_Window win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
ecore_x_client_message32_send(win, 27777, XCB_EVENT_MASK_NO_EVENT,
0x7162534, (0x10000000 + val), win, 0, 0);
}
/**
* Return whether the X server supports the Sync Extension.
* @return 1 if the X Sync Extension is available, 0 otherwise.
*
* Return 1 if the X server supports the Sync Extension version 3.0,
* 0 otherwise.
* @ingroup Ecore_X_Sync_Group
*/
EAPI Eina_Bool
ecore_x_sync_query(void)
/* public functions */
EAPI Ecore_X_Sync_Alarm
ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter)
{
#ifdef ECORE_XCB_SYNC
return _sync_available;
#else /* ifdef ECORE_XCB_SYNC */
return 0;
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_query */
/**
* Create a new alarm.
* @param counter A counter.
* @return A newly created alarm.
*
* Create a new alarm.
* @ingroup Ecore_X_Sync_Group
*/
EAPI Ecore_X_Sync_Alarm
ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter)
{
#ifdef ECORE_XCB_SYNC
uint32_t value_list[6];
uint32_t list[6], mask;
xcb_sync_int64_t init;
Ecore_X_Sync_Alarm alarm;
uint32_t value_mask;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return 0;
#ifdef ECORE_XCB_SYNC
init.lo = 0;
init.hi = 0;
xcb_sync_set_counter(_ecore_xcb_conn, counter, init);
value_mask =
XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE |
XCB_SYNC_CA_VALUE | XCB_SYNC_CA_TEST_TYPE |
XCB_SYNC_CA_DELTA | XCB_SYNC_CA_EVENTS;
value_list[0] = counter;
value_list[1] = XCB_SYNC_VALUETYPE_ABSOLUTE;
value_list[2] = 1;
value_list[3] = XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON;
value_list[4] = 1;
value_list[5] = 1;
mask = (XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE |
XCB_SYNC_CA_VALUE | XCB_SYNC_CA_TEST_TYPE |
XCB_SYNC_CA_DELTA | XCB_SYNC_CA_EVENTS);
list[0] = counter;
list[1] = XCB_SYNC_VALUETYPE_ABSOLUTE;
list[2] = 1;
list[3] = XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON;
list[4] = 1;
list[5] = 1;
alarm = xcb_generate_id(_ecore_xcb_conn);
xcb_sync_create_alarm(_ecore_xcb_conn,
alarm,
value_mask,
(const uint32_t *)value_list);
ecore_x_sync();
xcb_sync_create_alarm(_ecore_xcb_conn, alarm, mask, list);
ecore_x_sync(); // needed
return alarm;
#else /* ifdef ECORE_XCB_SYNC */
#endif
return 0;
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_alarm_new */
}
/**
* Delete an alarm.
* @param alarm The alarm to delete.
* @return 1 on success, 0 otherwise.
*
* Delete the @p alarm. Returns 1 on success, 0 otherwise.
* @ingroup Ecore_X_Sync_Group
*/
EAPI Eina_Bool
ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm)
EAPI Eina_Bool
ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!alarm)) return EINA_FALSE;
#ifdef ECORE_XCB_SYNC
xcb_sync_destroy_alarm(_ecore_xcb_conn, alarm);
return 1;
#else /* ifdef ECORE_XCB_SYNC */
return 0;
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_alarm_free */
return EINA_TRUE;
#endif
/* FIXME: round trip */
return EINA_FALSE;
}
EAPI Eina_Bool
ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val)
EAPI Eina_Bool
ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_query_counter_cookie_t cookie;
xcb_sync_query_counter_reply_t *reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return EINA_FALSE;
#ifdef ECORE_XCB_SYNC
cookie = xcb_sync_query_counter_unchecked(_ecore_xcb_conn, counter);
reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
if (reply)
{
*val = (unsigned int)reply->counter_value.lo;
if (val) *val = (unsigned int)reply->counter_value.lo;
free(reply);
return 1;
return EINA_TRUE;
}
#endif
return EINA_FALSE;
}
#endif /* ECORE_XCB_SYNC */
return 0;
} /* ecore_x_sync_counter_query */
EAPI Ecore_X_Sync_Counter
ecore_x_sync_counter_new(int val)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_counter_t counter;
xcb_sync_int64_t v;
counter = xcb_generate_id(_ecore_xcb_conn);
v.hi = (val < 0) ? ~0 : 0;
v.lo = val;
xcb_sync_create_counter(_ecore_xcb_conn, counter, v);
return counter;
#else /* ! ECORE_XCB_SYNC */
return 0;
#endif /* ! ECORE_XCB_SYNC */
} /* ecore_x_sync_counter_new */
EAPI void
ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_destroy_counter(_ecore_xcb_conn, counter);
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_counter_free */
EAPI void
ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter, int by)
EAPI void
ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter, int by)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_int64_t v;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return;
#ifdef ECORE_XCB_SYNC
v.hi = (by < 0) ? ~0 : 0;
v.lo = by;
xcb_sync_change_counter(_ecore_xcb_conn, counter, v);
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_counter_inc */
EAPI void
ecore_x_sync_counter_val_wait(Ecore_X_Sync_Counter counter, int val)
xcb_sync_change_counter(_ecore_xcb_conn, counter, v);
#endif
}
EAPI void
ecore_x_sync_counter_val_wait(Ecore_X_Sync_Counter counter, int val)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_query_counter_cookie_t cookie;
xcb_sync_query_counter_reply_t *reply;
xcb_sync_int64_t v1;
xcb_sync_int64_t v2;
xcb_sync_int64_t v1, v2;
xcb_sync_waitcondition_t cond;
#endif
/* what's the purpose of that call ?? as the value is erased... */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return;
#ifdef ECORE_XCB_SYNC
cookie = xcb_sync_query_counter_unchecked(_ecore_xcb_conn, counter);
reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return;
v1 = reply->counter_value;
free(reply);
v1.hi = (val < 0) ? ~0 : 0;
v1.lo = val;
v2.hi = ((val + 1) < 0) ? ~0 : 0;
v2.lo = val + 1;
v2.lo = (val + 1);
cond.trigger.counter = counter;
cond.trigger.wait_type = XCB_SYNC_VALUETYPE_ABSOLUTE;
cond.trigger.wait_value = v1;
cond.trigger.test_type = XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON;
cond.event_threshold = v2;
xcb_sync_await(_ecore_xcb_conn, 1, (const xcb_sync_waitcondition_t *)&cond);
#endif /* ECORE_XCB_SYNC */
} /* ecore_x_sync_counter_val_wait */
xcb_sync_await(_ecore_xcb_conn, 1, &cond);
#endif
}
EAPI Ecore_X_Sync_Counter
ecore_x_sync_counter_new(int val)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_counter_t counter;
xcb_sync_int64_t v;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_sync_avail) return 0;
#ifdef ECORE_XCB_SYNC
v.hi = (val < 0) ? ~0 : 0;
v.lo = val;
counter = xcb_generate_id(_ecore_xcb_conn);
xcb_sync_create_counter(_ecore_xcb_conn, counter, v);
return counter;
#endif
return 0;
}
EAPI void
ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return;
#ifdef ECORE_XCB_SYNC
xcb_sync_destroy_counter(_ecore_xcb_conn, counter);
#endif
}
EAPI void
ecore_x_sync_counter_set(Ecore_X_Sync_Counter counter, int val)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_int64_t v;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return;
#ifdef ECORE_XCB_SYNC
v.hi = (val < 0) ? ~0 : 0;
v.lo = val;
xcb_sync_set_counter(_ecore_xcb_conn, counter, v);
#endif
}
EAPI void
ecore_x_sync_counter_2_set(Ecore_X_Sync_Counter counter, int val_hi, unsigned int val_lo)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_int64_t v;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return;
#ifdef ECORE_XCB_SYNC
v.hi = val_hi;
v.lo = val_lo;
xcb_sync_set_counter(_ecore_xcb_conn, counter, v);
#endif
}
EAPI Eina_Bool
ecore_x_sync_counter_2_query(Ecore_X_Sync_Counter counter, int *val_hi, unsigned int *val_lo)
{
#ifdef ECORE_XCB_SYNC
xcb_sync_query_counter_cookie_t cookie;
xcb_sync_query_counter_reply_t *reply;
xcb_sync_int64_t value;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if ((!_sync_avail) || (!counter)) return EINA_FALSE;
#ifdef ECORE_XCB_SYNC
cookie =
xcb_sync_query_counter_unchecked(_ecore_xcb_conn,
(xcb_sync_counter_t)counter);
reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return EINA_FALSE;
value = reply->counter_value;
free(reply);
if (val_hi) *val_hi = (int)value.hi;
if (val_lo) *val_lo = (unsigned int)value.lo;
return EINA_TRUE;
#endif
return EINA_FALSE;
}

View File

@ -0,0 +1,469 @@
#include "ecore_xcb_private.h"
//#include "Ecore_X_Atoms.h"
#include <langinfo.h>
#ifdef HAVE_ICONV
# include <iconv.h>
#endif
#ifndef CODESET
# define CODESET "INVALID"
#endif
static int _ecore_xcb_textlist_get_buffer_size(Eina_Bool is_wide, void *list, int count);
static int _ecore_xcb_textlist_get_wc_len(wchar_t *wstr);
static void *_ecore_xcb_textlist_alloc_list(Eina_Bool is_wide, int count, int nitems);
static void _ecore_xcb_textlist_copy_list(Eina_Bool is_wide, void *text, char **list, int count);
static wchar_t *_ecore_xcb_textlist_copy_wchar(wchar_t *str1, wchar_t *str2);
static int _ecore_xcb_textlist_len_wchar(wchar_t *str);
#ifdef HAVE_ICONV
Eina_Bool
_ecore_xcb_utf8_textlist_to_textproperty(char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_textlist_to_textproperty("utf8string", list, count,
style, ret);
}
#endif
Eina_Bool
_ecore_xcb_mb_textlist_to_textproperty(char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_textlist_to_textproperty("multiByte", list, count,
style, ret);
}
/* NB: This Function May Not Be Correct !!!
* (as I do not know text conversion, locales, etc, etc very well)
*
* Portions were ripped from libX11 XTextListToTextProperty
*/
Eina_Bool
_ecore_xcb_textlist_to_textproperty(const char *type, char **list, int count, Ecore_Xcb_Encoding_Style style, Ecore_Xcb_Textproperty *ret)
{
Eina_Bool is_wide = EINA_FALSE;
Ecore_X_Atom encoding;
int len = 0, nitems = 0, i = 0;
size_t from_left = 0, to_left = 0;
int unconv_num = 0, val = 0;
char *buff, *to, *value, *from;
const char *to_type, *from_type;
char **mb = NULL;
wchar_t **wc = NULL;
#ifdef HAVE_ICONV
iconv_t conv;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!strcmp("wideChar", type)) is_wide = EINA_TRUE;
len = _ecore_xcb_textlist_get_buffer_size(is_wide, list, count);
if (!(buff = (char *)malloc(len * sizeof(char)))) return EINA_FALSE;
from_type = nl_langinfo(CODESET);
switch (style)
{
case XcbStringStyle:
case XcbStdICCTextStyle:
encoding = ECORE_X_ATOM_STRING;
to_type = nl_langinfo(CODESET);
// to_type = "string";
break;
case XcbUTF8StringStyle:
encoding = ECORE_X_ATOM_UTF8_STRING;
to_type = "UTF-8";
break;
case XcbCompoundTextStyle:
encoding = ECORE_X_ATOM_COMPOUND_TEXT;
to_type = nl_langinfo(CODESET);
// to_type = "compoundText";
break;
case XcbTextStyle:
encoding = ECORE_X_ATOM_TEXT;
to_type = nl_langinfo(CODESET);
// to_type = "multiByte";
if (!is_wide)
{
nitems = 0;
mb = (char **)list;
to = buff;
for (i = 0; ((i < count) && (len > 0)); i++)
{
if (*mb) strcpy(to, *mb);
else *to = '\0';
from_left = (*mb ? strlen(*mb) : 0) + 1;
nitems += from_left;
to += from_left;
mb++;
}
unconv_num = 0;
goto done;
}
break;
default:
free(buff);
return EINA_FALSE;
break;
}
if (count < 1)
{
nitems = 0;
goto done;
}
retry:
#ifdef HAVE_ICONV
conv = iconv_open(to_type, from_type);
#endif
if (is_wide)
wc = (wchar_t **)list;
else
mb = (char **)list;
to = buff;
to_left = len;
unconv_num = 0;
for (i = 1; to_left > 0; i++)
{
if (is_wide)
{
from = (char *)*wc;
from_left = _ecore_xcb_textlist_get_wc_len(*wc);
wc++;
}
else
{
from = *mb;
from_left = (*mb ? strlen(*mb) : 0);
mb++;
}
#ifdef HAVE_ICONV
val = iconv(conv, &from, &from_left, &to, &to_left);
#endif
if (val < 0) continue;
if ((val > 0) && (style == XcbStdICCTextStyle) &&
(encoding == ECORE_X_ATOM_STRING))
{
#ifdef HAVE_ICONV
iconv_close(conv);
#endif
encoding = ECORE_X_ATOM_COMPOUND_TEXT;
goto retry;
}
unconv_num += val;
*to++ = '\0';
to_left --;
if (i >= count) break;
}
#ifdef HAVE_ICONV
iconv_close(conv);
#endif
nitems = (to - buff);
done:
if (nitems <= 0) nitems = 1;
if (!(value = (char *)malloc(nitems * sizeof(char))))
{
free(buff);
return EINA_FALSE;
}
if (nitems == 1)
*value = 0;
else
memcpy(value, buff, nitems);
nitems--;
free(buff);
ret->value = value;
ret->encoding = encoding;
ret->format = 8;
ret->nitems = nitems;
return EINA_TRUE;
}
#ifdef HAVE_ICONV
Eina_Bool
_ecore_xcb_utf8_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, char ***list_ret, int *count_ret)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_textproperty_to_textlist(text_prop, "utf8String",
list_ret, count_ret);
}
#endif
Eina_Bool
_ecore_xcb_mb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, char ***list_ret, int *count_ret)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
return _ecore_xcb_textproperty_to_textlist(text_prop, "multiByte",
list_ret, count_ret);
}
Eina_Bool
_ecore_xcb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, const char *type, char ***list_ret, int *count_ret)
{
Eina_Bool is_wide = EINA_FALSE;
Eina_Bool do_strcpy = EINA_FALSE;
const char *from_type;
char *buff, *to, *from;
char *lptr, *sptr;
int nitems = 0, len = 0, num = 0, ret = 0;
size_t from_left = 0, to_left = 0;
#ifdef HAVE_ICONV
iconv_t conv = 0;
#endif
*list_ret = NULL;
*count_ret = 0;
if (!strcmp("wideChar", type)) is_wide = EINA_TRUE;
nitems = text_prop->nitems;
if (nitems <= 0) return EINA_TRUE;
if (text_prop->format != 8) return EINA_FALSE;
from_type = nl_langinfo(CODESET);
if (text_prop->encoding == ECORE_X_ATOM_UTF8_STRING)
from_type = "UTF-8";
if (is_wide)
len = (text_prop->nitems + 1) * sizeof(wchar_t);
else
{
if (!strcmp(type, "utf8String"))
len = text_prop->nitems * 6 + 1;
else
len = text_prop->nitems * MB_CUR_MAX + 1;
}
buff = (char *)malloc(len * sizeof(char));
if (!buff) return EINA_FALSE;
to = buff;
to_left = len;
if (!strcmp(from_type, type))
do_strcpy = EINA_TRUE;
else
{
#ifdef HAVE_ICONV
conv = iconv_open(type, from_type);
#endif
if (!conv)
{
free(buff);
return EINA_FALSE;
}
}
lptr = sptr = text_prop->value;
num = *count_ret = 0;
while (1)
{
if ((nitems == 0) || (*sptr == 0))
{
from = lptr;
from_left = sptr - lptr;
lptr = sptr;
if (do_strcpy)
{
int l = 0;
l = MIN(from_left, to_left);
strncpy(to, from, l);
from += len;
to += len;
from_left -= l;
to_left -= l;
ret = 0;
}
else
ret = iconv(conv, &from, &from_left, &to, &to_left);
if (ret < 0) continue;
num += ret;
(*count_ret)++;
if (nitems == 0) break;
lptr = ++sptr;
if (is_wide)
{
*((wchar_t *)to) = (wchar_t)0;
to += sizeof(wchar_t);
to_left -= sizeof(wchar_t);
}
else
{
*((char *)to) = '\0';
to++;
to_left--;
}
}
else
sptr++;
nitems--;
}
#if HAVE_ICONV
if (!do_strcpy) iconv_close(conv);
#endif
if (is_wide)
{
*((wchar_t *)to) = (wchar_t)0;
to_left -= sizeof(wchar_t);
}
else
{
*((char *)to) = '\0';
to_left--;
}
*list_ret =
_ecore_xcb_textlist_alloc_list(is_wide, *count_ret, (len - to_left));
if (*list_ret)
_ecore_xcb_textlist_copy_list(is_wide, buff, *list_ret, *count_ret);
free(buff);
return EINA_TRUE;
}
static int
_ecore_xcb_textlist_get_buffer_size(Eina_Bool is_wide, void *list, int count)
{
int len = 0;
char **mb;
wchar_t **wc;
if (!list) return 0;
if (is_wide)
{
wc = (wchar_t **)list;
for (; count-- > 0; wc++)
if (*wc) len += _ecore_xcb_textlist_get_wc_len(*wc) + 1;
len *= 5;
}
else
{
mb = (char **)list;
for (; count-- > 0; mb++)
if (*mb) len += strlen(*mb) + 1;
len *= 3;
}
len = (len / 2048 + 1) * 2048;
return len;
}
static int
_ecore_xcb_textlist_get_wc_len(wchar_t *wstr)
{
wchar_t *ptr;
ptr = wstr;
while (*ptr)
ptr++;
return (ptr - wstr);
}
static void *
_ecore_xcb_textlist_alloc_list(Eina_Bool is_wide, int count, int nitems)
{
if (is_wide)
{
wchar_t **list;
list = (wchar_t **)malloc(count * sizeof(wchar_t *));
if (!list) return NULL;
*list = (wchar_t *)malloc(nitems * sizeof(wchar_t));
if (!*list)
{
free(list);
return NULL;
}
return *list;
}
else
{
char **list;
list = (char **)malloc(count * sizeof(char *));
if (!list) return NULL;
*list = (char *)malloc(nitems * sizeof(char));
if (!*list)
{
free(list);
return NULL;
}
return *list;
}
}
static void
_ecore_xcb_textlist_copy_list(Eina_Bool is_wide, void *text, char **list, int count)
{
int len = 0;
if (is_wide)
{
wchar_t *txt, *str, **wlist;
txt = (wchar_t *)text;
wlist = (wchar_t **)list;
for (str = *wlist; count > 0; count--, wlist++)
{
_ecore_xcb_textlist_copy_wchar(str, txt);
*wlist = str;
len = (_ecore_xcb_textlist_len_wchar(str) + 1);
str += len;
txt += len;
}
}
else
{
char *txt, *str, **slist;
txt = (char *)text;
slist = (char **)list;
for (str = *slist; count > 0; count--, slist++)
{
strcpy(str, txt);
*slist = str;
len = strlen(str) + 1;
str += len;
txt += len;
}
}
}
static wchar_t *
_ecore_xcb_textlist_copy_wchar(wchar_t *str1, wchar_t *str2)
{
wchar_t *tmp;
tmp = str1;
while ((*str1++ = *str2++))
;
return tmp;
}
static int
_ecore_xcb_textlist_len_wchar(wchar_t *str)
{
wchar_t *ptr;
ptr = str;
while (*ptr)
ptr++;
return (ptr - str);
}

View File

@ -0,0 +1,359 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_DRI
# include <fcntl.h>
# include <dlfcn.h>
# include <xcb/dri2.h>
#endif
#define ECORE_XCB_VSYNC_DRI2 1
#define DRM_EVENT_CONTEXT_VERSION 2
#ifdef ECORE_XCB_DRI
/* relevant header bits of dri/drm inlined here to avoid needing external */
/* headers to build drm */
typedef unsigned int drm_magic_t;
typedef enum
{
DRM_VBLANK_ABSOLUTE = 0x00000000,
DRM_VBLANK_RELATIVE = 0x00000001,
DRM_VBLANK_EVENT = 0x04000000,
DRM_VBLANK_FLIP = 0x08000000,
DRM_VBLANK_NEXTONMISS = 0x10000000,
DRM_VBLANK_SECONDARY = 0x20000000,
DRM_VBLANK_SIGNAL = 0x40000000
} drmVBlankSeqType;
typedef struct _drmVBlankReq
{
drmVBlankSeqType type;
unsigned int sequence;
unsigned long signal;
} drmVBlankReq;
typedef struct _drmVBlankReply
{
drmVBlankSeqType type;
unsigned int sequence;
long tval_sec, tval_usec;
} drmVBlankReply;
typedef union _drmVBlank
{
drmVBlankReq request;
drmVBlankReply reply;
} drmVBlank;
typedef struct _drmEventContext
{
int version;
void (*vblank_handler)(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data);
void (*page_flip_handler)(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data);
} drmEventContext;
static int (*sym_drmClose) (int fd) = NULL;
static int (*sym_drmGetMagic) (int fd, drm_magic_t * magic) = NULL;
static int (*sym_drmWaitVBlank) (int fd, drmVBlank *vbl) = NULL;
static int (*sym_drmHandleEvent) (int fd, drmEventContext *evctx) = NULL;
#endif
/* local function prototypes */
static Eina_Bool _ecore_xcb_dri_link(void);
static Eina_Bool _ecore_xcb_dri_start(void);
static void _ecore_xcb_dri_shutdown(void);
static Eina_Bool _ecore_xcb_dri_cb(void *data __UNUSED__, Ecore_Fd_Handler *fdh __UNUSED__);
static void _ecore_xcb_dri_tick_begin(void *data __UNUSED__);
static void _ecore_xcb_dri_tick_end(void *data __UNUSED__);
static void _ecore_xcb_dri_tick_schedule(void);
static void _ecore_xcb_dri_vblank_handler(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec __UNUSED__, unsigned int usec __UNUSED__, void *data __UNUSED__);
/* local variables */
static Eina_Bool _dri2_avail = EINA_FALSE;
static Ecore_X_Window _vsync_root = 0;
static int _drm_fd = -1;
static Ecore_Fd_Handler *_drm_fdh = NULL;
static unsigned int _drm_magic = 0;
static Eina_Bool _drm_event_busy = EINA_FALSE;
static void *_drm_lib = NULL;
#ifdef ECORE_XCB_DRI
static drmEventContext _drm_evctx;
#endif
void
_ecore_xcb_dri_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DRI
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_dri2_id);
#endif
}
void
_ecore_xcb_dri_finalize(void)
{
#ifdef ECORE_XCB_DRI
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DRI
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_dri2_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_dri2_query_version_cookie_t dcookie;
xcb_dri2_query_version_reply_t *dreply;
dcookie =
xcb_dri2_query_version_unchecked(_ecore_xcb_conn,
XCB_DRI2_MAJOR_VERSION,
XCB_DRI2_MINOR_VERSION);
dreply = xcb_dri2_query_version_reply(_ecore_xcb_conn, dcookie, NULL);
if (dreply)
{
if (dreply->major_version >= 2) _dri2_avail = EINA_TRUE;
free(dreply);
}
}
#endif
}
EAPI Eina_Bool
ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
{
#ifdef ECORE_XCB_DRI
Ecore_X_Window root;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_dri2_avail) return EINA_FALSE;
#ifdef ECORE_XCB_DRI
root = ecore_x_window_root_get(win);
if (root != _vsync_root)
{
_vsync_root = root;
if (_vsync_root)
{
if (!_ecore_xcb_dri_link())
{
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
return EINA_FALSE;
}
_ecore_xcb_dri_shutdown();
if (!_ecore_xcb_dri_start())
{
_vsync_root = 0;
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
return EINA_FALSE;
}
ecore_animator_custom_source_tick_begin_callback_set
(_ecore_xcb_dri_tick_begin, NULL);
ecore_animator_custom_source_tick_end_callback_set
(_ecore_xcb_dri_tick_end, NULL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
}
else
{
if (_drm_fd >= 0)
{
_ecore_xcb_dri_shutdown();
ecore_animator_custom_source_tick_begin_callback_set
(NULL, NULL);
ecore_animator_custom_source_tick_end_callback_set
(NULL, NULL);
ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
}
}
}
return EINA_TRUE;
#else
return EINA_FALSE;
win = 0;
#endif
}
/* local functions */
static Eina_Bool
_ecore_xcb_dri_link(void)
{
#ifdef ECORE_XCB_DRI
const char *_drm_libs[] =
{
"libdrm.so.2",
"libdrm.so.1",
"libdrm.so.0",
"libdrm.so",
NULL,
};
int i = 0, fail = 0;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DRI
# define SYM(lib, xx) \
do { \
sym_## xx = dlsym(lib, #xx); \
if (!(sym_## xx)) { \
fprintf(stderr, "%s\n", dlerror()); \
fail = 1; \
} \
} while (0);
if (_drm_lib) return EINA_TRUE;
for (i = 0; _drm_libs[i]; i++)
{
_drm_lib = dlopen(_drm_libs[i], (RTLD_LOCAL | RTLD_LAZY));
if (_drm_lib)
{
fail = 0;
SYM(_drm_lib, drmClose);
SYM(_drm_lib, drmGetMagic);
SYM(_drm_lib, drmWaitVBlank);
SYM(_drm_lib, drmHandleEvent);
if (fail)
{
dlclose(_drm_lib);
_drm_lib = NULL;
}
else
break;
}
}
if (!_drm_lib) return EINA_FALSE;
return EINA_TRUE;
#endif
return EINA_FALSE;
}
static Eina_Bool
_ecore_xcb_dri_start(void)
{
#ifdef ECORE_XCB_DRI
xcb_dri2_connect_cookie_t cookie;
xcb_dri2_connect_reply_t *reply;
xcb_dri2_authenticate_cookie_t acookie;
xcb_dri2_authenticate_reply_t *areply;
char *device = NULL, *driver = NULL;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_dri2_avail) return EINA_FALSE;
#ifdef ECORE_XCB_DRI
cookie = xcb_dri2_connect_unchecked(_ecore_xcb_conn,
_vsync_root, XCB_DRI2_DRIVER_TYPE_DRI);
reply = xcb_dri2_connect_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return EINA_FALSE;
driver = xcb_dri2_connect_driver_name(reply);
device = xcb_dri2_connect_device_name(reply);
free(reply);
if (!(_drm_fd = open(device, O_RDWR)))
{
_drm_fd = -1;
return EINA_FALSE;
}
sym_drmGetMagic(_drm_fd, &_drm_magic);
acookie =
xcb_dri2_authenticate_unchecked(_ecore_xcb_conn, _vsync_root, _drm_magic);
areply = xcb_dri2_authenticate_reply(_ecore_xcb_conn, acookie, NULL);
if (!areply)
{
close(_drm_fd);
_drm_fd = -1;
return EINA_FALSE;
}
free(areply);
memset(&_drm_evctx, 0, sizeof(_drm_evctx));
_drm_evctx.version = DRM_EVENT_CONTEXT_VERSION;
_drm_evctx.vblank_handler = _ecore_xcb_dri_vblank_handler;
_drm_evctx.page_flip_handler = NULL;
_drm_fdh = ecore_main_fd_handler_add(_drm_fd, ECORE_FD_READ,
_ecore_xcb_dri_cb, NULL, NULL, NULL);
if (!_drm_fdh)
{
close(_drm_fd);
_drm_fd = -1;
return EINA_FALSE;
}
return EINA_TRUE;
#endif
return EINA_FALSE;
}
static void
_ecore_xcb_dri_shutdown(void)
{
if (_drm_fd >= 0)
{
close(_drm_fd);
_drm_fd = -1;
}
if (_drm_fdh)
{
ecore_main_fd_handler_del(_drm_fdh);
_drm_fdh = NULL;
}
}
static Eina_Bool
_ecore_xcb_dri_cb(void *data __UNUSED__, Ecore_Fd_Handler *fdh __UNUSED__)
{
#ifdef ECORE_XCB_DRI
sym_drmHandleEvent(_drm_fd, &_drm_evctx);
#endif
return ECORE_CALLBACK_RENEW;
}
static void
_ecore_xcb_dri_tick_begin(void *data __UNUSED__)
{
_drm_event_busy = EINA_TRUE;
_ecore_xcb_dri_tick_schedule();
}
static void
_ecore_xcb_dri_tick_end(void *data __UNUSED__)
{
_drm_event_busy = EINA_FALSE;
}
static void
_ecore_xcb_dri_tick_schedule(void)
{
#ifdef ECORE_XCB_DRI
drmVBlank vbl;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_DRI
vbl.request.type = (DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT);
vbl.request.sequence = 1;
vbl.request.signal = 0;
sym_drmWaitVBlank(_drm_fd, &vbl);
#endif
}
static void
_ecore_xcb_dri_vblank_handler(int fd __UNUSED__, unsigned int frame __UNUSED__, unsigned int sec __UNUSED__, unsigned int usec __UNUSED__, void *data __UNUSED__)
{
ecore_animator_custom_tick();
if (_drm_event_busy) _ecore_xcb_dri_tick_schedule();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,16 @@
/* #include "Ecore.h" */
#include "ecore_xcb_private.h"
#include "Ecore_X.h"
typedef struct _Shadow Shadow;
typedef struct _Shadow Shadow;
struct _Shadow
{
Shadow *parent;
Shadow **children;
Shadow *parent, **children;
Ecore_X_Window win;
int children_num;
short x, y;
int children_num;
short x, y;
unsigned short w, h;
};
static int shadow_count = 0;
//static int shadow_count = 0;
static Shadow **shadow_base = NULL;
static int shadow_num = 0;
@ -21,61 +18,33 @@ static int shadow_num = 0;
static Shadow *
_ecore_x_window_tree_walk(Ecore_X_Window window)
{
Shadow *s;
Shadow **sl;
Shadow *s, **sl;
xcb_get_window_attributes_reply_t *reply_attr;
xcb_get_geometry_reply_t *reply_geom;
xcb_query_tree_reply_t *reply_tree;
xcb_get_window_attributes_cookie_t cookie_attr;
xcb_get_geometry_cookie_t cookie_geom;
xcb_query_tree_cookie_t cookie_tree;
int i;
int j;
int i, j;
cookie_attr = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window);
cookie_geom = xcb_get_geometry_unchecked(_ecore_xcb_conn, window);
cookie_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
reply_attr = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_attr, NULL);
if (!reply_attr)
{
reply_geom = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_geom, NULL);
if (reply_geom)
free(reply_geom);
reply_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_tree, NULL);
if (reply_tree)
free(reply_tree);
return NULL;
}
if (!reply_attr) return NULL;
if (reply_attr->map_state != XCB_MAP_STATE_VIEWABLE)
{
reply_geom = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_geom, NULL);
if (reply_geom)
free(reply_geom);
reply_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_tree, NULL);
if (reply_tree)
free(reply_tree);
free(reply_attr);
return NULL;
}
free(reply_attr);
s = calloc(1, sizeof(Shadow));
if (!s)
return NULL;
cookie_geom = xcb_get_geometry_unchecked(_ecore_xcb_conn, window);
reply_geom = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_geom, NULL);
if (!reply_geom)
{
reply_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_tree, NULL);
if (reply_tree)
free(reply_tree);
if (!reply_geom) return NULL;
if (!(s = calloc(1, sizeof(Shadow))))
{
free(reply_geom);
return NULL;
}
@ -87,11 +56,10 @@ _ecore_x_window_tree_walk(Ecore_X_Window window)
free(reply_geom);
cookie_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, window);
reply_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_tree, NULL);
if (reply_tree)
{
/* if (XQueryTree(_ecore_xcb_conn, s->win, &root_win, &parent_win, */
/* &list, &num)) */
xcb_window_t *list;
int num;
@ -106,7 +74,7 @@ _ecore_x_window_tree_walk(Ecore_X_Window window)
{
s->children[i] = _ecore_x_window_tree_walk(list[i]);
if (s->children[i])
s->children[i]->parent = s;
s->children[i]->parent = s;
}
/* compress list down */
j = 0;
@ -128,8 +96,7 @@ _ecore_x_window_tree_walk(Ecore_X_Window window)
{
s->children_num = j;
sl = realloc(s->children, sizeof(Shadow *) * j);
if (sl)
s->children = sl;
if (sl) s->children = sl;
}
}
@ -137,143 +104,132 @@ _ecore_x_window_tree_walk(Ecore_X_Window window)
}
return s;
} /* _ecore_x_window_tree_walk */
}
static void
_ecore_x_window_tree_shadow_free1(Shadow *s)
{
int i;
if (!s)
return;
int i = 0;
if (!s) return;
if (s->children)
{
for (i = 0; i < s->children_num; i++)
{
if (s->children[i])
_ecore_x_window_tree_shadow_free1(s->children[i]);
_ecore_x_window_tree_shadow_free1(s->children[i]);
}
free(s->children);
}
free(s);
} /* _ecore_x_window_tree_shadow_free1 */
}
static void
_ecore_x_window_tree_shadow_free(void)
{
int i;
int i = 0;
if (!shadow_base)
return;
if (!shadow_base) return;
for (i = 0; i < shadow_num; i++)
{
if (!shadow_base[i])
continue;
if (!shadow_base[i]) continue;
_ecore_x_window_tree_shadow_free1(shadow_base[i]);
}
free(shadow_base);
shadow_base = NULL;
shadow_num = 0;
} /* _ecore_x_window_tree_shadow_free */
}
static void
_ecore_x_window_tree_shadow_populate(void)
{
Ecore_X_Window *roots;
int i, num;
Ecore_X_Window *roots = NULL;
int i = 0, num = 0;
roots = ecore_x_window_root_list(&num);
if (roots)
if ((roots = ecore_x_window_root_list(&num)))
{
shadow_base = calloc(1, sizeof(Shadow *) * num);
if (shadow_base)
{
shadow_num = num;
for (i = 0; i < num; i++)
shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
}
free(roots);
}
} /* _ecore_x_window_tree_shadow_populate */
}
/*
static void
_ecore_x_window_tree_shadow_start(void)
{
shadow_count++;
if (shadow_count > 1)
return;
if (shadow_count > 1) return;
_ecore_x_window_tree_shadow_populate();
} /* _ecore_x_window_tree_shadow_start */
}
static void
_ecore_x_window_tree_shadow_stop(void)
{
shadow_count--;
if (shadow_count != 0)
return;
if (shadow_count != 0) return;
_ecore_x_window_tree_shadow_free();
} /* _ecore_x_window_tree_shadow_stop */
}
*/
Shadow *
_ecore_x_window_shadow_tree_find_shadow(Shadow *s, Ecore_X_Window win)
{
Shadow *ss;
int i;
int i = 0;
if (s->win == win)
return s;
if (s->win == win) return s;
if (s->children)
{
for (i = 0; i < s->children_num; i++)
{
if (!s->children[i])
continue;
if (!s->children[i]) continue;
if ((ss = _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
return ss;
if ((ss =
_ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
return ss;
}
}
return NULL;
} /* _ecore_x_window_shadow_tree_find_shadow */
}
Shadow *
_ecore_x_window_shadow_tree_find(Ecore_X_Window base)
{
Shadow *s;
int i;
int i = 0;
for (i = 0; i < shadow_num; i++)
{
if (!shadow_base[i])
continue;
if (!shadow_base[i]) continue;
if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
return s;
if ((s =
_ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
return s;
}
return NULL;
} /* _ecore_x_window_shadow_tree_find */
}
static Ecore_X_Window
_ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, int y,
Ecore_X_Window *skip, int skip_num)
_ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, int y, Ecore_X_Window *skip, int skip_num)
{
Ecore_X_Window child;
int i, j;
int wx, wy;
int i = 0, j = 0, wx = 0, wy = 0;
wx = s->x + bx;
wy = s->y + by;
if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
return 0;
return 0;
if (s->children)
{
@ -281,8 +237,7 @@ _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, i
for (i = s->children_num - 1; i >= 0; --i)
{
if (!s->children[i])
continue;
if (!s->children[i]) continue;
skipit = 0;
if (skip)
@ -296,40 +251,35 @@ _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, i
}
}
}
onward:
if (!skipit)
{
if ((child = _ecore_x_window_shadow_tree_at_xy_get_shadow(s->children[i], wx, wy, x, y, skip, skip_num)))
{
return child;
}
if ((child =
_ecore_x_window_shadow_tree_at_xy_get_shadow(s->children[i], wx, wy, x, y, skip, skip_num)))
return child;
}
}
}
return s->win;
} /* _ecore_x_window_shadow_tree_at_xy_get_shadow */
}
static Ecore_X_Window
_ecore_x_window_shadow_tree_at_xy_get(Ecore_X_Window base, int bx, int by, int x, int y,
Ecore_X_Window *skip, int skip_num)
_ecore_x_window_shadow_tree_at_xy_get(Ecore_X_Window base, int bx, int by, int x, int y, Ecore_X_Window *skip, int skip_num)
{
Shadow *s;
if (!shadow_base)
{
_ecore_x_window_tree_shadow_populate();
if (!shadow_base)
return 0;
if (!shadow_base) return 0;
}
s = _ecore_x_window_shadow_tree_find(base);
if (!s)
return 0;
if (!s) return 0;
return _ecore_x_window_shadow_tree_at_xy_get_shadow(s, bx, by, x, y, skip, skip_num);
} /* _ecore_x_window_shadow_tree_at_xy_get */
}
/**
* Retrieves the top, visible window at the given location,
@ -347,7 +297,7 @@ EAPI Ecore_X_Window
ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base, int x, int y, Ecore_X_Window *skip, int skip_num)
{
return _ecore_x_window_shadow_tree_at_xy_get(base, 0, 0, x, y, skip, skip_num);
} /* ecore_x_window_shadow_tree_at_xy_with_skip_get */
}
/**
* Retrieves the parent window a given window has. This uses the shadow window
@ -358,34 +308,30 @@ ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base, int x, int y
* @ingroup Ecore_X_Window_Geometry_Group
*/
EAPI Ecore_X_Window
ecore_x_window_shadow_parent_get(Ecore_X_Window root, Ecore_X_Window win)
ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__, Ecore_X_Window win)
{
Shadow *s;
int i;
int i = 0;
if (!shadow_base)
{
_ecore_x_window_tree_shadow_populate();
if (!shadow_base)
return 0;
if (!shadow_base) return 0;
}
for (i = 0; i < shadow_num; i++)
{
if (!shadow_base[i])
continue;
if (!shadow_base[i]) continue;
s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
if (s)
{
if (!s->parent)
return 0;
if (!s->parent) return 0;
return s->parent->win;
}
}
return 0;
} /* ecore_x_window_shadow_parent_get */
}
/**
* Flushes the window shadow tree so nothing is stored.
@ -395,5 +341,4 @@ EAPI void
ecore_x_window_shadow_tree_flush(void)
{
_ecore_x_window_tree_shadow_free();
} /* ecore_x_window_shadow_tree_flush */
}

View File

@ -0,0 +1,587 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_SHAPE
# include <xcb/shape.h>
#endif
/**
* @defgroup Ecore_X_Window_Shape X Window Shape Functions
*
* These functions use the shape extension of the X server to change
* shape of given windows.
*/
/**
* Sets the input shape of the given window to that given by the pixmap @p mask.
* @param win The given window.
* @param mask A 1-bit depth pixmap that provides the new input shape of the
* window.
* @ingroup Ecore_X_Window_Shape
*/
EAPI void
ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
win, 0, 0, mask);
#else
return;
win = 0;
mask = 0;
#endif
}
/**
* 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__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
win, 0, 0, mask);
#else
return;
win = 0;
mask = 0;
#endif
}
EAPI void
ecore_x_window_shape_window_set(Ecore_X_Window win, Ecore_X_Window shape_win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
XCB_SHAPE_SK_BOUNDING, win, 0, 0, shape_win);
#else
return;
win = 0;
shape_win = 0;
#endif
}
EAPI void
ecore_x_window_shape_window_set_xy(Ecore_X_Window win, Ecore_X_Window shape_win, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
XCB_SHAPE_SK_BOUNDING, win, x, y, shape_win);
#else
return;
win = 0;
shape_win = 0;
x = 0;
y = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangle_set(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
if (num > 0)
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, num, (xcb_rectangle_t *)&rects);
else
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 0, NULL);
#else
return;
win = 0;
num = 0;
rects = NULL;
#endif
}
EAPI void
ecore_x_window_shape_window_add(Ecore_X_Window win, Ecore_X_Window shape_win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
win, 0, 0, shape_win);
#else
return;
win = 0;
shape_win = 0;
#endif
}
EAPI void
ecore_x_window_shape_window_add_xy(Ecore_X_Window win, Ecore_X_Window shape_win, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING,
win, x, y, shape_win);
#else
return;
win = 0;
shape_win = 0;
x = 0;
y = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangle_add(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, int x, int y, int w, int h)
{
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
if (num > 0)
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, num, (xcb_rectangle_t *)&rects);
else
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 0, NULL);
#else
return;
win = 0;
num = 0;
rects = NULL;
#endif
}
EAPI Ecore_X_Rectangle *
ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret)
{
Ecore_X_Rectangle *rects = NULL;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num_ret) *num_ret = 0;
#ifdef ECORE_XCB_SHAPE
xcb_shape_get_rectangles_cookie_t cookie;
xcb_shape_get_rectangles_reply_t *reply;
xcb_rectangle_t *r;
unsigned int i = 0;
cookie =
xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_BOUNDING);
reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return NULL;
if (num_ret) *num_ret = reply->rectangles_len;
if (reply->rectangles_len < 1)
{
free(reply);
if (num_ret) *num_ret = 0;
return NULL;
}
rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
if (!rects)
{
free(reply);
if (num_ret) *num_ret = 0;
return NULL;
}
r = xcb_shape_get_rectangles_rectangles(reply);
for (i = 0; i < reply->rectangles_len; i++)
{
rects[i].x = r[i].x;
rects[i].y = r[i].y;
rects[i].width = r[i].width;
rects[i].height = r[i].height;
}
free(reply);
return rects;
#else
return rects;
win = 0;
#endif
}
EAPI void
ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_shape_select_input(_ecore_xcb_conn, win, on);
#else
return;
win = 0;
on = 0;
#endif
}
EAPI Ecore_X_Rectangle *
ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret)
{
Ecore_X_Rectangle *rects = NULL;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num_ret) *num_ret = 0;
#ifdef ECORE_XCB_SHAPE
xcb_shape_get_rectangles_cookie_t cookie;
xcb_shape_get_rectangles_reply_t *reply;
xcb_rectangle_t *r;
unsigned int i = 0;
cookie =
xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_INPUT);
reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return NULL;
if (num_ret) *num_ret = reply->rectangles_len;
if (reply->rectangles_len < 1)
{
free(reply);
if (num_ret) *num_ret = 0;
return NULL;
}
rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len);
if (!rects)
{
free(reply);
if (num_ret) *num_ret = 0;
return NULL;
}
r = xcb_shape_get_rectangles_rectangles(reply);
for (i = 0; i < reply->rectangles_len; i++)
{
rects[i].x = r[i].x;
rects[i].y = r[i].y;
rects[i].width = r[i].width;
rects[i].height = r[i].height;
}
free(reply);
return rects;
#else
return rects;
win = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
if (!rects) return;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, num, (xcb_rectangle_t *)rects);
#else
return;
win = 0;
num = 0;
rects = NULL;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win, int x, int y, int w, int h)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win, Ecore_X_Window shape_win, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
// DBG("Window Shape Input Window Set XY: %d %d %d %d", win, shape_win, x, y);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
#else
return;
win = 0;
shape_win = 0;
x = 0;
y = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win, Ecore_X_Window shape_win, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
// DBG("Window Shape Input Window Add XY: %d %d %d %d", win, shape_win, x, y);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT,
XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
#else
return;
win = 0;
shape_win = 0;
x = 0;
y = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_window_set(Ecore_X_Window win, Ecore_X_Window shape_win)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
// DBG("Window Shape Input Window Set: %d %d", win, shape_win);
#ifdef ECORE_XCB_SHAPE
xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
XCB_SHAPE_SK_INPUT, win, 0, 0, shape_win);
#else
return;
win = 0;
shape_win = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win, int x, int y, int w, int h)
{
#ifdef ECORE_XCB_SHAPE
xcb_rectangle_t rect;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 1, &rect);
#else
return;
win = 0;
x = 0;
y = 0;
w = 0;
h = 0;
#endif
}
EAPI void
ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_SHAPE
if (num > 0)
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, num, (xcb_rectangle_t *)&rects);
else
xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
win, 0, 0, 0, NULL);
#else
return;
win = 0;
num = 0;
rects = NULL;
#endif
}

View File

@ -0,0 +1,603 @@
#include "ecore_xcb_private.h"
# ifdef ECORE_XCB_XFIXES
# include <xcb/xfixes.h>
# endif
/* local function prototypes */
static xcb_rectangle_t *_ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, int num);
static Ecore_X_Rectangle *_ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, int num);
/* local variables */
static Eina_Bool _xfixes_avail = EINA_FALSE;
/* external variables */
int _ecore_xcb_event_xfixes = -1;
void
_ecore_xcb_xfixes_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
#endif
}
void
_ecore_xcb_xfixes_finalize(void)
{
#ifdef ECORE_XCB_XFIXES
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xfixes_id);
if ((ext_reply) && (ext_reply->present))
{
xcb_xfixes_query_version_cookie_t cookie;
xcb_xfixes_query_version_reply_t *reply;
cookie =
xcb_xfixes_query_version_unchecked(_ecore_xcb_conn,
XCB_XFIXES_MAJOR_VERSION,
XCB_XFIXES_MINOR_VERSION);
reply = xcb_xfixes_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if (reply->major_version >= 3)
_xfixes_avail = EINA_TRUE;
free(reply);
}
if (_xfixes_avail)
_ecore_xcb_event_xfixes = ext_reply->first_event;
}
#endif
}
Eina_Bool
_ecore_xcb_xfixes_avail_get(void)
{
return _xfixes_avail;
}
/**
* @defgroup Ecore_X_Fixes_Group X Fixes Extension Functions
*
* Functions related to the X Fixes extension.
*/
/**
* Create a region from rectangles.
* @param rects The rectangles used to initialize the region.
* @param num The number of rectangles.
* @return The newly created region.
*
* Create a region initialized to the specified list of rectangles
* @p rects. The rectangles may be specified in any order, their union
* becomes the region.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Region
ecore_x_region_new(Ecore_X_Rectangle *rects, int num)
{
Ecore_X_Region region = 0;
#ifdef ECORE_XCB_XFIXES
xcb_rectangle_t *xrects;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xrects = _ecore_xcb_rect_to_xcb(rects, num);
region = xcb_generate_id(_ecore_xcb_conn);
xcb_xfixes_create_region(_ecore_xcb_conn, region, num, xrects);
free(xrects);
#endif
return region;
}
/**
* Create a region from a pixmap.
* @param bitmap The bitmap used to initialize the region.
* @return The newly created region.
*
* Creates a region initialized to the set of 'one' pixels in @p bitmap
* (which must be of depth 1, else Match error).
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Region
ecore_x_region_new_from_bitmap(Ecore_X_Pixmap bitmap)
{
Ecore_X_Region region = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
region = xcb_generate_id(_ecore_xcb_conn);
xcb_xfixes_create_region_from_bitmap(_ecore_xcb_conn, region, bitmap);
#endif
return region;
}
/**
* Create a region from a window.
* @param window The window used to initialize the region.
* @param type The type of the region.
* @return The newly created region.
*
* Creates a region initialized to the specified @p window region. See
* the Shape extension for the definition of Bounding and Clip
* regions.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Region
ecore_x_region_new_from_window(Ecore_X_Window win, Ecore_X_Region_Type type)
{
Ecore_X_Region region = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
region = xcb_generate_id(_ecore_xcb_conn);
xcb_xfixes_create_region_from_window(_ecore_xcb_conn, region, win, type);
#endif
return region;
}
/**
* Create a region from a graphic context.
* @param gc The graphic context used to initialize the region.
* @return The newly created region.
*
* Creates a region initialized from the clip list of @p gc.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Region
ecore_x_region_new_from_gc(Ecore_X_GC gc)
{
Ecore_X_Region region = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
region = xcb_generate_id(_ecore_xcb_conn);
xcb_xfixes_create_region_from_gc(_ecore_xcb_conn, region, gc);
#endif
return region;
}
/**
* Create a region from a picture.
* @param picture The picture used to initialize the region.
* @return The newly created region.
*
* Creates a region initialized from the clip list of @p picture.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Region
ecore_x_region_new_from_picture(Ecore_X_Picture picture)
{
Ecore_X_Region region = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
region = xcb_generate_id(_ecore_xcb_conn);
xcb_xfixes_create_region_from_picture(_ecore_xcb_conn, region, picture);
#endif
return region;
}
/**
* Destroy a region.
* @param region The region to destroy.
*
* Destroy the specified @p region.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_free(Ecore_X_Region region)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_destroy_region(_ecore_xcb_conn, region);
#endif
}
/**
* Set the content of a region.
* @param region The region to destroy.
* @param rects The rectangles used to set the region.
* @param num The number of rectangles.
*
* Replace the current contents of @p region with the region formed
* by the union of the rectangles @p rects.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_set(Ecore_X_Region region, Ecore_X_Rectangle *rects, int num)
{
#ifdef ECORE_XCB_XFIXES
xcb_rectangle_t *xrects;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xrects = _ecore_xcb_rect_to_xcb(rects, num);
xcb_xfixes_set_region(_ecore_xcb_conn, region, num, xrects);
free(xrects);
#endif
}
/**
* Copy the content of a region.
* @param dest The destination region.
* @param source The source region.
*
* Replace the contents of @p dest with the contents of @p source.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_copy(Ecore_X_Region dest, Ecore_X_Region source)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
// NB: Hmmmm...this may need converting to/fro xcb_rectangle_t
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_copy_region(_ecore_xcb_conn, source, dest);
#endif
}
/**
* Make the union of two regions.
* @param dest The destination region.
* @param source1 The first source region.
* @param source2 The second source region.
*
* Replace the contents of @p dest with the union of @p source1 and
* @p source2.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_combine(Ecore_X_Region dest, Ecore_X_Region source1, Ecore_X_Region source2)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_union_region(_ecore_xcb_conn, source1, source2, dest);
#endif
}
/**
* Make the intersection of two regions.
* @param dest The destination region.
* @param source1 The first source region.
* @param source2 The second source region.
*
* Replace the contents of @p dest with the intersection of @p source1 and
* @p source2.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_intersect(Ecore_X_Region dest, Ecore_X_Region source1, Ecore_X_Region source2)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_intersect_region(_ecore_xcb_conn, source1, source2, dest);
#endif
}
/**
* Make the subtraction of two regions.
* @param dest The destination region.
* @param source1 The first source region.
* @param source2 The second source region.
*
* Replace the contents of @p dest with the subtraction of @p source1 by
* @p source2.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_subtract(Ecore_X_Region dest, Ecore_X_Region source1, Ecore_X_Region source2)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_subtract_region(_ecore_xcb_conn, source1, source2, dest);
#endif
}
/**
* Make the subtraction of regions by bounds.
* @param dest The destination region.
* @param bounds The bounds.
* @param source The source region.
*
* The @p source region is subtracted from the region specified by
* @p bounds. The result is placed in @p dest, replacing its
* contents.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_invert(Ecore_X_Region dest, Ecore_X_Rectangle *bounds, Ecore_X_Region source)
{
#ifdef ECORE_XCB_XFIXES
xcb_rectangle_t xrects;
int num = 0;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
while (bounds + num)
num++;
xrects.x = bounds->x;
xrects.y = bounds->y;
xrects.width = bounds->width;
xrects.height = bounds->height;
// xrects = _ecore_xcb_rect_to_xcb(bounds, num);
xcb_xfixes_invert_region(_ecore_xcb_conn, source, xrects, dest);
// free(xrects);
#endif
}
/**
* Translate a region.
* @param region The region to translate.
* @param dx The horizontal translation.
* @param dy The vertical translation.
*
* The @p region is translated by @p dx and @p dy in place.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_translate(Ecore_X_Region region, int dx, int dy)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_translate_region(_ecore_xcb_conn, region, dx, dy);
#endif
}
/**
* Extent a region.
* @param dest The destination region.
* @param source The source region.
*
* The extents of the @p source region are placed in @p dest.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_extents(Ecore_X_Region dest, Ecore_X_Region source)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_region_extents(_ecore_xcb_conn, source, dest);
#endif
}
/**
* Return the rectangles that compose a region.
* @param region The region (Unused).
* @param num The number of returned rectangles.
* @param bounds The returned bounds of the region.
* @return The returned rectangles.
*
* The @p region passed to ecore_xcb_region_fetch_prefetch() is
* returned as a list of rectagles in XY-banded order.
*
* To use this function, you must call before, and in order,
* ecore_xcb_region_fetch_prefetch(), which sends the XFixesFetchRegion request,
* then ecore_xcb_region_fetch_fetch(), which gets the reply.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI Ecore_X_Rectangle *
ecore_x_region_fetch(Ecore_X_Region region, int *num, Ecore_X_Rectangle *bounds)
{
Ecore_X_Rectangle extents = { 0, 0, 0, 0 };
Ecore_X_Rectangle *rects = NULL;
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_fetch_region_cookie_t cookie;
xcb_xfixes_fetch_region_reply_t *reply;
xcb_rectangle_t *r;
int n = 0;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (num) *num = 0;
if (bounds) *bounds = extents;
#ifdef ECORE_XCB_XFIXES
cookie = xcb_xfixes_fetch_region_unchecked(_ecore_xcb_conn, region);
reply = xcb_xfixes_fetch_region_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return NULL;
r = xcb_xfixes_fetch_region_rectangles(reply);
n = xcb_xfixes_fetch_region_rectangles_length(reply);
rects = _ecore_xcb_rect_to_ecore(r, n);
if (num) *num = n;
/* rects = (Ecore_X_Rectangle *)malloc(n * sizeof(Ecore_X_Rectangle)); */
/* if (!rects) */
/* { */
/* free(reply); */
/* return NULL; */
/* } */
/* for (i = 0; i < n; i++) */
/* { */
/* rects[i].x = r[i].x; */
/* rects[i].y = r[i].y; */
/* rects[i].width = r[i].width; */
/* rects[i].height = r[i].height; */
/* } */
(*bounds).x = reply->extents.x;
(*bounds).y = reply->extents.y;
(*bounds).width = reply->extents.width;
(*bounds).height = reply->extents.height;
free(reply);
#endif
return rects;
}
/**
* Expand a region.
* @param dest The destination region.
* @param source The source region.
* @param left The number of pixels to add on the left.
* @param right The number of pixels to add on the right.
* @param top The number of pixels to add at the top.
* @param bottom The number of pixels to add at the bottom.
*
* Put in @p dest the area specified by expanding each rectangle in
* the @p source region by the specified number of pixels to the
* @p left, @p right, @p top and @p bottom.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_expand(Ecore_X_Region dest, Ecore_X_Region source, unsigned int left, unsigned int right, unsigned int top, unsigned int bottom)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_expand_region(_ecore_xcb_conn, source, dest, left, right, top, bottom);
#endif
}
/**
* Change clip-mask in a graphic context to the specified region.
* @param region The region to change.
* @param gc The clip-mask graphic context.
* @param x_origin The horizontal translation.
* @param y_origin The vertical translation.
*
* Changes clip-mask in @p gc to the specified @p region and
* sets the clip origin with the values of @p x_origin and @p y_origin.
* Output will be clippped to remain contained within the region. The
* clip origin is interpreted relative to the origin of whatever
* destination drawable is specified in a graphics request. The
* region is interpreted relative to the clip origin. Future changes
* to region have no effect on the gc clip-mask.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_gc_clip_set(Ecore_X_Region region, Ecore_X_GC gc, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_set_gc_clip_region(_ecore_xcb_conn, gc, region, x, y);
#endif
}
/**
* Change the shape extension of a window.
* @param region The region.
* @param dest The window whose shape is changed.
* @param type The kind of shape.
* @param x_offset The horizontal offset.
* @param y_offset The vertical offset.
*
* Set the specified Shape extension region of @p window to @p region,
* offset by @p x_offset and @p y_offset. Future changes to region
* have no effect on the window shape.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_window_shape_set(Ecore_X_Region region, Ecore_X_Window dest, Ecore_X_Shape_Type type, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_set_window_shape_region(_ecore_xcb_conn, dest, type, x, y, region);
#endif
}
/**
* Change clip-mask in picture to the specified region.
* @param region The region.
* @param picture The picture.
* @param x_origin The X coordinate of the origin.
* @param y_origin The Y coordinate of the origin.
*
* Changes clip-mask in picture to the specified @p region
* and sets the clip origin. Input and output will be clipped to
* remain contained within the region. The clip origin is interpreted
* relative to the origin of the drawable associated with @p picture. The
* region is interpreted relative to the clip origin. Future changes
* to region have no effect on the picture clip-mask.
* @ingroup Ecore_X_Fixes_Group
*/
EAPI void
ecore_x_region_picture_clip_set(Ecore_X_Region region, Ecore_X_Picture picture, int x, int y)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XFIXES
xcb_xfixes_set_picture_clip_region(_ecore_xcb_conn, picture, region, x, y);
#endif
}
/* local function prototypes */
static xcb_rectangle_t *
_ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, int num)
{
xcb_rectangle_t *xrect;
int i = 0;
if (!num) return NULL;
xrect = malloc(sizeof(xcb_rectangle_t) * num);
if (!xrect) return NULL;
for (i = 0; i < num; i++)
{
xrect[i].x = rects[i].x;
xrect[i].y = rects[i].y;
xrect[i].width = rects[i].width;
xrect[i].height = rects[i].height;
}
return xrect;
}
static Ecore_X_Rectangle *
_ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, int num)
{
Ecore_X_Rectangle *erect;
int i = 0;
if (!num) return NULL;
erect = malloc(sizeof(Ecore_X_Rectangle) * num);
if (!erect) return NULL;
for (i = 0; i < num; i++)
{
erect[i].x = rects[i].x;
erect[i].y = rects[i].y;
erect[i].width = rects[i].width;
erect[i].height = rects[i].height;
}
return erect;
}

View File

@ -1,212 +1,132 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_XINERAMA
# include <xcb/xinerama.h>
#endif
/**
* @defgroup Ecore_X_Xinerama_Group X Xinerama Extension Functions
*
* Functions related to the X Xinerama extension.
*/
/* local variables */
static Eina_Bool _xinerama_avail = EINA_FALSE;
static Eina_Bool _xinerama_active = EINA_FALSE;
void
_ecore_xcb_xinerama_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XINERAMA
static int _xinerama_available = 0;
static xcb_xinerama_query_version_cookie_t _ecore_xcb_xinerama_init_cookie;
#endif /* ECORE_XCB_XINERAMA */
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xinerama_id);
#endif
}
/* To avoid round trips, the initialization is separated in 2
functions: _ecore_xcb_xinerama_init and
_ecore_xcb_xinerama_init_finalize. The first one gets the cookies and
the second one gets the replies. */
void
_ecore_x_xinerama_init(const xcb_query_extension_reply_t *reply)
void
_ecore_xcb_xinerama_finalize(void)
{
#ifdef ECORE_XCB_XINERAMA
if (reply && (reply->present))
_ecore_xcb_xinerama_init_cookie = xcb_xinerama_query_version_unchecked(_ecore_xcb_conn, 1, 2);
const xcb_query_extension_reply_t *ext_reply;
#endif
#endif /* ECORE_XCB_XINERAMA */
} /* _ecore_x_xinerama_init */
LOGFN(__FILE__, __LINE__, __FUNCTION__);
void
_ecore_x_xinerama_init_finalize(void)
{
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_query_version_reply_t *reply;
reply = xcb_xinerama_query_version_reply(_ecore_xcb_conn,
_ecore_xcb_xinerama_init_cookie, NULL);
if (reply)
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xinerama_id);
if ((ext_reply) && (ext_reply->present))
{
if ((reply->major >= 1) &&
(reply->minor >= 1))
_xinerama_available = 1;
xcb_xinerama_query_version_cookie_t cookie;
xcb_xinerama_query_version_reply_t *reply;
free(reply);
}
#endif /* ECORE_XCB_XINERAMA */
} /* _ecore_x_xinerama_init_finalize */
/**
* Return whether the X server supports the Xinerama Extension.
* @return 1 if the X Xinerama Extension is available, 0 otherwise.
*
* Return 1 if the X server supports the Fixes Xinerama version 1.1,
* 0 otherwise.
* @ingroup Ecore_X_Xinerama_Group
*/
EAPI Eina_Bool
ecore_x_xinerama_query(void)
{
#ifdef ECORE_XCB_XINERAMA
return _xinerama_available;
#else /* ifdef ECORE_XCB_XINERAMA */
return 0;
#endif /* ECORE_XCB_XINERAMA */
} /* ecore_x_xinerama_query */
/**
* Sends the XineramaQueryScreens request.
* @ingroup Ecore_X_Xinerama_Group
*/
EAPI void
ecore_x_xinerama_query_screens_prefetch(void)
{
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_query_screens_cookie_t cookie;
cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn);
_ecore_xcb_cookie_cache(cookie.sequence);
#endif /* ECORE_XCB_XINERAMA */
} /* ecore_x_xinerama_query_screens_prefetch */
/**
* Gets the reply of the XineramaQueryScreens request sent by ecore_x_xinerama_query_screens_prefetch().
* @ingroup Ecore_X_Xinerama_Group
*/
EAPI void
ecore_x_xinerama_query_screens_fetch(void)
{
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_query_screens_cookie_t cookie;
xcb_xinerama_query_screens_reply_t *reply;
cookie.sequence = _ecore_xcb_cookie_get();
reply = xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
_ecore_xcb_reply_cache(reply);
#endif /* ECORE_XCB_XINERAMA */
} /* ecore_x_xinerama_query_screens_fetch */
/**
* Return the number of screens.
* @return The screen count.
*
* Return the number of screens.
*
* To use this function, you must call before, and in order,
* ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
* then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
* @ingroup Ecore_X_Xinerama_Group
*/
EAPI int
ecore_x_xinerama_screen_count_get(void)
{
int screen_count = 0;
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_screen_info_iterator_t iter;
xcb_xinerama_query_screens_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
return 0;
iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
screen_count = iter.rem;
#endif /* ECORE_XCB_XINERAMA */
return screen_count;
} /* ecore_x_xinerama_screen_count_get */
/**
* Get the geometry of the screen.
* @param screen The screen (Unused).
* @param x The X coordinate of the screen.
* @param y The Y coordinate of the screen
* @param width The width of the screen
* @param height The height of the screen
* @return 1 on success, 0 otherwise.
*
* Get the geometry of the screen whose number is @p screen. The
* returned values are stored in @p x, @p y, @p width and @p height.
*
* To use this function, you must call before, and in order,
* ecore_x_xinerama_query_screens_prefetch(), which sends the XineramaQueryScreens request,
* then ecore_x_xinerama_query_screens_fetch(), which gets the reply.
* @ingroup Ecore_X_Xinerama_Group
*/
EAPI Eina_Bool
ecore_x_xinerama_screen_geometry_get(int screen,
int *x,
int *y,
int *width,
int *height)
{
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_screen_info_iterator_t iter;
xcb_xinerama_query_screens_reply_t *reply;
reply = _ecore_xcb_reply_get();
if (!reply)
{
if (x)
*x = 0;
if (y)
*y = 0;
if (width)
*width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
if (height)
*height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
return 0;
}
iter = xcb_xinerama_query_screens_screen_info_iterator(reply);
for (; iter.rem; screen--, xcb_xinerama_screen_info_next(&iter))
{
if (screen == 0)
cookie =
xcb_xinerama_query_version_unchecked(_ecore_xcb_conn,
XCB_XINERAMA_MAJOR_VERSION,
XCB_XINERAMA_MINOR_VERSION);
reply =
xcb_xinerama_query_version_reply(_ecore_xcb_conn, cookie, NULL);
if (reply)
{
if (x)
*x = iter.data->x_org;
_xinerama_avail = EINA_TRUE;
// NB: Do we need to compare version numbers here ?
free(reply);
}
if (y)
*y = iter.data->y_org;
if (_xinerama_avail)
{
xcb_xinerama_is_active_cookie_t acookie;
xcb_xinerama_is_active_reply_t *areply;
if (width)
*width = iter.data->width;
if (height)
*height = iter.data->height;
return 1;
acookie = xcb_xinerama_is_active_unchecked(_ecore_xcb_conn);
areply =
xcb_xinerama_is_active_reply(_ecore_xcb_conn, acookie, NULL);
if (areply)
{
_xinerama_active = areply->state;
free(areply);
}
}
}
#endif /* ECORE_XCB_XINERAMA */
#endif
}
if (x)
*x = 0;
EAPI int
ecore_x_xinerama_screen_count_get(void)
{
int count = 0;
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_query_screens_cookie_t cookie;
xcb_xinerama_query_screens_reply_t *reply;
#endif
if (y)
*y = 0;
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (width)
*width = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
if (!_xinerama_avail) return 0;
if (height)
*height = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
#ifdef ECORE_XCB_XINERAMA
cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn);
reply =
xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return 0;
count = reply->number;
#endif
return 0;
} /* ecore_x_xinerama_screen_geometry_get */
return count;
}
EAPI Eina_Bool
ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h)
{
#ifdef ECORE_XCB_XINERAMA
xcb_xinerama_query_screens_cookie_t cookie;
xcb_xinerama_query_screens_reply_t *reply;
xcb_xinerama_screen_info_t *info;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (x) *x = 0;
if (y) *y = 0;
if (w) *w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels;
if (h) *h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels;
if (!_xinerama_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XINERAMA
cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn);
reply =
xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL);
if (!reply) return EINA_FALSE;
info = xcb_xinerama_query_screens_screen_info(reply);
if (!info)
{
free(reply);
return EINA_FALSE;
}
if (x) *x = info[screen].x_org;
if (y) *y = info[screen].y_org;
if (w) *w = info[screen].width;
if (h) *h = info[screen].height;
free(reply);
return EINA_TRUE;
#endif
return EINA_FALSE;
}

View File

@ -0,0 +1,212 @@
#include "ecore_xcb_private.h"
#ifdef ECORE_XCB_XTEST
# include <xcb/xtest.h>
# include <X11/keysym.h>
#endif
/* local variables */
static Eina_Bool _test_avail = EINA_FALSE;
void
_ecore_xcb_xtest_init(void)
{
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XTEST
xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_test_id);
#endif
}
void
_ecore_xcb_xtest_finalize(void)
{
#ifdef ECORE_XCB_XTEST
const xcb_query_extension_reply_t *ext_reply;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
#ifdef ECORE_XCB_XTEST
ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_test_id);
if ((ext_reply) && (ext_reply->present))
_test_avail = EINA_TRUE;
#endif
}
EAPI Eina_Bool
#ifdef ECORE_XCB_XTEST
ecore_x_test_fake_key_down(const char *key)
#else
ecore_x_test_fake_key_down(const char *key __UNUSED__)
#endif
{
#ifdef ECORE_XCB_XTEST
xcb_keycode_t keycode = 0;
xcb_void_cookie_t cookie;
xcb_generic_error_t *err;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_test_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XTEST
keycode = _ecore_xcb_keymap_string_to_keycode(key);
if (keycode == XCB_NO_SYMBOL) return EINA_FALSE;
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS,
keycode, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
return EINA_TRUE;
#endif
return EINA_FALSE;
}
EAPI Eina_Bool
#ifdef ECORE_XCB_XTEST
ecore_x_test_fake_key_up(const char *key)
#else
ecore_x_test_fake_key_up(const char *key __UNUSED__)
#endif
{
#ifdef ECORE_XCB_XTEST
xcb_keycode_t keycode = 0;
xcb_void_cookie_t cookie;
xcb_generic_error_t *err;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_test_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XTEST
keycode = _ecore_xcb_keymap_string_to_keycode(key);
if (keycode == XCB_NO_SYMBOL) return EINA_FALSE;
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE,
keycode, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
return EINA_TRUE;
#endif
return EINA_FALSE;
}
EAPI Eina_Bool
#ifdef ECORE_XCB_XTEST
ecore_x_test_fake_key_press(const char *key)
#else
ecore_x_test_fake_key_press(const char *key __UNUSED__)
#endif
{
#ifdef ECORE_XCB_XTEST
xcb_keycode_t keycode = 0;
xcb_keysym_t keysym = 0;
xcb_keycode_t shift_code = 0;
xcb_void_cookie_t cookie;
xcb_generic_error_t *err;
Eina_Bool shift = EINA_FALSE;
#endif
LOGFN(__FILE__, __LINE__, __FUNCTION__);
if (!_test_avail) return EINA_FALSE;
#ifdef ECORE_XCB_XTEST
keycode = _ecore_xcb_keymap_string_to_keycode(key);
keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 0);
if (keysym == XCB_NO_SYMBOL)
{
keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 1);
if (keysym != XCB_NO_SYMBOL)
shift = EINA_TRUE;
}
if (shift)
{
xcb_keycode_t *keycodes;
int i = 0;
keycodes = _ecore_xcb_keymap_keysym_to_keycode(XK_Shift_L);
while (keycodes[i] != XCB_NO_SYMBOL)
{
if (keycodes[i] != 0)
{
shift_code = keycodes[i];
break;
}
i++;
}
}
if (shift)
{
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS,
shift_code, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root,
0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
}
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS,
keycode, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE,
keycode, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
if (shift)
{
cookie =
xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE,
shift_code, XCB_CURRENT_TIME,
((xcb_screen_t *)_ecore_xcb_screen)->root,
0, 0, 0);
err = xcb_request_check(_ecore_xcb_conn, cookie);
if (err)
{
free(err);
return EINA_FALSE;
}
}
return EINA_TRUE;
#endif
return EINA_FALSE;
}