[PATCH] add sn_internal_display_get_root_window()
Julien Danjou
julien at danjou.info
Thu Jan 29 06:37:37 PST 2009
Signed-off-by: Julien Danjou <julien at danjou.info>
---
libsn/sn-common.c | 19 +++++++++++++++++++
libsn/sn-internals.h | 3 +++
libsn/sn-xmessages.c | 4 ++--
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/libsn/sn-common.c b/libsn/sn-common.c
index b494ad7..35fd6d7 100644
--- a/libsn/sn-common.c
+++ b/libsn/sn-common.c
@@ -151,6 +151,25 @@ sn_internal_display_get_x_screen (SnDisplay *display,
}
/**
+ * sn_internal_display_get_root_window:
+ * @display: an #SnDisplay
+ * @number: screen number to get root window from
+ *
+ * Gets a root window; if the screen number
+ * does not exist, returns %NULL.
+ *
+ * Return value: X root window or %NULL
+ **/
+Window
+sn_internal_display_get_root_window (SnDisplay *display,
+ int number)
+{
+ if (number < 0 || number >= display->n_screens)
+ return None;
+ return RootWindow (display->xdisplay, number);
+}
+
+/**
* sn_display_process_event:
* @display: a display
* @xevent: X event
diff --git a/libsn/sn-internals.h b/libsn/sn-internals.h
index 0336a0d..5969a82 100644
--- a/libsn/sn-internals.h
+++ b/libsn/sn-internals.h
@@ -53,6 +53,9 @@ SN_BEGIN_DECLS
Screen* sn_internal_display_get_x_screen (SnDisplay *display,
int number);
+Window sn_internal_display_get_root_window (SnDisplay *display,
+ int number);
+
void sn_internal_display_get_xmessage_data (SnDisplay *display,
SnList **funcs,
SnList **pending);
diff --git a/libsn/sn-xmessages.c b/libsn/sn-xmessages.c
index da7a8f4..50afb0a 100644
--- a/libsn/sn-xmessages.c
+++ b/libsn/sn-xmessages.c
@@ -64,7 +64,7 @@ sn_internal_add_xmessage_func (SnDisplay *display,
handler = sn_new0 (SnXmessageHandler, 1);
handler->xdisplay = sn_display_get_x_display (display);
- handler->root = RootWindow (handler->xdisplay, screen);
+ 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);
handler->message_type = sn_internal_strdup (message_type);
@@ -120,7 +120,7 @@ sn_internal_remove_xmessage_func (SnDisplay *display,
fhd.func = func;
fhd.func_data = func_data;
fhd.handler = NULL;
- fhd.root = RootWindow (sn_display_get_x_display (display), screen);
+ fhd.root = sn_internal_display_get_root_window (display, screen);
if (xmessage_funcs != NULL)
sn_list_foreach (xmessage_funcs, find_handler_foreach, &fhd);
--
1.5.6.5
More information about the xdg
mailing list