aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2010-04-08 00:49:19 +0800
committerMichael Meeks <michael.meeks@novell.com>2010-04-08 00:52:09 +0800
commite16baf2b51cdbf2bd4d1feb9507603c261599d11 (patch)
treeefca151b0c23dcbe3243c2c5b3859a46410c13b9
parentc63a626b5e401da99d499402dc17d535f5724050 (diff)
downloadgsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar.gz
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar.bz2
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar.lz
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar.xz
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.tar.zst
gsoc2013-evolution-e16baf2b51cdbf2bd4d1feb9507603c261599d11.zip
hook out X symbols via g_module to avoid direct X linkage.
-rw-r--r--shell/e-shell-meego.c63
1 files changed, 43 insertions, 20 deletions
diff --git a/shell/e-shell-meego.c b/shell/e-shell-meego.c
index 63342f156d..70401c1e62 100644
--- a/shell/e-shell-meego.c
+++ b/shell/e-shell-meego.c
@@ -37,9 +37,6 @@ void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
#else
void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
{
- /* cannot compile on Fedora, disabling for now */
- *is_meego = *small_screen = FALSE;
- /*
GdkAtom wm_win, mob_atom;
Atom dummy_t;
unsigned long dummy_l;
@@ -48,6 +45,18 @@ void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
GdkDisplay *display;
Window *wm_window_v = NULL;
unsigned char *moblin_string = NULL;
+ GModule *module;
+ /*
+ * Wow - this is unpleasant, but it is hard to link directly
+ * to the X libraries, and we have to use XGetWindowProperty
+ * to get to the (mind-mashed) 'supporting' window.
+ */
+ struct {
+ int (*XFree) (void *);
+ int (*XGetWindowProperty) (Display*, XID, Atom, long, long, Bool,
+ Atom, Atom *, int *, unsigned long*,
+ unsigned long*, unsigned char**);
+ } fns = { 0, 0 };
*is_meego = *small_screen = FALSE;
@@ -59,25 +68,36 @@ void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
if (!wm_win || !mob_atom)
return;
+ module = g_module_open (NULL, 0);
+ if (!module)
+ return;
+ g_module_symbol (module, "XFree", (gpointer) &fns.XFree);
+ g_module_symbol (module, "XGetWindowProperty",
+ (gpointer) &fns.XGetWindowProperty);
+ if (!fns.XFree || !fns.XGetWindowProperty) {
+ fprintf (stderr, "defective X server\n");
+ goto exit;
+ }
+
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (gdk_display_get_default());
gdk_error_trap_push ();
- /* get the window manager's supporting window * /
- XGetWindowProperty (gdk_x11_display_get_xdisplay (display),
- GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
- gdk_x11_atom_to_xatom_for_display (display, wm_win),
- 0, 1, False, XA_WINDOW, &dummy_t, &dummy_i,
- &dummy_l, &dummy_l, (unsigned char **)(&wm_window_v));
+ /* get the window manager's supporting window */
+ fns.XGetWindowProperty (gdk_x11_display_get_xdisplay (display),
+ GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
+ gdk_x11_atom_to_xatom_for_display (display, wm_win),
+ 0, 1, False, XA_WINDOW, &dummy_t, &dummy_i,
+ &dummy_l, &dummy_l, (unsigned char **)(&wm_window_v));
- /* get the '_Moblin' setting * /
+ /* get the '_Moblin' setting */
if (wm_window_v && (*wm_window_v != None))
- XGetWindowProperty (gdk_x11_display_get_xdisplay (display), *wm_window_v,
- gdk_x11_atom_to_xatom_for_display (display, mob_atom),
- 0, 8192, False, XA_STRING,
- &dummy_t, &dummy_i, &dummy_l, &dummy_l,
- &moblin_string);
+ fns.XGetWindowProperty (gdk_x11_display_get_xdisplay (display), *wm_window_v,
+ gdk_x11_atom_to_xatom_for_display (display, mob_atom),
+ 0, 8192, False, XA_STRING,
+ &dummy_t, &dummy_i, &dummy_l, &dummy_l,
+ &moblin_string);
gdk_error_trap_pop ();
@@ -87,7 +107,7 @@ void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
g_warning ("prop '%s'", moblin_string);
- /* use meego theming tweaks * /
+ /* use meego theming tweaks */
*is_meego = TRUE;
props = g_strsplit ((gchar *)moblin_string, ":", -1);
@@ -97,22 +117,25 @@ void e_shell_detect_meego (gboolean *is_meego, gboolean *small_screen)
g_warning ("pair '%s'='%s'", pair ? pair[0] : "<null>",
pair && pair[0] ? pair[1] : "<null>");
- /* Hunt for session-type=small-screen * /
+ /* Hunt for session-type=small-screen */
if (pair && pair[0] && !g_ascii_strcasecmp (pair[0], "session-type"))
*small_screen = !g_ascii_strcasecmp (pair[1], "small-screen");
g_strfreev (pair);
}
g_strfreev (props);
- XFree (moblin_string);
+ fns.XFree (moblin_string);
}
+ exit:
if (wm_window_v)
- XFree (wm_window_v);*/
+ fns.XFree (wm_window_v);
+
+ g_module_close (module);
}
#endif
#ifdef TEST_APP
-/* gcc -g -O0 -Wall -I. -DTEST `pkg-config --cflags --libs gtk+-2.0` e-shell-meego.c && ./a.out */
+/* gcc -g -O0 -Wall -I. -DTEST_APP `pkg-config --cflags --libs gtk+-2.0` e-shell-meego.c && ./a.out */
#include <gtk/gtk.h>
int main (int argc, char **argv)