Some client message and ICCCM related functions.

SVN revision: 11687
This commit is contained in:
Kim Woelders 2004-09-21 19:18:45 +00:00
parent e6ac57ddb6
commit be77d65356
6 changed files with 141 additions and 10 deletions

View File

@ -2,14 +2,5 @@
.libs
Makefile
Makefile.in
ecore_x.lo
ecore_x_dnd.lo
ecore_x_error.lo
ecore_x_events.lo
ecore_x_gc.lo
ecore_x_pixmap.lo
ecore_x_window.lo
ecore_x_window_prop.lo
ecore_x_window_shape.lo
ecore_x_selection.lo
*.lo
libecore_x.la

View File

@ -860,6 +860,15 @@ int ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap);
Ecore_X_GC ecore_x_gc_new(Ecore_X_Drawable draw);
void ecore_x_gc_del(Ecore_X_GC gc);
int ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, long d0, long d1, long d2, long d3, long d4);
int ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type, const void *data, int len);
void ecore_x_icccm_window_state_set_iconic(Ecore_X_Window win);
void ecore_x_icccm_window_state_set_normal(Ecore_X_Window win);
void ecore_x_icccm_window_state_set_withdrawn(Ecore_X_Window win);
void ecore_x_icccm_send_delete_window(Ecore_X_Window win);
void ecore_x_icccm_send_take_focus(Ecore_X_Window win);
/* FIXME: these funcs need categorising */

View File

@ -23,6 +23,7 @@ ecore_x.c \
ecore_x_dnd.c \
ecore_x_error.c \
ecore_x_events.c \
ecore_x_icccm.c \
ecore_x_selection.c \
ecore_x_window.c \
ecore_x_window_prop.c \
@ -52,6 +53,7 @@ ecore_x.c \
ecore_x_dnd.c \
ecore_x_error.c \
ecore_x_events.c \
ecore_x_icccm.c \
ecore_x_selection.c \
ecore_x_window.c \
ecore_x_window_prop.c \

View File

@ -28,6 +28,7 @@ int _ecore_x_event_last_root_y = 0;
/*
* ICCCM and Motif hints.
*/
Atom _ecore_x_atom_wm_state = 0;
Atom _ecore_x_atom_wm_delete_window = 0;
Atom _ecore_x_atom_wm_take_focus = 0;
Atom _ecore_x_atom_wm_protocols = 0;
@ -365,6 +366,7 @@ ecore_x_init(const char *name)
return 0;
}
_ecore_x_filter_handler = ecore_event_filter_add(_ecore_x_event_filter_start, _ecore_x_event_filter_filter, _ecore_x_event_filter_end, NULL);
_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);
@ -1270,6 +1272,64 @@ ecore_x_ungrab(void)
}
}
/**
* Send client message with given type and format 32.
*
* @param win The window the message is sent to.
* @param type The client message type.
* @param d0...d4 The client message data items.
*
* @return !0 on success.
*/
int
ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type,
long d0, long d1, long d2, long d3, long d4)
{
XEvent xev;
xev.xclient.window = win;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = type;
xev.xclient.format = 32;
xev.xclient.data.l[0] = d0;
xev.xclient.data.l[1] = d1;
xev.xclient.data.l[2] = d2;
xev.xclient.data.l[3] = d3;
xev.xclient.data.l[4] = d4;
return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
}
/**
* Send client message with given type and format 8.
*
* @param win The window the message is sent to.
* @param type The client message type.
* @param data Data to be sent.
* @param len Number of data bytes, max 20.
*
* @return !0 on success.
*/
int
ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type,
const void *data, int len)
{
XEvent xev;
xev.xclient.window = win;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = type;
xev.xclient.format = 8;
if (len > 20)
len = 20;
memcpy(xev.xclient.data.b, data, len);
memset(xev.xclient.data.b + len, 0, 20 - len);
return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/

View File

@ -0,0 +1,68 @@
/*
* Various ICCCM related functions.
* These are normally called only by window managers.
*/
#include "Ecore.h"
#include "ecore_x_private.h"
#include "Ecore_X.h"
static void
_ecore_x_icccm_window_state_set(Ecore_X_Window win, unsigned int state)
{
unsigned long c[2];
c[0] = state;
c[1] = 0;
XChangeProperty(_ecore_x_disp, win, _ecore_x_atom_wm_state,
_ecore_x_atom_wm_state, 32, PropModeReplace,
(unsigned char *)c, 2);
}
void
ecore_x_icccm_window_state_set_iconic(Ecore_X_Window win)
{
_ecore_x_icccm_window_state_set(win, IconicState);
}
void
ecore_x_icccm_window_state_set_normal(Ecore_X_Window win)
{
_ecore_x_icccm_window_state_set(win, NormalState);
}
void
ecore_x_icccm_window_state_set_withdrawn(Ecore_X_Window win)
{
_ecore_x_icccm_window_state_set(win, WithdrawnState);
}
static void
_ecore_x_icccm_client_message_send(Ecore_X_Window win,
Ecore_X_Atom atom, Ecore_X_Time ts)
{
ecore_x_client_message32_send(win, _ecore_x_atom_wm_protocols, atom, ts,
0, 0, 0);
}
void
ecore_x_icccm_send_delete_window(Ecore_X_Window win)
{
_ecore_x_icccm_client_message_send(win, _ecore_x_atom_wm_delete_window,
CurrentTime);
}
void
ecore_x_icccm_send_take_focus(Ecore_X_Window win)
{
_ecore_x_icccm_client_message_send(win, _ecore_x_atom_wm_take_focus,
CurrentTime);
}
#if 0
void
ecore_x_icccm_send_save_yourself(Ecore_X_Window win)
{
_ecore_x_icccm_client_message_send(win, _ecore_x_atom_wm_save_yourself,
CurrentTime);
}
#endif

View File

@ -120,6 +120,7 @@ extern Window _ecore_x_event_last_win;
extern int _ecore_x_event_last_root_x;
extern int _ecore_x_event_last_root_y;
extern Atom _ecore_x_atom_wm_state;
extern Atom _ecore_x_atom_wm_delete_window;
extern Atom _ecore_x_atom_wm_take_focus;
extern Atom _ecore_x_atom_wm_protocols;