Missed assigning an event for client machine change. Also added support for

_NET_WM_PID.


SVN revision: 7564
This commit is contained in:
rbdpngn 2003-10-13 17:36:09 +00:00 committed by rbdpngn
parent 1926a20d84
commit 911e66a03c
6 changed files with 114 additions and 27 deletions

View File

@ -468,6 +468,25 @@ handler_x_window_prop_client_machine_change(void *data, int type, void *event)
return 1;
}
int
handler_x_window_prop_pid_change(void *data, int type, void *event)
{
Ecore_X_Event_Window_Prop_Pid_Change *e;
e = event;
if (e->pid)
{
printf("Pid change to \"%d\" ", e->pid);
if (e->pid == getpid())
printf("correct.\n");
else
printf("INCORRECT!\n");
}
else
printf("Pid deleted\n");
return 1;
}
int
handler_x_window_prop_name_class_change(void *data, int type, void *event)
{
@ -524,6 +543,7 @@ setup_ecore_x_test(void)
printf("Client machine: %s\n", tmp);
free(tmp);
}
printf("Pid: %d\n", ecore_x_window_prop_pid_get(win));
ecore_x_window_prop_name_class_set(win, "ecore_test", "main");
ecore_x_window_prop_protocol_set(win, ECORE_X_WM_PROTOCOL_DELETE_REQUEST, 1);
ecore_x_window_show(win);
@ -547,6 +567,8 @@ setup_ecore_x_test(void)
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_ICON_NAME_CHANGE, handler_x_window_prop_icon_name_change, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_VISIBLE_ICON_NAME_CHANGE, handler_x_window_prop_visible_icon_name_change, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE, handler_x_window_prop_name_class_change, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE, handler_x_window_prop_client_machine_change, NULL);
ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE, handler_x_window_prop_pid_change, NULL);
}
#endif

View File

@ -106,6 +106,7 @@ typedef struct _Ecore_X_Event_Window_Prop_Icon_Name_Change Ecore_X_Event
typedef struct _Ecore_X_Event_Window_Prop_Visible_Icon_Name_Change Ecore_X_Event_Window_Prop_Visible_Icon_Name_Change;
typedef struct _Ecore_X_Event_Window_Prop_Client_Machine_Change Ecore_X_Event_Window_Prop_Client_Machine_Change;
typedef struct _Ecore_X_Event_Window_Prop_Name_Class_Change Ecore_X_Event_Window_Prop_Name_Class_Change;
typedef struct _Ecore_X_Event_Window_Prop_Pid_Change Ecore_X_Event_Window_Prop_Pid_Change;
struct _Ecore_X_Event_Key_Down
{
@ -409,6 +410,13 @@ struct _Ecore_X_Event_Window_Prop_Name_Class_Change
Ecore_X_Time time;
};
struct _Ecore_X_Event_Window_Prop_Pid_Change
{
Ecore_X_Window win;
pid_t pid;
Ecore_X_Time time;
};
extern int ECORE_X_EVENT_KEY_DOWN;
extern int ECORE_X_EVENT_KEY_UP;
extern int ECORE_X_EVENT_MOUSE_BUTTON_DOWN;
@ -450,6 +458,7 @@ extern int ECORE_X_EVENT_WINDOW_PROP_ICON_NAME_CHANGE;
extern int ECORE_X_EVENT_WINDOW_PROP_VISIBLE_ICON_NAME_CHANGE;
extern int ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE;
extern int ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE;
extern int ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE;
extern int ECORE_X_MODIFIER_SHIFT;
extern int ECORE_X_MODIFIER_CTRL;
@ -524,6 +533,7 @@ void ecore_x_window_lower(Ecore_X_Window win);
void ecore_x_window_reparent(Ecore_X_Window win, Ecore_X_Window new_parent, int x, int y);
void ecore_x_window_size_get(Ecore_X_Window win, int *w, int *h);
void ecore_x_window_cursor_show(Ecore_X_Window win, int show);
void ecore_x_window_defaults_set(Ecore_X_Window win);
void ecore_x_window_prop_property_set(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_Atom format, int size, void *data, int number);
void ecore_x_window_prop_string_set(Ecore_X_Window win, Ecore_X_Atom type, char *str);
@ -537,6 +547,7 @@ char *ecore_x_window_prop_icon_name_get(Ecore_X_Window win);
void ecore_x_window_prop_visible_icon_name_set(Ecore_X_Window win, const char *t);
char *ecore_x_window_prop_visible_icon_name_get(Ecore_X_Window win);
char *ecore_x_window_prop_client_machine_get(Ecore_X_Window win);
pid_t ecore_x_window_prop_pid_get(Ecore_X_Window win);
void ecore_x_window_prop_name_class_set(Ecore_X_Window win, const char *n, const char *c);
void ecore_x_window_prop_name_class_get(Ecore_X_Window win, char **n, char **c);
void ecore_x_window_prop_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, int on);

