2005-02-10 04:14:37 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2004-09-21 12:18:45 -07:00
|
|
|
/*
|
|
|
|
* Various ICCCM related functions.
|
2004-10-22 19:19:19 -07:00
|
|
|
*
|
|
|
|
* This is ALL the code involving anything ICCCM related. for both WM and
|
|
|
|
* client.
|
2004-09-21 12:18:45 -07:00
|
|
|
*/
|
|
|
|
#include "Ecore.h"
|
|
|
|
#include "ecore_x_private.h"
|
|
|
|
#include "Ecore_X.h"
|
2004-12-04 02:10:29 -08:00
|
|
|
#include "Ecore_X_Atoms.h"
|
|
|
|
|
|
|
|
/* Atoms */
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_STATE = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_DELETE_WINDOW = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_TAKE_FOCUS = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_PROTOCOLS = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_CLASS = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_NAME = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_COMMAND = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_ICON_NAME = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_CLIENT_MACHINE = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_CHANGE_STATE = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_COLORMAP_WINDOWS = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_WINDOW_ROLE = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_HINTS = 0;
|
2004-12-05 00:29:10 -08:00
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_NORMAL_HINTS = 0;
|
2004-12-04 02:10:29 -08:00
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_CLIENT_LEADER = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_TRANSIENT_FOR = 0;
|
|
|
|
Ecore_X_Atom ECORE_X_ATOM_WM_SAVE_YOURSELF = 0;
|
2004-09-21 12:18:45 -07:00
|
|
|
|
2004-12-05 00:29:10 -08:00
|
|
|
void
|
|
|
|
ecore_x_icccm_init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
ECORE_X_ATOM_WM_STATE = XInternAtom(_ecore_x_disp, "WM_STATE", False);
|
|
|
|
ECORE_X_ATOM_WM_DELETE_WINDOW =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_DELETE_WINDOW", False);
|
|
|
|
ECORE_X_ATOM_WM_TAKE_FOCUS =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_TAKE_FOCUS", False);
|
|
|
|
ECORE_X_ATOM_WM_PROTOCOLS =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_PROTOCOLS", False);
|
|
|
|
ECORE_X_ATOM_WM_CLASS = XInternAtom(_ecore_x_disp, "WM_CLASS", False);
|
|
|
|
ECORE_X_ATOM_WM_NAME = XInternAtom(_ecore_x_disp, "WM_NAME", False);
|
|
|
|
ECORE_X_ATOM_WM_COMMAND = XInternAtom(_ecore_x_disp, "WM_COMMAND", False);
|
|
|
|
ECORE_X_ATOM_WM_ICON_NAME =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_ICON_NAME", False);
|
|
|
|
ECORE_X_ATOM_WM_CLIENT_MACHINE =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_CLIENT_MACHINE", False);
|
|
|
|
ECORE_X_ATOM_WM_CHANGE_STATE =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_CHANGE_STATE", False);
|
|
|
|
ECORE_X_ATOM_WM_COLORMAP_WINDOWS =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_COLORMAP_WINDOWS", False);
|
|
|
|
ECORE_X_ATOM_WM_WINDOW_ROLE =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_WINDOW_ROLE", False);
|
|
|
|
ECORE_X_ATOM_WM_HINTS = XInternAtom(_ecore_x_disp, "WM_HINTS", False);
|
|
|
|
ECORE_X_ATOM_WM_NORMAL_HINTS =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_NORMAL_HINTS", False);
|
|
|
|
ECORE_X_ATOM_WM_CLIENT_LEADER =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_CLIENT_LEADER", False);
|
|
|
|
ECORE_X_ATOM_WM_TRANSIENT_FOR =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_TRANSIENT_FOR", False);
|
|
|
|
ECORE_X_ATOM_WM_SAVE_YOURSELF =
|
|
|
|
XInternAtom(_ecore_x_disp, "WM_SAVE_YOURSELF", False);
|
|
|
|
}
|
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
void
|
|
|
|
ecore_x_icccm_state_set(Ecore_X_Window win, Ecore_X_Window_State_Hint state)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
|
|
|
unsigned long c[2];
|
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
|
2004-12-04 02:10:29 -08:00
|
|
|
c[0] = WithdrawnState;
|
2004-10-21 20:41:49 -07:00
|
|
|
else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
|
2004-12-04 02:10:29 -08:00
|
|
|
c[0] = NormalState;
|
2004-10-21 20:41:49 -07:00
|
|
|
else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
|
2004-12-04 02:10:29 -08:00
|
|
|
c[0] = IconicState;
|
2005-03-20 10:25:47 -08:00
|
|
|
c[1] = None;
|
2004-12-04 02:10:29 -08:00
|
|
|
XChangeProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_STATE,
|
|
|
|
ECORE_X_ATOM_WM_STATE, 32, PropModeReplace,
|
2004-09-21 12:18:45 -07:00
|
|
|
(unsigned char *)c, 2);
|
|
|
|
}
|
|
|
|
|
2005-02-15 03:24:25 -08:00
|
|
|
Ecore_X_Window_State_Hint
|
|
|
|
ecore_x_icccm_state_get(Ecore_X_Window win)
|
|
|
|
{
|
|
|
|
unsigned char *prop_ret;
|
|
|
|
Atom type_ret;
|
|
|
|
unsigned long bytes_after, num_ret;
|
|
|
|
int format_ret;
|
|
|
|
Ecore_X_Window_State_Hint hint;
|
|
|
|
|
2005-03-01 23:06:44 -08:00
|
|
|
hint = ECORE_X_WINDOW_STATE_HINT_NONE;
|
2005-02-15 03:24:25 -08:00
|
|
|
XGetWindowProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_STATE,
|
|
|
|
0, 0x7fffffff, False, ECORE_X_ATOM_WM_STATE,
|
|
|
|
&type_ret, &format_ret, &num_ret, &bytes_after,
|
|
|
|
&prop_ret);
|
|
|
|
if ((prop_ret) && (num_ret == 2))
|
|
|
|
{
|
|
|
|
if (prop_ret[0] == WithdrawnState)
|
|
|
|
hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
|
|
|
|
else if (prop_ret[0] == NormalState)
|
|
|
|
hint = ECORE_X_WINDOW_STATE_HINT_NORMAL;
|
|
|
|
else if (prop_ret[0] == IconicState)
|
|
|
|
hint = ECORE_X_WINDOW_STATE_HINT_ICONIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prop_ret)
|
|
|
|
XFree(prop_ret);
|
|
|
|
|
|
|
|
return hint;
|
|
|
|
}
|
|
|
|
|
2004-09-21 12:18:45 -07:00
|
|
|
void
|
2004-10-22 19:19:19 -07:00
|
|
|
ecore_x_icccm_delete_window_send(Ecore_X_Window win, Ecore_X_Time t)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
|
2004-12-29 04:36:25 -08:00
|
|
|
ECORE_X_EVENT_MASK_NONE,
|
2004-12-04 02:10:29 -08:00
|
|
|
ECORE_X_ATOM_WM_DELETE_WINDOW,
|
2004-12-25 05:13:57 -08:00
|
|
|
t, 0, 0, 0);
|
2004-09-21 12:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-22 19:19:19 -07:00
|
|
|
ecore_x_icccm_take_focus_send(Ecore_X_Window win, Ecore_X_Time t)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
|
2004-12-29 04:36:25 -08:00
|
|
|
ECORE_X_EVENT_MASK_NONE,
|
2004-12-04 02:10:29 -08:00
|
|
|
ECORE_X_ATOM_WM_TAKE_FOCUS,
|
2004-12-25 05:13:57 -08:00
|
|
|
t, 0, 0, 0);
|
2004-09-21 12:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-22 19:19:19 -07:00
|
|
|
ecore_x_icccm_save_yourself_send(Ecore_X_Window win, Ecore_X_Time t)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
|
2004-12-29 04:36:25 -08:00
|
|
|
ECORE_X_EVENT_MASK_NONE,
|
2004-12-04 02:10:29 -08:00
|
|
|
ECORE_X_ATOM_WM_SAVE_YOURSELF,
|
2004-12-25 05:13:57 -08:00
|
|
|
t, 0, 0, 0);
|
2004-09-21 12:18:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_icccm_move_resize_send(Ecore_X_Window win, int x, int y, int w, int h)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2004-10-21 20:41:49 -07:00
|
|
|
XEvent ev;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
ev.type = ConfigureNotify;
|
|
|
|
ev.xconfigure.display = _ecore_x_disp;
|
|
|
|
ev.xconfigure.event = win;
|
|
|
|
ev.xconfigure.window = win;
|
|
|
|
ev.xconfigure.x = x;
|
|
|
|
ev.xconfigure.y = y;
|
|
|
|
ev.xconfigure.width = w;
|
|
|
|
ev.xconfigure.height = h;
|
|
|
|
ev.xconfigure.border_width = 0;
|
2005-01-06 01:08:20 -08:00
|
|
|
ev.xconfigure.above = None;
|
2004-10-21 20:41:49 -07:00
|
|
|
ev.xconfigure.override_redirect = False;
|
|
|
|
XSendEvent(_ecore_x_disp, win, False, StructureNotifyMask, &ev);
|
2004-12-04 02:10:29 -08:00
|
|
|
}
|
2004-09-21 12:18:45 -07:00
|
|
|
|
2004-10-22 19:19:19 -07:00
|
|
|
void
|
|
|
|
ecore_x_icccm_hints_set(Ecore_X_Window win,
|
|
|
|
int accepts_focus,
|
|
|
|
Ecore_X_Window_State_Hint initial_state,
|
|
|
|
Ecore_X_Pixmap icon_pixmap,
|
|
|
|
Ecore_X_Pixmap icon_mask,
|
|
|
|
Ecore_X_Window icon_window,
|
2004-12-04 02:10:29 -08:00
|
|
|
Ecore_X_Window window_group, int is_urgent)
|
2004-10-22 19:19:19 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
XWMHints *hints;
|
|
|
|
|
2004-10-22 19:19:19 -07:00
|
|
|
hints = XAllocWMHints();
|
2004-12-04 02:10:29 -08:00
|
|
|
if (!hints)
|
|
|
|
return;
|
|
|
|
|
2004-10-22 19:19:19 -07:00
|
|
|
hints->flags = InputHint | StateHint;
|
|
|
|
hints->input = accepts_focus;
|
|
|
|
if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
|
2004-12-04 02:10:29 -08:00
|
|
|
hints->initial_state = WithdrawnState;
|
2004-10-22 19:19:19 -07:00
|
|
|
else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
|
2004-12-04 02:10:29 -08:00
|
|
|
hints->initial_state = NormalState;
|
2004-10-22 19:19:19 -07:00
|
|
|
else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
|
2004-12-04 02:10:29 -08:00
|
|
|
hints->initial_state = IconicState;
|
2004-10-22 19:19:19 -07:00
|
|
|
if (icon_pixmap != 0)
|
|
|
|
{
|
|
|
|
hints->icon_pixmap = icon_pixmap;
|
|
|
|
hints->flags |= IconPixmapHint;
|
|
|
|
}
|
|
|
|
if (icon_mask != 0)
|
|
|
|
{
|
|
|
|
hints->icon_mask = icon_mask;
|
|
|
|
hints->flags |= IconMaskHint;
|
|
|
|
}
|
|
|
|
if (icon_window != 0)
|
|
|
|
{
|
|
|
|
hints->icon_window = icon_window;
|
|
|
|
hints->flags |= IconWindowHint;
|
|
|
|
}
|
|
|
|
if (window_group != 0)
|
|
|
|
{
|
|
|
|
hints->window_group = window_group;
|
|
|
|
hints->flags |= WindowGroupHint;
|
|
|
|
}
|
|
|
|
if (is_urgent)
|
2004-12-04 02:10:29 -08:00
|
|
|
hints->flags |= XUrgencyHint;
|
2004-10-22 19:19:19 -07:00
|
|
|
XSetWMHints(_ecore_x_disp, win, hints);
|
|
|
|
XFree(hints);
|
|
|
|
}
|
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
int
|
2004-10-22 19:19:19 -07:00
|
|
|
ecore_x_icccm_hints_get(Ecore_X_Window win,
|
|
|
|
int *accepts_focus,
|
2005-02-15 03:24:25 -08:00
|
|
|
Ecore_X_Window_State_Hint *initial_state,
|
|
|
|
Ecore_X_Pixmap *icon_pixmap,
|
|
|
|
Ecore_X_Pixmap *icon_mask,
|
|
|
|
Ecore_X_Window *icon_window,
|
|
|
|
Ecore_X_Window *window_group, int *is_urgent)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2005-02-15 03:24:25 -08:00
|
|
|
XWMHints *hints;
|
2004-10-22 19:19:19 -07:00
|
|
|
|
2004-12-04 02:10:29 -08:00
|
|
|
if (accepts_focus)
|
|
|
|
*accepts_focus = 0;
|
|
|
|
if (initial_state)
|
|
|
|
*initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
|
|
|
|
if (icon_pixmap)
|
|
|
|
*icon_pixmap = 0;
|
|
|
|
if (icon_mask)
|
|
|
|
*icon_mask = 0;
|
|
|
|
if (icon_window)
|
|
|
|
*icon_window = 0;
|
|
|
|
if (window_group)
|
|
|
|
*window_group = 0;
|
|
|
|
if (is_urgent)
|
|
|
|
*is_urgent = 0;
|
2004-10-21 20:41:49 -07:00
|
|
|
hints = XGetWMHints(_ecore_x_disp, win);
|
|
|
|
if (hints)
|
|
|
|
{
|
|
|
|
if ((hints->flags & InputHint) && (accepts_focus))
|
|
|
|
{
|
|
|
|
if (hints->input)
|
2004-12-04 02:10:29 -08:00
|
|
|
*accepts_focus = 1;
|
2004-10-21 20:41:49 -07:00
|
|
|
else
|
2004-12-04 02:10:29 -08:00
|
|
|
*accepts_focus = 0;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
|
|
|
if ((hints->flags & StateHint) && (initial_state))
|
|
|
|
{
|
|
|
|
if (hints->initial_state == WithdrawnState)
|
2004-12-04 02:10:29 -08:00
|
|
|
*initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
|
2004-10-21 20:41:49 -07:00
|
|
|
else if (hints->initial_state == NormalState)
|
2004-12-04 02:10:29 -08:00
|
|
|
*initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
|
2004-10-21 20:41:49 -07:00
|
|
|
else if (hints->initial_state == IconicState)
|
2004-12-04 02:10:29 -08:00
|
|
|
*initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
|
|
|
if ((hints->flags & IconPixmapHint) && (icon_pixmap))
|
|
|
|
{
|
|
|
|
*icon_pixmap = hints->icon_pixmap;
|
|
|
|
}
|
|
|
|
if ((hints->flags & IconMaskHint) && (icon_mask))
|
|
|
|
{
|
|
|
|
*icon_mask = hints->icon_pixmap;
|
|
|
|
}
|
|
|
|
if ((hints->flags & IconWindowHint) && (icon_window))
|
|
|
|
{
|
|
|
|
*icon_window = hints->icon_window;
|
|
|
|
}
|
|
|
|
if ((hints->flags & WindowGroupHint) && (window_group))
|
|
|
|
{
|
|
|
|
*window_group = hints->window_group;
|
|
|
|
}
|
2004-10-22 19:19:19 -07:00
|
|
|
if ((hints->flags & XUrgencyHint) && (is_urgent))
|
|
|
|
{
|
|
|
|
*is_urgent = 1;
|
|
|
|
}
|
2004-10-21 20:41:49 -07:00
|
|
|
XFree(hints);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2004-09-21 12:18:45 -07:00
|
|
|
}
|
|
|
|
|
2004-11-01 20:03:27 -08:00
|
|
|
void
|
|
|
|
ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win,
|
2004-12-04 02:10:29 -08:00
|
|
|
int request_pos,
|
2004-11-01 20:03:27 -08:00
|
|
|
Ecore_X_Gravity gravity,
|
|
|
|
int min_w, int min_h,
|
|
|
|
int max_w, int max_h,
|
|
|
|
int base_w, int base_h,
|
|
|
|
int step_x, int step_y,
|
2004-12-04 02:10:29 -08:00
|
|
|
double min_aspect, double max_aspect)
|
2004-11-01 20:03:27 -08:00
|
|
|
{
|
|
|
|
/* FIXME: working here */
|
2004-12-04 02:10:29 -08:00
|
|
|
XSizeHints hint;
|
|
|
|
|
2004-11-01 20:03:27 -08:00
|
|
|
hint.flags = 0;
|
|
|
|
if (request_pos)
|
|
|
|
{
|
|
|
|
hint.flags |= USPosition;
|
|
|
|
}
|
|
|
|
if (gravity != ECORE_X_GRAVITY_NW)
|
|
|
|
{
|
|
|
|
hint.flags |= PWinGravity;
|
|
|
|
hint.win_gravity = gravity;
|
|
|
|
}
|
|
|
|
if ((min_w > 0) || (min_h > 0))
|
|
|
|
{
|
|
|
|
hint.flags |= PMinSize;
|
|
|
|
hint.min_width = min_w;
|
|
|
|
hint.min_height = min_h;
|
|
|
|
}
|
|
|
|
if ((max_w > 0) || (max_h > 0))
|
|
|
|
{
|
|
|
|
hint.flags |= PMaxSize;
|
|
|
|
hint.max_width = max_w;
|
|
|
|
hint.max_height = max_h;
|
|
|
|
}
|
|
|
|
if ((base_w > 0) || (base_h > 0))
|
|
|
|
{
|
|
|
|
hint.flags |= PBaseSize;
|
|
|
|
hint.base_width = base_w;
|
|
|
|
hint.base_height = base_h;
|
|
|
|
}
|
|
|
|
if ((step_x > 1) || (step_y > 1))
|
|
|
|
{
|
|
|
|
hint.flags |= PResizeInc;
|
|
|
|
hint.width_inc = step_x;
|
|
|
|
hint.height_inc = step_y;
|
|
|
|
}
|
|
|
|
if ((min_aspect > 0.0) || (max_aspect > 0.0))
|
|
|
|
{
|
|
|
|
hint.flags |= PAspect;
|
|
|
|
hint.min_aspect.x = min_aspect * 10000;
|
|
|
|
hint.min_aspect.x = 10000;
|
|
|
|
hint.max_aspect.x = max_aspect * 10000;
|
|
|
|
hint.max_aspect.x = 10000;
|
|
|
|
}
|
|
|
|
XSetWMNormalHints(_ecore_x_disp, win, &hint);
|
|
|
|
}
|
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
int
|
2004-11-01 20:03:27 -08:00
|
|
|
ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win,
|
|
|
|
int *request_pos,
|
2004-12-04 02:10:29 -08:00
|
|
|
Ecore_X_Gravity * gravity,
|
2004-11-01 20:03:27 -08:00
|
|
|
int *min_w, int *min_h,
|
|
|
|
int *max_w, int *max_h,
|
|
|
|
int *base_w, int *base_h,
|
|
|
|
int *step_x, int *step_y,
|
2004-12-04 02:10:29 -08:00
|
|
|
double *min_aspect, double *max_aspect)
|
2004-09-21 12:18:45 -07:00
|
|
|
{
|
2004-10-21 20:41:49 -07:00
|
|
|
XSizeHints hint;
|
|
|
|
long mask;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
|
|
|
int minw = 0, minh = 0;
|
|
|
|
int maxw = 32767, maxh = 32767;
|
2005-04-19 06:39:02 -07:00
|
|
|
int basew = -1, baseh = -1;
|
2004-12-04 02:10:29 -08:00
|
|
|
int stepx = 1, stepy = 1;
|
|
|
|
double mina = 0.0, maxa = 0.0;
|
|
|
|
|
|
|
|
if (XGetWMNormalHints(_ecore_x_disp, win, &hint, &mask) < Success)
|
|
|
|
return 0;
|
2004-10-21 20:41:49 -07:00
|
|
|
if ((hint.flags & USPosition) || ((hint.flags & PPosition)))
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
if (request_pos)
|
|
|
|
*request_pos = 1;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
if (request_pos)
|
|
|
|
*request_pos = 0;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
2004-11-01 20:03:27 -08:00
|
|
|
if (hint.flags & PWinGravity)
|
2004-10-21 20:41:49 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
if (gravity)
|
|
|
|
*gravity = hint.win_gravity;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
2004-11-01 20:03:27 -08:00
|
|
|
else
|
2004-10-21 20:41:49 -07:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
if (gravity)
|
|
|
|
*gravity = ECORE_X_GRAVITY_NW;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
2004-11-01 20:03:27 -08:00
|
|
|
if (hint.flags & PMinSize)
|
|
|
|
{
|
|
|
|
minw = hint.min_width;
|
|
|
|
minh = hint.min_height;
|
|
|
|
}
|
|
|
|
if (hint.flags & PMaxSize)
|
2004-10-21 20:41:49 -07:00
|
|
|
{
|
2004-11-01 20:03:27 -08:00
|
|
|
maxw = hint.max_width;
|
|
|
|
maxh = hint.max_height;
|
2004-12-04 02:10:29 -08:00
|
|
|
if (maxw < minw)
|
|
|
|
maxw = minw;
|
|
|
|
if (maxh < minh)
|
|
|
|
maxh = minh;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
|
|
|
if (hint.flags & PBaseSize)
|
|
|
|
{
|
2004-11-01 20:03:27 -08:00
|
|
|
basew = hint.base_width;
|
|
|
|
baseh = hint.base_height;
|
2004-12-04 02:10:29 -08:00
|
|
|
if (basew > minw)
|
|
|
|
minw = basew;
|
|
|
|
if (baseh > minh)
|
|
|
|
minh = baseh;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
2004-11-01 20:03:27 -08:00
|
|
|
if (hint.flags & PResizeInc)
|
2004-10-21 20:41:49 -07:00
|
|
|
{
|
2004-11-01 20:03:27 -08:00
|
|
|
stepx = hint.width_inc;
|
|
|
|
stepy = hint.height_inc;
|
2004-12-04 02:10:29 -08:00
|
|
|
if (stepx < 1)
|
|
|
|
stepx = 1;
|
|
|
|
if (stepy < 1)
|
|
|
|
stepy = 1;
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
|
|
|
if (hint.flags & PAspect)
|
|
|
|
{
|
2004-11-01 20:03:27 -08:00
|
|
|
if (hint.min_aspect.y > 0)
|
2004-12-04 02:10:29 -08:00
|
|
|
mina = ((double)hint.min_aspect.x) / ((double)hint.min_aspect.y);
|
2004-11-01 20:03:27 -08:00
|
|
|
if (hint.max_aspect.y > 0)
|
2004-12-04 02:10:29 -08:00
|
|
|
maxa = ((double)hint.max_aspect.x) / ((double)hint.max_aspect.y);
|
2004-10-21 20:41:49 -07:00
|
|
|
}
|
2004-12-04 02:10:29 -08:00
|
|
|
if (min_w)
|
|
|
|
*min_w = minw;
|
|
|
|
if (min_h)
|
|
|
|
*min_h = minh;
|
|
|
|
if (max_w)
|
|
|
|
*max_w = maxw;
|
|
|
|
if (max_h)
|
|
|
|
*max_h = maxh;
|
|
|
|
if (base_w)
|
|
|
|
*base_w = basew;
|
|
|
|
if (base_h)
|
|
|
|
*base_h = baseh;
|
|
|
|
if (step_x)
|
|
|
|
*step_x = stepx;
|
|
|
|
if (step_y)
|
|
|
|
*step_y = stepy;
|
|
|
|
if (min_aspect)
|
|
|
|
*min_aspect = mina;
|
|
|
|
if (max_aspect)
|
|
|
|
*max_aspect = maxa;
|
2004-10-21 20:41:49 -07:00
|
|
|
return 1;
|
2004-09-21 12:18:45 -07:00
|
|
|
}
|
2004-10-21 20:41:49 -07:00
|
|
|
|
2004-11-23 07:17:56 -08:00
|
|
|
void
|
|
|
|
ecore_x_icccm_title_set(Ecore_X_Window win, const char *t)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
char *list[1];
|
|
|
|
XTextProperty xprop;
|
|
|
|
int ret;
|
|
|
|
|
2004-11-23 07:17:56 -08:00
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
|
|
|
list[0] = strdup(t);
|
2004-12-04 02:10:29 -08:00
|
|
|
ret =
|
|
|
|
Xutf8TextListToTextProperty(_ecore_x_disp, list, 1, XUTF8StringStyle,
|
|
|
|
&xprop);
|
2004-11-23 07:17:56 -08:00
|
|
|
#else
|
|
|
|
list[0] = strdup(t);
|
2004-12-04 02:10:29 -08:00
|
|
|
ret =
|
|
|
|
XmbTextListToTextProperty(_ecore_x_disp, list, 1, XStdICCTextStyle,
|
|
|
|
&xprop);
|
2004-11-23 07:17:56 -08:00
|
|
|
#endif
|
|
|
|
if (ret >= Success)
|
|
|
|
{
|
|
|
|
XSetWMName(_ecore_x_disp, win, &xprop);
|
|
|
|
XFree(xprop.value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (XStringListToTextProperty(list, 1, &xprop) >= Success)
|
|
|
|
{
|
|
|
|
XSetWMName(_ecore_x_disp, win, &xprop);
|
|
|
|
XFree(xprop.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(list[0]);
|
|
|
|
}
|
|
|
|
|
2004-12-04 02:10:29 -08:00
|
|
|
char *
|
2004-11-23 07:17:56 -08:00
|
|
|
ecore_x_icccm_title_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
XTextProperty xprop;
|
|
|
|
|
2004-11-23 23:27:58 -08:00
|
|
|
if (XGetWMName(_ecore_x_disp, win, &xprop) >= Success)
|
2004-11-23 07:17:56 -08:00
|
|
|
{
|
|
|
|
if (xprop.value)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
char **list = NULL;
|
|
|
|
char *t = NULL;
|
|
|
|
int num = 0;
|
2005-02-10 04:14:37 -08:00
|
|
|
int ret;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
2005-02-10 04:14:37 -08:00
|
|
|
if (xprop.encoding == ECORE_X_ATOM_UTF8_STRING)
|
2004-11-23 07:17:56 -08:00
|
|
|
{
|
|
|
|
t = strdup(xprop.value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
|
2005-02-10 04:14:37 -08:00
|
|
|
/* convert to utf8 */
|
2004-11-23 07:17:56 -08:00
|
|
|
#ifdef X_HAVE_UTF8_STRING
|
2004-12-04 02:10:29 -08:00
|
|
|
ret = Xutf8TextPropertyToTextList(_ecore_x_disp, &xprop,
|
2004-11-23 07:17:56 -08:00
|
|
|
&list, &num);
|
2004-12-04 02:10:29 -08:00
|
|
|
#else
|
|
|
|
ret = XmbTextPropertyToTextList(_ecore_x_disp, &xprop,
|
2004-11-23 07:17:56 -08:00
|
|
|
&list, &num);
|
2004-12-04 02:10:29 -08:00
|
|
|
#endif
|
2005-02-10 04:14:37 -08:00
|
|
|
|
2004-11-23 07:17:56 -08:00
|
|
|
if ((ret == XLocaleNotSupported) ||
|
2004-12-04 02:10:29 -08:00
|
|
|
(ret == XNoMemory) || (ret == XConverterNotFound))
|
2004-11-23 07:17:56 -08:00
|
|
|
{
|
|
|
|
t = strdup(xprop.value);
|
|
|
|
}
|
|
|
|
else if (ret >= Success)
|
|
|
|
{
|
|
|
|
if ((num >= 1) && (list))
|
|
|
|
{
|
|
|
|
t = strdup(list[0]);
|
|
|
|
}
|
2004-12-04 02:10:29 -08:00
|
|
|
if (list)
|
2005-02-10 04:14:37 -08:00
|
|
|
XFreeStringList(list);
|
2004-11-23 07:17:56 -08:00
|
|
|
}
|
|
|
|
}
|
2005-02-10 04:14:37 -08:00
|
|
|
|
2004-11-23 07:17:56 -08:00
|
|
|
XFree(xprop.value);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-25 22:42:24 -08:00
|
|
|
/**
|
|
|
|
* Set or unset a wm protocol property.
|
|
|
|
* @param win The Window
|
|
|
|
* @param protocol The protocol to enable/disable
|
|
|
|
* @param on On/Off
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_protocol_set(Ecore_X_Window win,
|
2004-12-04 02:10:29 -08:00
|
|
|
Ecore_X_WM_Protocol protocol, int on)
|
2004-11-25 22:42:24 -08:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
Atom *protos = NULL;
|
|
|
|
Atom proto;
|
|
|
|
int protos_count = 0;
|
|
|
|
int already_set = 0;
|
|
|
|
int i;
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
/* Check for invalid values */
|
2005-03-01 23:06:44 -08:00
|
|
|
if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
|
2004-11-25 22:42:24 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
proto = _ecore_x_atoms_wm_protocols[protocol];
|
|
|
|
|
|
|
|
if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
protos = NULL;
|
|
|
|
protos_count = 0;
|
|
|
|
}
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
for (i = 0; i < protos_count; i++)
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
if (protos[i] == proto)
|
|
|
|
{
|
|
|
|
already_set = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
if (on)
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
2005-04-10 03:20:18 -07:00
|
|
|
Atom *new_protos = NULL;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
|
|
|
if (already_set)
|
|
|
|
goto leave;
|
|
|
|
new_protos = malloc((protos_count + 1) * sizeof(Atom));
|
|
|
|
if (!new_protos)
|
|
|
|
goto leave;
|
|
|
|
for (i = 0; i < protos_count; i++)
|
|
|
|
new_protos[i] = protos[i];
|
|
|
|
new_protos[protos_count] = proto;
|
|
|
|
XSetWMProtocols(_ecore_x_disp, win, new_protos, protos_count + 1);
|
|
|
|
free(new_protos);
|
|
|
|
}
|
2004-11-25 22:42:24 -08:00
|
|
|
else
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
if (!already_set)
|
|
|
|
goto leave;
|
|
|
|
for (i = 0; i < protos_count; i++)
|
|
|
|
{
|
|
|
|
if (protos[i] == proto)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = i + 1; j < protos_count; j++)
|
|
|
|
protos[j - 1] = protos[j];
|
|
|
|
if (protos_count > 1)
|
|
|
|
XSetWMProtocols(_ecore_x_disp, win, protos,
|
|
|
|
protos_count - 1);
|
|
|
|
else
|
|
|
|
XDeleteProperty(_ecore_x_disp, win,
|
|
|
|
ECORE_X_ATOM_WM_PROTOCOLS);
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
leave:
|
2004-11-25 22:42:24 -08:00
|
|
|
if (protos)
|
|
|
|
XFree(protos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether a protocol is set for a window.
|
|
|
|
* @param win The Window
|
|
|
|
* @param protocol The protocol to query
|
|
|
|
* @return 1 if the protocol is set, else 0.
|
|
|
|
*/
|
|
|
|
int
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol)
|
2004-11-25 22:42:24 -08:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
Atom proto, *protos = NULL;
|
|
|
|
int i, ret = 0, protos_count = 0;
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
/* check for invalid values */
|
2005-03-01 23:06:44 -08:00
|
|
|
if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
|
2004-11-25 22:42:24 -08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
proto = _ecore_x_atoms_wm_protocols[protocol];
|
|
|
|
|
|
|
|
if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
|
|
|
|
return 0;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
2004-11-25 22:42:24 -08:00
|
|
|
for (i = 0; i < protos_count; i++)
|
|
|
|
if (protos[i] == proto)
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
XFree(protos);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a window name & class.
|
|
|
|
* @param win The window
|
|
|
|
* @param n The name string
|
|
|
|
* @param c The class string
|
|
|
|
*
|
|
|
|
* Set a window name * class
|
|
|
|
*/
|
|
|
|
void
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_icccm_name_class_set(Ecore_X_Window win, const char *n, const char *c)
|
2004-11-25 22:42:24 -08:00
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
XClassHint *xch;
|
2004-11-25 22:42:24 -08:00
|
|
|
|
|
|
|
xch = XAllocClassHint();
|
|
|
|
if (!xch)
|
|
|
|
return;
|
|
|
|
xch->res_name = (char *)n;
|
|
|
|
xch->res_class = (char *)c;
|
|
|
|
XSetClassHint(_ecore_x_disp, win, xch);
|
|
|
|
XFree(xch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a window client machine string.
|
|
|
|
* @param win The window
|
|
|
|
* @return The windows client machine string
|
|
|
|
*
|
|
|
|
* Return the client machine of a window. String must be free'd when done with.
|
|
|
|
*/
|
2004-12-04 02:10:29 -08:00
|
|
|
char *
|
2004-11-25 22:42:24 -08:00
|
|
|
ecore_x_icccm_client_machine_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
char *name;
|
2004-11-25 22:42:24 -08:00
|
|
|
|
2004-12-04 02:10:29 -08:00
|
|
|
name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_CLIENT_MACHINE);
|
2004-11-25 22:42:24 -08:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the WM_COMMAND property for @a win.
|
|
|
|
*
|
|
|
|
* @param win The window.
|
|
|
|
* @param argc Number of arguments.
|
|
|
|
* @param argv Arguments.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_command_set(Ecore_X_Window win, int argc, char **argv)
|
|
|
|
{
|
|
|
|
XSetCommand(_ecore_x_disp, win, argv, argc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the WM_COMMAND property for @a win.
|
|
|
|
*
|
|
|
|
* Return the command of a window. String must be free'd when done with.
|
|
|
|
*
|
|
|
|
* @param win The window.
|
|
|
|
* @param argc Number of arguments.
|
|
|
|
* @param argv Arguments.
|
|
|
|
*/
|
|
|
|
void
|
2004-11-29 14:30:14 -08:00
|
|
|
ecore_x_icccm_command_get(Ecore_X_Window win, int *argc, char ***argv)
|
2004-11-25 22:42:24 -08:00
|
|
|
{
|
|
|
|
XGetCommand(_ecore_x_disp, win, argv, argc);
|
|
|
|
}
|
|
|
|
|
2004-11-25 23:28:51 -08:00
|
|
|
/**
|
|
|
|
* Set a window icon name.
|
|
|
|
* @param win The window
|
|
|
|
* @param t The icon name string
|
|
|
|
*
|
|
|
|
* Set a window icon name
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_icon_name_set(Ecore_X_Window win, const char *t)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_ICON_NAME, (char *)t);
|
|
|
|
ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_ICON_NAME,
|
2004-11-25 23:28:51 -08:00
|
|
|
(char *)t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a window icon name.
|
|
|
|
* @param win The window
|
|
|
|
* @return The windows icon name string
|
|
|
|
*
|
|
|
|
* Return the icon name of a window. String must be free'd when done with.
|
|
|
|
*/
|
2004-12-04 02:10:29 -08:00
|
|
|
char *
|
2004-11-25 23:28:51 -08:00
|
|
|
ecore_x_icccm_icon_name_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
char *name;
|
2004-11-25 23:28:51 -08:00
|
|
|
|
2004-12-04 02:10:29 -08:00
|
|
|
name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_WM_ICON_NAME);
|
|
|
|
if (!name)
|
|
|
|
name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_ICON_NAME);
|
2004-11-25 23:28:51 -08:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a subwindow to the list of windows that need a different colormap installed.
|
|
|
|
* @param win The toplevel window
|
|
|
|
* @param subwin The subwindow to be added to the colormap windows list
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_colormap_window_set(Ecore_X_Window win, Ecore_X_Window subwin)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
int num = 0, i;
|
|
|
|
unsigned char *old_data = NULL;
|
|
|
|
unsigned char *data = NULL;
|
|
|
|
Window *oldset = NULL;
|
|
|
|
Window *newset = NULL;
|
|
|
|
|
|
|
|
if (!ecore_x_window_prop_property_get(win,
|
|
|
|
ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
|
|
|
|
XA_WINDOW, 32, &old_data, &num))
|
|
|
|
{
|
|
|
|
newset = calloc(1, sizeof(Window));
|
|
|
|
if (!newset)
|
|
|
|
return;
|
|
|
|
newset[0] = subwin;
|
|
|
|
num = 1;
|
|
|
|
data = (unsigned char *)newset;
|
|
|
|
}
|
2004-11-25 23:28:51 -08:00
|
|
|
else
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
newset = calloc(num + 1, sizeof(Window));
|
|
|
|
oldset = (Window *) old_data;
|
|
|
|
if (!newset)
|
|
|
|
return;
|
|
|
|
for (i = 0; i < num; ++i)
|
|
|
|
{
|
|
|
|
if (oldset[i] == subwin)
|
|
|
|
{
|
|
|
|
XFree(old_data);
|
|
|
|
free(newset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
newset[i] = oldset[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
newset[num++] = subwin;
|
|
|
|
XFree(old_data);
|
|
|
|
data = (unsigned char *)newset;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecore_x_window_prop_property_set(win,
|
|
|
|
ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
|
|
|
|
XA_WINDOW, 32, data, num);
|
2004-11-25 23:28:51 -08:00
|
|
|
free(newset);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a window from the list of colormap windows.
|
|
|
|
* @param win The toplevel window
|
|
|
|
* @param subwin The window to be removed from the colormap window list.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_colormap_window_unset(Ecore_X_Window win, Ecore_X_Window subwin)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
int num = 0, i, j, k = 0;
|
|
|
|
unsigned char *old_data = NULL;
|
|
|
|
unsigned char *data = NULL;
|
|
|
|
Window *oldset = NULL;
|
|
|
|
Window *newset = NULL;
|
|
|
|
|
|
|
|
if (!ecore_x_window_prop_property_get(win,
|
|
|
|
ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
|
|
|
|
XA_WINDOW, 32, &old_data, &num))
|
2004-11-25 23:28:51 -08:00
|
|
|
return;
|
2004-11-25 22:42:24 -08:00
|
|
|
|
2004-11-25 23:28:51 -08:00
|
|
|
oldset = (Window *) old_data;
|
|
|
|
for (i = 0; i < num; i++)
|
2004-12-04 02:10:29 -08:00
|
|
|
{
|
|
|
|
if (oldset[i] == subwin)
|
|
|
|
{
|
|
|
|
if (num == 1)
|
|
|
|
{
|
|
|
|
XDeleteProperty(_ecore_x_disp,
|
|
|
|
win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS);
|
|
|
|
XFree(old_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newset = calloc(num - 1, sizeof(Window));
|
|
|
|
data = (unsigned char *)newset;
|
|
|
|
for (j = 0; j < num; ++j)
|
|
|
|
if (oldset[j] != subwin)
|
|
|
|
newset[k++] = oldset[j];
|
|
|
|
ecore_x_window_prop_property_set(win,
|
|
|
|
ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
|
|
|
|
XA_WINDOW, 32, data, k);
|
|
|
|
XFree(old_data);
|
|
|
|
free(newset);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-25 23:28:51 -08:00
|
|
|
XFree(old_data);
|
|
|
|
}
|
2004-11-25 22:42:24 -08:00
|
|
|
|
2004-11-26 00:27:45 -08:00
|
|
|
/**
|
|
|
|
* Specify that a window is transient for another top-level window and should be handled accordingly.
|
|
|
|
* @param win the transient window
|
|
|
|
* @param forwin the toplevel window
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_transient_for_set(Ecore_X_Window win, Ecore_X_Window forwin)
|
|
|
|
{
|
|
|
|
XSetTransientForHint(_ecore_x_disp, win, forwin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the transient_for setting from a window.
|
|
|
|
* @param The window
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_transient_for_unset(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_TRANSIENT_FOR);
|
2004-11-26 00:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the window this window is transient for, if any.
|
|
|
|
* @param win The window to check
|
|
|
|
* @return The window ID of the top-level window, or 0 if the property does not exist.
|
|
|
|
*/
|
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_icccm_transient_for_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
Window forwin;
|
2004-11-26 00:27:45 -08:00
|
|
|
|
2004-12-04 02:10:29 -08:00
|
|
|
if (XGetTransientForHint(_ecore_x_disp, win, &forwin))
|
2004-11-27 07:17:30 -08:00
|
|
|
return (Ecore_X_Window) forwin;
|
2004-11-26 00:27:45 -08:00
|
|
|
else
|
|
|
|
return 0;
|
2004-12-04 02:10:29 -08:00
|
|
|
|
2004-11-26 00:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the window role hint.
|
|
|
|
* @param win The window
|
|
|
|
* @param role The role string
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_window_role_set(Ecore_X_Window win, const char *role)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_WINDOW_ROLE,
|
|
|
|
(char *)role);
|
2004-11-26 00:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the window role.
|
|
|
|
* @param win The window
|
|
|
|
* @return The window's role string.
|
|
|
|
*/
|
2004-12-04 02:10:29 -08:00
|
|
|
char *
|
2004-11-26 00:27:45 -08:00
|
|
|
ecore_x_icccm_window_role_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
return ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_WINDOW_ROLE);
|
2004-11-26 00:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the window's client leader.
|
|
|
|
* @param win The window
|
|
|
|
* @param l The client leader window
|
|
|
|
*
|
|
|
|
* All non-transient top-level windows created by an app other than
|
|
|
|
* the main window must have this property set to the app's main window.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ecore_x_icccm_client_leader_set(Ecore_X_Window win, Ecore_X_Window l)
|
|
|
|
{
|
|
|
|
ecore_x_window_prop_property_set(win,
|
2004-12-04 02:10:29 -08:00
|
|
|
ECORE_X_ATOM_WM_CLIENT_LEADER,
|
|
|
|
XA_WINDOW, 32, &l, 1);
|
2004-11-26 00:27:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the window's client leader.
|
|
|
|
* @param win The window
|
|
|
|
* @return The window's client leader window, or 0 if unset */
|
|
|
|
Ecore_X_Window
|
|
|
|
ecore_x_icccm_client_leader_get(Ecore_X_Window win)
|
|
|
|
{
|
2004-12-04 02:10:29 -08:00
|
|
|
unsigned char *data;
|
|
|
|
int num;
|
|
|
|
|
|
|
|
if (ecore_x_window_prop_property_get(win,
|
|
|
|
ECORE_X_ATOM_WM_CLIENT_LEADER,
|
|
|
|
XA_WINDOW, 32, &data, &num))
|
|
|
|
return (Ecore_X_Window) * data;
|
2004-11-26 00:27:45 -08:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-21 20:41:49 -07:00
|
|
|
/* FIXME: move these things in here as they are icccm related */
|
2004-10-22 19:19:19 -07:00
|
|
|
/* send iconify request */
|
2004-10-21 20:41:49 -07:00
|
|
|
|
2004-11-01 20:03:27 -08:00
|
|
|
/* FIXME: there are older E hints, gnome hints and mwm hints and new netwm */
|
2004-10-21 20:41:49 -07:00
|
|
|
/* hints. each should go in their own file/section so we know which */
|
2004-11-01 20:03:27 -08:00
|
|
|
/* is which. also older kde hints too. we should try support as much */
|
2004-10-21 20:41:49 -07:00
|
|
|
/* as makese sense to support */
|