[PATCH] Anonymize display type into an generic id
Julien Danjou
julien at danjou.info
Thu Jan 29 06:37:40 PST 2009
This allows to handle identification of the connection without using any
Xlib defined type.
Signed-off-by: Julien Danjou <julien at danjou.info>
---
libsn/sn-common.c | 14 ++++++++++++++
libsn/sn-internals.h | 2 ++
libsn/sn-monitor.c | 4 ++--
libsn/sn-xmessages.c | 12 ++++++------
4 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/libsn/sn-common.c b/libsn/sn-common.c
index 6da3eed..d5c52c0 100644
--- a/libsn/sn-common.c
+++ b/libsn/sn-common.c
@@ -131,6 +131,20 @@ sn_display_get_x_display (SnDisplay *display)
}
/**
+ * sn_internal_display_get_id:
+ * @display: an #SnDisplay
+ *
+ *
+ *
+ * Return value: X display id.
+ **/
+void *
+sn_internal_display_get_id (SnDisplay *display)
+{
+ return display->xdisplay;
+}
+
+/**
* sn_internal_display_get_x_screen:
* @display: an #SnDisplay
* @number: screen number to get
diff --git a/libsn/sn-internals.h b/libsn/sn-internals.h
index 6466842..43ea186 100644
--- a/libsn/sn-internals.h
+++ b/libsn/sn-internals.h
@@ -57,6 +57,8 @@ Window sn_internal_display_get_root_window (SnDisplay *display,
int number);
int sn_internal_display_get_screen_number (SnDisplay *display);
+void* sn_internal_display_get_id (SnDisplay *display);
+
void sn_internal_display_get_xmessage_data (SnDisplay *display,
SnList **funcs,
SnList **pending);
diff --git a/libsn/sn-monitor.c b/libsn/sn-monitor.c
index d9a9e3a..223473a 100644
--- a/libsn/sn-monitor.c
+++ b/libsn/sn-monitor.c
@@ -624,8 +624,8 @@ find_sequence_by_id_foreach (void *value,
FindSequenceByIdData *fsd = data;
if (strcmp (sequence->id, fsd->id) == 0 &&
- sn_display_get_x_display (sequence->display) ==
- sn_display_get_x_display (fsd->display))
+ sn_internal_display_get_id (sequence->display) ==
+ sn_internal_display_get_id (fsd->display))
{
fsd->found = sequence;
return FALSE;
diff --git a/libsn/sn-xmessages.c b/libsn/sn-xmessages.c
index 3c328c8..c2fc8d1 100644
--- a/libsn/sn-xmessages.c
+++ b/libsn/sn-xmessages.c
@@ -28,7 +28,7 @@
typedef struct
{
- Display *xdisplay;
+ void *xid;
Window root;
Atom type_atom;
Atom type_atom_begin;
@@ -63,7 +63,7 @@ sn_internal_add_xmessage_func (SnDisplay *display,
handler = sn_new0 (SnXmessageHandler, 1);
- handler->xdisplay = sn_display_get_x_display (display);
+ handler->xid = sn_internal_display_get_id (display);
handler->root = sn_internal_display_get_root_window (display, screen);
handler->type_atom = sn_internal_atom_get (display, message_type);
handler->type_atom_begin = sn_internal_atom_get (display, message_type_begin);
@@ -226,7 +226,7 @@ sn_internal_broadcast_xmessage (SnDisplay *display,
typedef struct
{
- Display *xdisplay;
+ void *xid;
Atom atom;
Window xwindow;
sn_bool_t found_handler;
@@ -239,7 +239,7 @@ handler_for_atom_foreach (void *value,
SnXmessageHandler *handler = value;
HandlerForAtomData *hfad = data;
- if (handler->xdisplay == hfad->xdisplay &&
+ if (handler->xid == hfad->xid &&
(handler->type_atom == hfad->atom ||
handler->type_atom_begin == hfad->atom))
{
@@ -261,7 +261,7 @@ some_handler_handles_event (SnDisplay *display,
NULL);
hfad.atom = xevent->xclient.message_type;
- hfad.xdisplay = sn_display_get_x_display (display);
+ hfad.xid = sn_internal_display_get_id (display);
hfad.xwindow = xevent->xclient.window;
hfad.found_handler = FALSE;
@@ -394,7 +394,7 @@ dispatch_message_foreach (void *value,
MessageDispatchData *mdd = data;
if (handler->type_atom_begin == mdd->message->type_atom_begin &&
- sn_display_get_x_display (mdd->display) == handler->xdisplay)
+ sn_internal_display_get_id (mdd->display) == handler->xid)
(* handler->func) (mdd->display,
handler->message_type,
mdd->message->message,
--
1.5.6.5
More information about the xdg
mailing list