View File

@ -98,6 +98,7 @@ int ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE = 0;
int ECORE_X_EVENT_WINDOW_PROP_ICON_NAME_CHANGE = 0;
int ECORE_X_EVENT_WINDOW_PROP_VISIBLE_ICON_NAME_CHANGE = 0;
int ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE = 0;
int ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE = 0;
int ECORE_X_MODIFIER_SHIFT = 0;
int ECORE_X_MODIFIER_CTRL = 0;
@ -219,6 +220,8 @@ ecore_x_init(const char *name)
ECORE_X_EVENT_WINDOW_PROP_NAME_CLASS_CHANGE = ecore_event_type_new();
ECORE_X_EVENT_WINDOW_PROP_ICON_NAME_CHANGE = ecore_event_type_new();
ECORE_X_EVENT_WINDOW_PROP_VISIBLE_ICON_NAME_CHANGE = ecore_event_type_new();
ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE = ecore_event_type_new();
ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE = ecore_event_type_new();
}
ECORE_X_MODIFIER_SHIFT = _ecore_x_key_mask_get(XK_Shift_L);

View File

@ -8,6 +8,7 @@ static void _ecore_x_event_free_window_prop_visible_title_change(void *data, voi
static void _ecore_x_event_free_window_prop_icon_name_change(void *data, void *ev);
static void _ecore_x_event_free_window_prop_visible_icon_name_change(void *data, void *ev);
static void _ecore_x_event_free_window_prop_client_machine_change(void *data, void *ev);
static void _ecore_x_event_free_window_prop_pid_change(void *data, void *ev);
static void _ecore_x_event_free_key_down(void *data, void *ev);
static void _ecore_x_event_free_key_up(void *data, void *ev);
static void _ecore_x_event_free_generic(void *data, void *ev);
@ -73,6 +74,15 @@ _ecore_x_event_free_window_prop_client_machine_change(void *data, void *ev)
free(e);
}
static void
_ecore_x_event_free_window_prop_pid_change(void *data, void *ev)
{
Ecore_X_Event_Window_Prop_Client_Machine_Change *e;
e = ev;
free(e);
}
static void
_ecore_x_event_free_key_down(void *data, void *ev)
{
@ -792,6 +802,15 @@ _ecore_x_event_handle_property_notify(XEvent *xevent)
e->name = ecore_x_window_prop_client_machine_get(xevent->xproperty.window);
ecore_event_add(ECORE_X_EVENT_WINDOW_PROP_CLIENT_MACHINE_CHANGE, e, _ecore_x_event_free_window_prop_client_machine_change, NULL);
}
else if (xevent->xproperty.atom == _ecore_x_atom_net_wm_pid)
{
Ecore_X_Event_Window_Prop_Pid_Change *e;
e = calloc(1, sizeof(Ecore_X_Event_Window_Prop_Pid_Change));
if (!e) return;
e->pid = ecore_x_window_prop_pid_get(xevent->xproperty.window);
ecore_event_add(ECORE_X_EVENT_WINDOW_PROP_PID_CHANGE, e, _ecore_x_event_free_window_prop_pid_change, NULL);
}
else
{
Ecore_X_Event_Window_Property *e;

View File

@ -17,7 +17,6 @@
Ecore_X_Window
ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
{
char buf[MAXHOSTNAMELEN];
Window win;
XSetWindowAttributes attr;
@ -57,13 +56,7 @@ ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
CWEventMask,
&attr);
if (parent == DefaultRootWindow(_ecore_x_disp))
{
gethostname(buf, MAXHOSTNAMELEN);
buf[MAXHOSTNAMELEN - 1] = '\0';
ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_client_machine,
(char *)buf);
}
if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
return win;
}
@ -82,7 +75,6 @@ ecore_x_window_new(Ecore_X_Window parent, int x, int y, int w, int h)
Ecore_X_Window
ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
{
char buf[MAXHOSTNAMELEN];
Window win;
XSetWindowAttributes attr;
@ -122,13 +114,7 @@ ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
CWEventMask,
&attr);
if (parent == DefaultRootWindow(_ecore_x_disp))
{
gethostname(buf, MAXHOSTNAMELEN);
buf[MAXHOSTNAMELEN - 1] = '\0';
ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_client_machine,
(char *)buf);
}
if (parent == DefaultRootWindow(_ecore_x_disp)) ecore_x_window_defaults_set(win);
return win;
}
@ -147,7 +133,6 @@ ecore_x_window_override_new(Ecore_X_Window parent, int x, int y, int w, int h)
Ecore_X_Window
ecore_x_window_input_new(Ecore_X_Window parent, int x, int y, int w, int h)
{
char buf[MAXHOSTNAMELEN];
Window win;
XSetWindowAttributes attr;
@ -179,14 +164,39 @@ ecore_x_window_input_new(Ecore_X_Window parent, int x, int y, int w, int h)
if (parent == DefaultRootWindow(_ecore_x_disp))
{
gethostname(buf, MAXHOSTNAMELEN);
buf[MAXHOSTNAMELEN - 1] = '\0';
ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_client_machine,
(char *)buf);
}
return win;
}
/**
* Set defaults for a window
* @param win The window to set defaults
*
* Set defaults for a window
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
void
ecore_x_window_defaults_set(Ecore_X_Window win)
{
long pid;
char buf[MAXHOSTNAMELEN];
/*
* Set WM_CLIENT_MACHINE.
*/
gethostname(buf, MAXHOSTNAMELEN);
buf[MAXHOSTNAMELEN - 1] = '\0';
ecore_x_window_prop_string_set(win, _ecore_x_atom_wm_client_machine,
(char *)buf);
/*
* Set _NET_WM_PID
*/
pid = getpid();
ecore_x_window_prop_property_set(win, _ecore_x_atom_net_wm_pid, XA_CARDINAL,
32, &pid, 1);
}
/**
* Delete a window.
* @param win The window to delete

View File

@ -47,14 +47,14 @@ ecore_x_window_prop_property_get(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_
unsigned long num_ret = 0, bytes = 0, i;
unsigned char *prop_ret = NULL;
if (!win)
win = DefaultRootWindow(_ecore_x_disp);
if (!win) win = DefaultRootWindow(_ecore_x_disp);
ret = XGetWindowProperty(_ecore_x_disp, win, type, 0, LONG_MAX, False, format, &type_ret, &size_ret, &num_ret, &bytes, &prop_ret);
if (ret != Success) {
*data = NULL;
return 0;
}
if (ret != Success)
{
*data = NULL;
return 0;
}
if (size != size_ret || !num_ret) {
XFree(prop_ret);
@ -293,6 +293,28 @@ ecore_x_window_prop_client_machine_get(Ecore_X_Window win)
return name;
}
/**
* Get a windows process id
* @param win The window
* @return The windows process id
*
* Return the process id of a window.
* <hr><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
*/
pid_t
ecore_x_window_prop_pid_get(Ecore_X_Window win)
{
int num = 0;
long *tmp;
pid_t pid = 0;
ecore_x_window_prop_property_get(win, _ecore_x_atom_net_wm_pid, XA_CARDINAL,
32, &tmp, &num);
if (num && tmp) pid = (pid_t)(*tmp);
free(tmp);
return pid;
}
/**
* Set a window name & class.
* @param win The window