2003-09-23 01:09:32 -07:00
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_x_private.h"
|
|
|
|
#include "Ecore_X.h"
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
|
|
|
|
*
|
|
|
|
* Functions that can be used to create an X window.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Creates a new window.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param parent The parent window to use. If @p parent is @c 0, the root
|
|
|
|
* window of the default display is used.
|
|
|
|
* @param x X position.
|
|
|
|
* @param y Y position.
|
|
|
|
* @param w Width.
|
|
|
|
* @param h Height.
|
|
|
|
* @return The new window handle.
|
|
|
|
* @ingroup Ecore_X_Window_Create_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = False;
|
|
|
|
attr.colormap = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixmap = None;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.do_not_propagate_mask = True;
|
|
|
|
attr.event_mask = KeyPressMask |
|
|
|
|
KeyReleaseMask |
|
|
|
|
ButtonPressMask |
|
|
|
|
ButtonReleaseMask |
|
|
|
|
EnterWindowMask |
|
|
|
|
LeaveWindowMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
ExposureMask |
|
|
|
|
VisibilityChangeMask |
|
|
|
|
StructureNotifyMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ColormapChangeMask;
|
|
|
|
win = XCreateWindow(_ecore_x_disp, parent,
|
|
|
|
x, y, w, h, 0,
|
|
|
|
DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),
|
|
|
|
InputOutput,
|
|
|
|
DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),
|
|
|
|
CWBackingStore |
|
|
|
|
CWOverrideRedirect |
|
|
|
|
CWColormap |
|
|
|
|
CWBorderPixel |
|
|
|
|
CWBackPixmap |
|
|
|
|
CWSaveUnder |
|
|
|
|
CWDontPropagate |
|
|
|
|
CWEventMask,
|
|
|
|
&attr);
|
2003-10-12 10:55:28 -07:00
|
|
|
|
2003-10-13 10:36:09 -07:00
|
|
|
if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
|
2003-09-23 01:09:32 -07:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-08-01 05:48:39 -07:00
|
|
|
* Creates a window with the override redirect attribute set to @c True.
|
|
|
|
* @param parent The parent window to use. If @p parent is @c 0, the root
|
|
|
|
* window of the default display is used.
|
|
|
|
* @param x X position.
|
|
|
|
* @param y Y position.
|
|
|
|
* @param w Width.
|
|
|
|
* @param h Height.
|
|
|
|
* @return The new window handle.
|
|
|
|
* @ingroup Ecore_X_Window_Create_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = True;
|
|
|
|
attr.colormap = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
|
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixmap = None;
|
|
|
|
attr.save_under = False;
|
|
|
|
attr.do_not_propagate_mask = True;
|
|
|
|
attr.event_mask = KeyPressMask |
|
|
|
|
KeyReleaseMask |
|
|
|
|
ButtonPressMask |
|
|
|
|
ButtonReleaseMask |
|
|
|
|
EnterWindowMask |
|
|
|
|
LeaveWindowMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
ExposureMask |
|
|
|
|
VisibilityChangeMask |
|
|
|
|
StructureNotifyMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ColormapChangeMask;
|
|
|
|
win = XCreateWindow(_ecore_x_disp, parent,
|
|
|
|
x, y, w, h, 0,
|
|
|
|
DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),
|
|
|
|
InputOutput,
|
|
|
|
DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),
|
|
|
|
CWBackingStore |
|
|
|
|
CWOverrideRedirect |
|
|
|
|
CWColormap |
|
|
|
|
CWBorderPixel |
|
|
|
|
CWBackPixmap |
|
|
|
|
CWSaveUnder |
|
|
|
|
CWDontPropagate |
|
|
|
|
CWEventMask,
|
|
|
|
&attr);
|
2003-10-12 10:55:28 -07:00
|
|
|
|
2003-10-13 10:36:09 -07:00
|
|
|
if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
|
2003-09-23 01:09:32 -07:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2003-10-08 19:20:37 -07:00
|
|
|
/**
|
2004-08-01 05:48:39 -07:00
|
|
|
* Creates a new input window.
|
|
|
|
* @param parent The parent window to use. If @p parent is @c 0, the root
|
|
|
|
* window of the default display is used.
|
|
|
|
* @param x X position.
|
|
|
|
* @param y Y position.
|
|
|
|
* @param w Width.
|
|
|
|
* @param h Height.
|
|
|
|
* @return The new window.
|
|
|
|
* @ingroup Ecore_X_Window_Create_Group
|
2003-10-08 19:20:37 -07:00
|
|
|
*/
|
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_window_input_new(Ecore_X_Window parent, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
Window win;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
|
|
|
if (parent == 0) parent = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
attr.override_redirect = True;
|
|
|
|
attr.do_not_propagate_mask = True;
|
|
|
|
attr.event_mask = KeyPressMask |
|
|
|
|
KeyReleaseMask |
|
|
|
|
ButtonPressMask |
|
|
|
|
ButtonReleaseMask |
|
|
|
|
EnterWindowMask |
|
|
|
|
LeaveWindowMask |
|
|
|
|
PointerMotionMask |
|
|
|
|
ExposureMask |
|
|
|
|
VisibilityChangeMask |
|
|
|
|
StructureNotifyMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
PropertyChangeMask |
|
|
|
|
ColormapChangeMask;
|
|
|
|
win = XCreateWindow(_ecore_x_disp, parent,
|
|
|
|
x, y, w, h, 0,
|
|
|
|
0,
|
|
|
|
InputOnly,
|
|
|
|
DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),
|
|
|
|
CWOverrideRedirect |
|
|
|
|
CWDontPropagate |
|
|
|
|
CWEventMask,
|
|
|
|
&attr);
|
2003-10-12 10:55:28 -07:00
|
|
|
|
2003-10-13 09:02:41 -07:00
|
|
|
if (parent == DefaultRootWindow(_ecore_x_disp))
|
|
|
|
{
|
|
|
|
}
|
2003-10-08 19:20:37 -07:00
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Evas_X_Window_Properties_Group X Window Property Functions
|
|
|
|
*
|
|
|
|
* Functions that set window properties.
|
|
|
|
*/
|
|
|
|
|
2003-10-13 10:36:09 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Sets the default properties for the given window.
|
2003-10-13 10:36:09 -07:00
|
|
|
*
|
2004-07-15 06:43:15 -07:00
|
|
|
* The default properties set for the window are @c WM_CLIENT_MACHINE and
|
|
|
|
* @c _NET_WM_PID.
|
|
|
|
*
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @ingroup Evas_X_Window_Properties_Groups
|
2003-10-13 10:36:09 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_defaults_set(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
long pid;
|
|
|
|
char buf[MAXHOSTNAMELEN];
|
2004-02-15 14:33:55 -08:00
|
|
|
char *hostname[1];
|
2004-01-14 15:08:58 -08:00
|
|
|
int argc;
|
|
|
|
char **argv;
|
2004-02-15 14:33:55 -08:00
|
|
|
XTextProperty xprop;
|
2003-10-13 10:36:09 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set WM_CLIENT_MACHINE.
|
|
|
|
*/
|
|
|
|
gethostname(buf, MAXHOSTNAMELEN);
|
|
|
|
buf[MAXHOSTNAMELEN - 1] = '\0';
|
2004-02-15 14:33:55 -08:00
|
|
|
hostname[0] = buf;
|
|
|
|
/* The ecore function uses UTF8 which Xlib may not like (especially
|
|
|
|
* with older clients) */
|
|
|
|
/* ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_client_machine,
|
|
|
|
(char *)buf); */
|
|
|
|
if (XStringListToTextProperty(hostname, 1, &xprop))
|
2004-03-16 15:52:46 -08:00
|
|
|
{
|
|
|
|
XSetWMClientMachine(_ecore_x_disp, win, &xprop);
|
|
|
|
XFree(xprop.value);
|
|
|
|
}
|
2003-10-13 10:36:09 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set _NET_WM_PID
|
|
|
|
*/
|
|
|
|
pid = getpid();
|
|
|
|
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_pid, XA_CARDINAL,
|
|
|
|
32, &pid, 1);
|
2003-10-14 14:42:28 -07:00
|
|
|
|
2004-02-06 16:50:54 -08:00
|
|
|
ecore_x_window_prop_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
|
2004-01-14 15:08:58 -08:00
|
|
|
|
|
|
|
ecore_app_args_get(&argc, &argv);
|
|
|
|
ecore_x_window_prop_command_set(win, argc, argv);
|
2003-10-13 10:36:09 -07:00
|
|
|
}
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-08-01 05:48:39 -07:00
|
|
|
* @defgroup Evas_X_Window_Destroy_Group X Window Destroy Functions
|
|
|
|
*
|
|
|
|
* Functions to destroy X windows.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes the given window.
|
|
|
|
* @param win The given window.
|
|
|
|
* @ingroup Evas_X_Window_Destroy_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_del(Ecore_X_Window win)
|
|
|
|
{
|
2004-08-23 03:44:22 -07:00
|
|
|
/* sorry sir, deleting the root window doesn't sound like
|
|
|
|
* a smart idea.
|
|
|
|
*/
|
|
|
|
if (win)
|
|
|
|
XDestroyWindow(_ecore_x_disp, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a delete request to the given window.
|
|
|
|
* @param win The given window.
|
|
|
|
* @ingroup Evas_X_Window_Destroy_Group
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_delete_request_send(Ecore_X_Window win)
|
|
|
|
{
|
2004-08-23 03:47:20 -07:00
|
|
|
XEvent xev;
|
|
|
|
|
2004-08-23 03:44:22 -07:00
|
|
|
/* sorry sir, deleting the root window doesn't sound like
|
|
|
|
* a smart idea.
|
|
|
|
*/
|
|
|
|
if (!win)
|
|
|
|
return;
|
|
|
|
|
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.display = _ecore_x_disp;
|
|
|
|
xev.xclient.window = win;
|
|
|
|
xev.xclient.message_type = _ecore_x_atom_wm_protocols;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
xev.xclient.data.l[0] = _ecore_x_atom_wm_delete_window;
|
|
|
|
xev.xclient.data.l[1] = CurrentTime;
|
|
|
|
|
|
|
|
XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Evas_X_Window_Visibility_Group X Window Visibility Functions
|
|
|
|
*
|
|
|
|
* Functions to access and change the visibility of X windows.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Shows a window.
|
|
|
|
*
|
|
|
|
* Synonymous to "mapping" a window in X Window System terminology.
|
|
|
|
*
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to show.
|
|
|
|
* @ingroup Evas_X_Window_Visibility
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_show(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
XMapWindow(_ecore_x_disp, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Hides a window.
|
|
|
|
*
|
|
|
|
* Synonymous to "unmapping" a window in X Window System terminology.
|
|
|
|
*
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to hide.
|
|
|
|
* @ingroup Evas_X_Window_Visibility
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_hide(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
XUnmapWindow(_ecore_x_disp, win);
|
|
|
|
}
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
|
|
|
|
*
|
|
|
|
* Functions that change or retrieve the geometry of X windows.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Moves a window to the position @p x, @p y.
|
|
|
|
*
|
|
|
|
* The position is relative to the upper left hand corner of the
|
|
|
|
* parent window.
|
|
|
|
*
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to move.
|
|
|
|
* @param x X position.
|
|
|
|
* @param y Y position.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_move(Ecore_X_Window win, int x, int y)
|
|
|
|
{
|
|
|
|
XMoveWindow(_ecore_x_disp, win, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Resizes a window.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to resize.
|
|
|
|
* @param w New width of the window.
|
|
|
|
* @param h New height of the window.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_resize(Ecore_X_Window win, int w, int h)
|
|
|
|
{
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
XResizeWindow(_ecore_x_disp, win, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Moves and resizes a window.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to move and resize.
|
|
|
|
* @param x New X position of the window.
|
|
|
|
* @param y New Y position of the window.
|
|
|
|
* @param w New width of the window.
|
|
|
|
* @param h New height of the window.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_move_resize(Ecore_X_Window win, int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
|
|
|
|
}
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
|
|
|
|
*
|
|
|
|
* Functions that give the focus to an X Window.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Sets the focus to the window @p win.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to focus.
|
|
|
|
* @ingroup Ecore_X_Window_Focus_Functions
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_focus(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Sets the focus to the given window at a specific time.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to focus.
|
|
|
|
* @param t When to set the focus to the window.
|
|
|
|
* @ingroup Ecore_X_Window_Focus_Functions
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_focus_at_time(Ecore_X_Window win, Ecore_X_Time t)
|
|
|
|
{
|
|
|
|
if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
|
|
|
|
}
|
|
|
|
|
2004-08-01 05:48:39 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
|
|
|
|
*
|
|
|
|
* Functions that change the Z order of X windows.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Raises the given window.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to raise.
|
|
|
|
* @ingroup Ecore_X_Window_Z_Order_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_raise(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
XRaiseWindow(_ecore_x_disp, win);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Lowers the given window.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The window to lower.
|
|
|
|
* @ingroup Ecore_X_Window_Z_Order_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_lower(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
XLowerWindow(_ecore_x_disp, win);
|
|
|
|
}
|
|
|
|
|
2004-08-12 04:29:19 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
|
|
|
|
*
|
|
|
|
* Functions that retrieve or changes the parent window of a window.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Moves a window to within another window at a given position.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param win The window to reparent.
|
|
|
|
* @param new_parent The new parent window.
|
|
|
|
* @param x X position within new parent window.
|
|
|
|
* @param y Y position within new parent window.
|
|
|
|
* @ingroup Ecore_X_Window_Parent_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_reparent(Ecore_X_Window win, Ecore_X_Window new_parent, int x, int y)
|
|
|
|
{
|
|
|
|
if (new_parent == 0) new_parent = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the size of the given window.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @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_Window_Geometry_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h)
|
|
|
|
{
|
|
|
|
int dummy_x, dummy_y;
|
|
|
|
|
2004-02-21 13:44:48 -08:00
|
|
|
if (win == 0)
|
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
|
|
|
|
ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
|
|
|
|
2004-02-21 13:09:13 -08:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the geometry of the given window.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @param x Pointer to an integer in which the X position is to be stored.
|
|
|
|
* @param y Pointer to an integer in which the Y position is to be stored.
|
|
|
|
* @param w Pointer to an integer in which the width is to be stored.
|
|
|
|
* @param h Pointer to an integer in which the height is to be stored.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2004-02-21 13:09:13 -08:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_geometry_get(Ecore_X_Window win, int *x, int *y, int *w, int *h)
|
|
|
|
{
|
|
|
|
if (!win)
|
|
|
|
win = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
|
2004-02-21 13:44:48 -08:00
|
|
|
ecore_x_drawable_geometry_get(win, x, y, w, h);
|
2004-02-21 13:09:13 -08:00
|
|
|
}
|
2004-02-21 13:44:48 -08:00
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the width of the border of the given window.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @return Width of the border of @p win.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2004-02-21 13:44:48 -08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ecore_x_window_border_width_get(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
return ecore_x_drawable_border_width_get(win);
|
|
|
|
}
|
|
|
|
|
2004-08-26 10:50:33 -07:00
|
|
|
/**
|
|
|
|
* Sets the width of the border of the given window.
|
|
|
|
* @param win The given window.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_border_width_set(Ecore_X_Window win, int width)
|
|
|
|
{
|
|
|
|
XSetWindowBorderWidth (_ecore_x_disp, win, width);
|
|
|
|
}
|
|
|
|
|
2004-02-21 13:44:48 -08:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the depth of the given window.
|
|
|
|
* @param win The given window.
|
|
|
|
* @return Depth of the window.
|
2004-02-21 13:44:48 -08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ecore_x_window_depth_get(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
return ecore_x_drawable_depth_get(win);
|
|
|
|
}
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
|
|
|
* To be documented.
|
|
|
|
*
|
|
|
|
* FIXME: To be fixed.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_window_cursor_show(Ecore_X_Window win, int show)
|
|
|
|
{
|
|
|
|
if (win == 0) win = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
if (!show)
|
|
|
|
{
|
|
|
|
Cursor c;
|
|
|
|
XColor cl;
|
|
|
|
Pixmap p, m;
|
|
|
|
GC gc;
|
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
|
|
|
|
m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
|
|
|
|
gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
|
|
|
|
XSetForeground(_ecore_x_disp, gc, 0);
|
|
|
|
XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
|
|
|
|
XFreeGC(_ecore_x_disp, gc);
|
|
|
|
c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
|
|
|
|
XDefineCursor(_ecore_x_disp, win, c);
|
|
|
|
XFreeCursor(_ecore_x_disp, c);
|
|
|
|
XFreePixmap(_ecore_x_disp, p);
|
|
|
|
XFreePixmap(_ecore_x_disp, m);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
XDefineCursor(_ecore_x_disp, win, 0);
|
|
|
|
}
|
|
|
|
}
|
2004-02-28 20:29:25 -08:00
|
|
|
|
2004-08-25 16:41:57 -07:00
|
|
|
void
|
|
|
|
ecore_x_window_cursor_set(Ecore_X_Window win, Ecore_X_Cursor c)
|
|
|
|
{
|
|
|
|
if (c == 0)
|
|
|
|
XUndefineCursor(_ecore_x_disp, win);
|
|
|
|
else
|
|
|
|
XDefineCursor(_ecore_x_disp, win, c);
|
|
|
|
}
|
|
|
|
|
2004-02-28 20:29:25 -08:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Finds out whether the given window is currently visible.
|
2004-08-01 05:48:39 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @return 1 if the window is visible, otherwise 0.
|
|
|
|
* @ingroup Ecore_X_Window_Visibility_Group
|
2004-02-28 20:29:25 -08:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
ecore_x_window_visible_get(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
XWindowAttributes attr;
|
|
|
|
|
|
|
|
return (XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
|
|
|
|
(attr.map_state == IsViewable));
|
|
|
|
}
|
|
|
|
|
|
|
|
static Window
|
|
|
|
_ecore_x_window_at_xy_get(Window base, int bx, int by, int x, int y)
|
|
|
|
{
|
|
|
|
Window *list = NULL;
|
|
|
|
Window parent_win = 0, child = 0, root_win = 0;
|
|
|
|
int i, wx, wy, ww, wh;
|
|
|
|
unsigned int num;
|
|
|
|
|
|
|
|
if (!ecore_x_window_visible_get(base))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
|
|
|
|
wx += bx;
|
|
|
|
wy += by;
|
|
|
|
|
|
|
|
if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
|
|
|
|
return base;
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
for (i = num - 1;; --i)
|
|
|
|
{
|
|
|
|
if ((child = _ecore_x_window_at_xy_get(list[i], wx, wy, x, y)))
|
|
|
|
{
|
|
|
|
XFree(list);
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
if (!i)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
XFree(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return base;
|
|
|
|
}
|
|
|
|
|
2004-02-29 00:15:47 -08:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the top, visible window at the given location.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param x The given X position.
|
|
|
|
* @param y The given Y position.
|
|
|
|
* @return The window at that position.
|
|
|
|
* @ingroup Ecore_X_Window_Geometry_Group
|
2004-02-29 00:15:47 -08:00
|
|
|
*/
|
2004-02-28 20:29:25 -08:00
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_window_at_xy_get(int x, int y)
|
|
|
|
{
|
|
|
|
Ecore_X_Window win, root;
|
|
|
|
|
|
|
|
/* FIXME: Proper function to determine current root/virtual root
|
|
|
|
* window missing here */
|
|
|
|
root = DefaultRootWindow(_ecore_x_disp);
|
|
|
|
|
|
|
|
ecore_x_grab();
|
|
|
|
win = _ecore_x_window_at_xy_get(root, 0, 0, x, y);
|
|
|
|
ecore_x_ungrab();
|
|
|
|
|
|
|
|
return win ? win : root;
|
|
|
|
}
|
|
|
|
|
2004-02-29 00:15:47 -08:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the parent window of the given window.
|
2004-08-12 04:29:19 -07:00
|
|
|
* @param win The given window.
|
|
|
|
* @return The parent window of @p win.
|
|
|
|
* @ingroup Ecore_X_Window_Parent_Group
|
2004-02-29 00:15:47 -08:00
|
|
|
*/
|
2004-02-28 20:37:18 -08:00
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_window_parent_get(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
Window root, parent, *children = NULL;
|
|
|
|
unsigned int num;
|
|
|
|
|
|
|
|
if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
|
|
|
|
return 0;
|
|
|
|
if (children)
|
|
|
|
XFree(children);
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|