No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | e-shell-meego.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None | |
clang-analyzer | no-output-found | e-shell-meego.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * e-shell-meego.c
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with the program; if not, see <http://www.gnu.org/licenses/>
16 *
17 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
18 *
19 * Inspired by mx's mx-application.c by
20 * Thomas Wood <thomas.wood@intel.com>,
21 * Chris Lord <chris@linux.intel.com>
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <e-shell-meego.h>
29
30 #ifndef G_OS_WIN32
31 #include <gdk/gdkx.h>
32 #include <X11/Xatom.h>
33 #endif
34
35 #ifdef G_OS_WIN32
36 void
37 e_shell_detect_meego (gboolean *is_meego,
38 gboolean *small_screen)
39 {
40 *is_meego = *small_screen = FALSE;
41 }
42 #else
43 void
44 e_shell_detect_meego (gboolean *is_meego,
45 gboolean *small_screen)
46 {
47 Window *wm_window_v = NULL;
48 guchar *moblin_string = NULL;
49 GModule *module = NULL;
50 /*
51 * Wow - this is unpleasant, but it is hard to link directly
52 * to the X libraries, and we have to use XGetWindowProperty
53 * to get to the (mind-mashed) 'supporting' window.
54 */
55 struct {
56 gint (*XFree) (gpointer);
57 gint (*XGetWindowProperty) (Display *, XID, Atom, long, long, Bool,
58 Atom, Atom *, gint *, gulong *,
59 gulong *, guchar **);
60 } fns = { 0, 0 };
61
62 *is_meego = *small_screen = FALSE;
63
64 moblin_string = (guchar *) g_getenv ("EVO_MEEGO");
65 if (!moblin_string) {
66 GdkScreen *screen;
67 GdkDisplay *display;
68 GdkAtom wm_win, mob_atom;
69 Atom dummy_t;
70 gulong dummy_l;
71 gint dummy_i;
72
73 if (!gdk_display_get_default ())
74 return;
75
76 wm_win = gdk_atom_intern ("_NET_SUPPORTING_WM_CHECK", TRUE);
77 mob_atom = gdk_atom_intern ("_DAWATI", TRUE);
78 if (!wm_win || !mob_atom)
79 return;
80
81 module = g_module_open (NULL, 0);
82 if (!module)
83 return;
84 g_module_symbol (module, "XFree", (gpointer) &fns.XFree);
85 g_module_symbol (
86 module, "XGetWindowProperty",
87 (gpointer) &fns.XGetWindowProperty);
88 if (!fns.XFree || !fns.XGetWindowProperty) {
89 fprintf (stderr, "defective X server\n");
90 goto exit;
91 }
92
93 display = gdk_display_get_default ();
94 screen = gdk_display_get_default_screen (display);
95
96 gdk_error_trap_push ();
97
98 /* get the window manager's supporting window */
99 fns.XGetWindowProperty (
100 gdk_x11_display_get_xdisplay (display),
101 GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
102 gdk_x11_atom_to_xatom_for_display (display, wm_win),
103 0, 1, False, XA_WINDOW,
104 &dummy_t, &dummy_i,
105 &dummy_l, &dummy_l,
106 (guchar **) (&wm_window_v));
107
108 /* get the '_Moblin' setting */
109 if (wm_window_v && (*wm_window_v != None))
110 fns.XGetWindowProperty (
111 gdk_x11_display_get_xdisplay (display),
112 *wm_window_v,
113 gdk_x11_atom_to_xatom_for_display (display, mob_atom),
114 0, 8192, False, XA_STRING,
115 &dummy_t, &dummy_i,
116 &dummy_l, &dummy_l,
117 &moblin_string);
118
119 gdk_error_trap_pop_ignored ();
120 }
121
122 if (moblin_string) {
123 gint i;
124 gchar **props;
125
126 g_warning ("prop '%s'", moblin_string);
127
128 /* use meego theming tweaks */
129 *is_meego = TRUE;
130
131 props = g_strsplit ((gchar *) moblin_string, ":", -1);
132 for (i = 0; props && props[i]; i++) {
133 gchar **pair = g_strsplit (props[i], "=", 2);
134
135 g_warning (
136 "pair '%s'='%s'", pair ? pair[0] : "<null>",
137 pair && pair[0] ? pair[1] : "<null>");
138
139 /* Hunt for session-type=small-screen */
140 if (pair && pair[0] && !g_ascii_strcasecmp (pair[0], "session-type"))
141 *small_screen = !g_ascii_strcasecmp (pair[1], "small-screen");
142 g_strfreev (pair);
143 }
144 g_strfreev (props);
145 if (fns.XFree)
146 fns.XFree (moblin_string);
147 }
148
149 exit:
150 if (wm_window_v)
151 fns.XFree (wm_window_v);
152 if (module)
153 g_module_close (module);
154 }
155 #endif
156
157 #ifdef TEST_APP
158 /* gcc -g -O0 -Wall -I. -DTEST_APP `pkg-config --cflags --libs gtk+-2.0`
159 * e-shell-meego.c && ./a.out */
160 #include <gtk/gtk.h>
161
162 gint main (gint argc, gchar **argv)
163 {
164 gboolean is_meego, small_screen;
165
166 gtk_init (&argc, &argv);
167
168 e_shell_detect_meego (&is_meego, &small_screen);
169 fprintf (stderr, "Meego ? %d small ? %d\n", is_meego, small_screen);
170
171 return 0;
172 }
173 #endif