Bug Summary

File:rc/gs-window-x11.c
Warning:line 1027, column 4
Value stored to 'finished' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-window-x11.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib/llvm-16/lib/clang/16 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D CAFEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cafe-menus -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cafe-menus -D PREFIX="/usr" -D BINDIR="/usr/bin" -D LIBDIR="/usr/lib" -D LIBEXECDIR="/usr/libexec" -D DATADIR="/usr/share" -D SYSCONFDIR="/usr/etc" -D CAFELOCALEDIR="/usr/share/locale" -D SAVERDIR="/usr/libexec/cafe-screensaver" -D THEMESDIR="/usr/share/cafe-screensaver/themes" -D CTKBUILDERDIR="/usr/share/cafe-screensaver" -D PAM_SERVICE_NAME="cafe-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -I /usr/include/libxml2 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2024-09-01-000123-52284-1 -x c gs-window-x11.c
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2008 William Jon McCann <mccann@jhu.edu>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * Authors: William Jon McCann <mccann@jhu.edu>
20 *
21 */
22
23#include "config.h"
24
25#include <sys/types.h>
26#include <errno(*__errno_location ()).h>
27#include <sys/wait.h>
28#include <string.h>
29
30#include <cdk/cdkx.h>
31#include <cdk/cdkkeysyms.h>
32#include <ctk/ctk.h>
33#include <ctk/ctkx.h>
34
35#include "gs-window.h"
36#include "gs-marshal.h"
37#include "subprocs.h"
38#include "gs-debug.h"
39
40#ifdef HAVE_SHAPE_EXT1
41#include <X11/extensions/shape.h>
42#endif
43
44static void gs_window_finalize (GObject *object);
45
46static gboolean popup_dialog_idle (GSWindow *window);
47static void gs_window_dialog_finish (GSWindow *window);
48static void remove_command_watches (GSWindow *window);
49
50enum
51{
52 DIALOG_RESPONSE_CANCEL,
53 DIALOG_RESPONSE_OK
54};
55
56#define MAX_QUEUED_EVENTS16 16
57#define INFO_BAR_SECONDS30 30
58
59struct GSWindowPrivate
60{
61 CdkMonitor *monitor;
62
63 CdkRectangle geometry;
64 guint obscured : 1;
65 guint dialog_up : 1;
66
67 guint lock_enabled : 1;
68 guint user_switch_enabled : 1;
69 guint logout_enabled : 1;
70 guint keyboard_enabled : 1;
71
72 guint64 logout_timeout;
73 char *logout_command;
74 char *keyboard_command;
75 char *status_message;
76
77 CtkWidget *vbox;
78 CtkWidget *drawing_area;
79 CtkWidget *lock_box;
80 CtkWidget *lock_socket;
81 CtkWidget *keyboard_socket;
82 CtkWidget *info_bar;
83 CtkWidget *info_content;
84
85 cairo_surface_t *background_surface;
86
87 guint popup_dialog_idle_id;
88
89 guint dialog_map_signal_id;
90 guint dialog_unmap_signal_id;
91 guint dialog_response_signal_id;
92
93 guint watchdog_timer_id;
94 guint info_bar_timer_id;
95
96 gint lock_pid;
97 gint lock_watch_id;
98 gint dialog_response;
99 gboolean dialog_quit_requested;
100 gboolean dialog_shake_in_progress;
101
102 gint keyboard_pid;
103 gint keyboard_watch_id;
104
105 GList *key_events;
106
107 gdouble last_x;
108 gdouble last_y;
109
110 GTimer *timer;
111
112#ifdef HAVE_SHAPE_EXT1
113 int shape_event_base;
114#endif
115};
116
117enum
118{
119 ACTIVITY,
120 DEACTIVATED,
121 LAST_SIGNAL
122};
123
124enum
125{
126 PROP_0,
127 PROP_OBSCURED,
128 PROP_DIALOG_UP,
129 PROP_LOCK_ENABLED,
130 PROP_LOGOUT_ENABLED,
131 PROP_KEYBOARD_ENABLED,
132 PROP_KEYBOARD_COMMAND,
133 PROP_LOGOUT_COMMAND,
134 PROP_LOGOUT_TIMEOUT,
135 PROP_MONITOR,
136 PROP_STATUS_MESSAGE
137};
138
139static guint signals [LAST_SIGNAL] = { 0, };
140
141G_DEFINE_TYPE_WITH_PRIVATE (GSWindow, gs_window, CTK_TYPE_WINDOW)static void gs_window_init (GSWindow *self); static void gs_window_class_init
(GSWindowClass *klass); static GType gs_window_get_type_once
(void); static gpointer gs_window_parent_class = ((void*)0);
static gint GSWindow_private_offset; static void gs_window_class_intern_init
(gpointer klass) { gs_window_parent_class = g_type_class_peek_parent
(klass); if (GSWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWindow_private_offset); gs_window_class_init (
(GSWindowClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_window_get_instance_private (GSWindow *self
) { return (((gpointer) ((guint8*) (self) + (glong) (GSWindow_private_offset
)))); } GType gs_window_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= gs_window_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType gs_window_get_type_once (void) {
GType g_define_type_id = g_type_register_static_simple ((ctk_window_get_type
()), g_intern_static_string ("GSWindow"), sizeof (GSWindowClass
), (GClassInitFunc)(void (*)(void)) gs_window_class_intern_init
, sizeof (GSWindow), (GInstanceInitFunc)(void (*)(void)) gs_window_init
, (GTypeFlags) 0); { {{ GSWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWindowPrivate)); };} } return g_define_type_id
; }
142
143static void
144set_invisible_cursor (CdkWindow *window,
145 gboolean invisible)
146{
147 CdkDisplay *display;
148 CdkCursor *cursor = NULL((void*)0);
149
150 if (invisible)
151 {
152 display = cdk_window_get_display (window);
153 cursor = cdk_cursor_new_for_display (display, CDK_BLANK_CURSOR);
154 }
155
156 cdk_window_set_cursor (window, cursor);
157
158 if (cursor)
159 {
160 g_object_unref (cursor);
161 }
162}
163
164/* derived from tomboy */
165static void
166gs_window_override_user_time (GSWindow *window)
167{
168 guint32 ev_time = ctk_get_current_event_time ();
169
170 if (ev_time == 0)
171 {
172 gint ev_mask = ctk_widget_get_events (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
173 if (!(ev_mask & CDK_PROPERTY_CHANGE_MASK))
174 {
175 ctk_widget_add_events (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
,
176 CDK_PROPERTY_CHANGE_MASK);
177 }
178
179 /*
180 * NOTE: Last resort for D-BUS or other non-interactive
181 * openings. Causes roundtrip to server. Lame.
182 */
183 ev_time = cdk_x11_get_server_time (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
));
184 }
185
186 cdk_x11_window_set_user_time (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
), ev_time);
187}
188
189static void
190clear_children (Window window)
191{
192 Window root;
193 Window parent;
194 Window *children;
195 unsigned int n_children;
196 int status;
197
198 children = NULL((void*)0);
199 status = XQueryTree (CDK_DISPLAY_XDISPLAY (cdk_display_get_default ())(cdk_x11_display_get_xdisplay (cdk_display_get_default ())), window, &root, &parent, &children, &n_children);
200
201 if (status == 0)
202 {
203 if (children)
204 {
205 XFree (children);
206 }
207 return;
208 }
209
210 if (children)
211 {
212 while (n_children)
213 {
214 Window child;
215
216 child = children [--n_children];
217
218 XClearWindow (CDK_DISPLAY_XDISPLAY (cdk_display_get_default ())(cdk_x11_display_get_xdisplay (cdk_display_get_default ())), child);
219
220 clear_children (child);
221 }
222
223 XFree (children);
224 }
225}
226
227static void
228widget_clear_all_children (CtkWidget *widget)
229{
230 CdkWindow *w;
231 CdkDisplay *display;
232
233 gs_debug ("Clearing all child windows")gs_debug_real (__func__, "gs-window-x11.c", 233, "Clearing all child windows"
)
;
234 display = ctk_widget_get_display (widget);
235
236 cdk_x11_display_error_trap_push (display);
237
238 w = ctk_widget_get_window (widget);
239
240 clear_children (CDK_WINDOW_XID (w)(cdk_x11_window_get_xid (w)));
241
242 cdk_x11_display_error_trap_pop_ignored (display);
243
244}
245
246void
247gs_window_set_background_surface (GSWindow *window,
248 cairo_surface_t *surface)
249{
250 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
251
252 if (window->priv->background_surface != NULL((void*)0))
253 {
254 cairo_surface_destroy (window->priv->background_surface);
255 }
256 window->priv->background_surface = NULL((void*)0);
257
258 if (surface != NULL((void*)0))
259 {
260 window->priv->background_surface = cairo_surface_reference (surface);
261 }
262
263 ctk_widget_queue_draw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
264}
265
266void
267gs_window_clear (GSWindow *window)
268{
269 CdkDisplay *display;
270 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
271
272 gs_debug ("Clearing widgets")gs_debug_real (__func__, "gs-window-x11.c", 272, "Clearing widgets"
)
;
273
274 if (ctk_widget_get_realized (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
275 {
276 ctk_widget_queue_draw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
277 /* If a screensaver theme adds child windows
278 we need to clear them too */
279 widget_clear_all_children (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
280 }
281
282 if (ctk_widget_get_realized (window->priv->drawing_area))
283 {
284 ctk_widget_queue_draw (window->priv->drawing_area);
285 widget_clear_all_children (window->priv->drawing_area);
286 }
287
288 display = ctk_widget_get_display (CTK_WIDGET(window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
289 cdk_display_flush (display);
290}
291
292static cairo_region_t *
293get_outside_region (GSWindow *window)
294{
295 CdkDisplay *display;
296 int i;
297 int num_monitors;
298 cairo_region_t *region;
299
300 display = ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
301
302 region = cairo_region_create ();
303
304 num_monitors = cdk_display_get_n_monitors (display);
305 for (i = 0; i < num_monitors; i++)
306 {
307 CdkMonitor *mon = cdk_display_get_monitor (display, i);
308
309 if (mon != window->priv->monitor)
310 {
311 CdkRectangle geometry;
312 cairo_rectangle_int_t rectangle;
313
314 cdk_monitor_get_geometry (mon, &geometry);
315 rectangle.x = geometry.x;
316 rectangle.y = geometry.y;
317 rectangle.width = geometry.width;
318 rectangle.height = geometry.height;
319 cairo_region_union_rectangle (region, &rectangle);
320 }
321 else
322 {
323 break;
324 }
325 }
326
327 return region;
328}
329
330static void
331update_geometry (GSWindow *window)
332{
333 CdkRectangle geometry;
334 cairo_region_t *outside_region;
335 cairo_region_t *monitor_region;
336
337 outside_region = get_outside_region (window);
338
339 cdk_monitor_get_geometry (window->priv->monitor, &geometry);
340 gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 344, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
341 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 344, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
342 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 344, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
343 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 344, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
344 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 344, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
345 monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
346 cairo_region_subtract (monitor_region, outside_region);
347 cairo_region_destroy (outside_region);
348
349 cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
350 cairo_region_destroy (monitor_region);
351
352 gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 356, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
353 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 356, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
354 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 356, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
355 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 356, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
356 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 356, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
357
358 window->priv->geometry.x = geometry.x;
359 window->priv->geometry.y = geometry.y;
360 window->priv->geometry.width = geometry.width;
361 window->priv->geometry.height = geometry.height;
362}
363
364static void
365monitor_geometry_notify (CdkMonitor *monitor,
366 GParamSpec *pspec,
367 GSWindow *window)
368{
369 gs_debug ("Got monitor geometry notify signal")gs_debug_real (__func__, "gs-window-x11.c", 369, "Got monitor geometry notify signal"
)
;
370 ctk_widget_queue_resize (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
371}
372
373/* copied from panel-toplevel.c */
374static void
375gs_window_move_resize_window (GSWindow *window,
376 gboolean move,
377 gboolean resize)
378{
379 CtkWidget *widget;
380 CdkWindow *cdkwindow;
381
382 widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
;
383 cdkwindow = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
384
385 g_assert (ctk_widget_get_realized (widget))do { (void) 0; } while (0);
386
387 gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 391, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
388 window->priv->geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 391, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
389 window->priv->geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 391, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
390 window->priv->geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 391, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
391 window->priv->geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 391, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
;
392
393 if (move && resize)
394 {
395 cdk_window_move_resize (cdkwindow,
396 window->priv->geometry.x,
397 window->priv->geometry.y,
398 window->priv->geometry.width,
399 window->priv->geometry.height);
400 }
401 else if (move)
402 {
403 cdk_window_move (cdkwindow,
404 window->priv->geometry.x,
405 window->priv->geometry.y);
406 }
407 else if (resize)
408 {
409 cdk_window_resize (cdkwindow,
410 window->priv->geometry.width,
411 window->priv->geometry.height);
412 }
413}
414
415static void
416gs_window_real_unrealize (CtkWidget *widget)
417{
418 CdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
419
420 g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
421 widget)g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
;
422
423 if (CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->unrealize)
424 {
425 CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->unrealize (widget);
426 }
427}
428
429/* copied from cdk */
430extern char **environ;
431
432static gchar **
433spawn_make_environment_for_display (CdkDisplay *display,
434 gchar **envp)
435{
436 gchar **retval = NULL((void*)0);
437 const gchar *display_name;
438 gint display_index = -1;
439 gint i, env_len;
440
441 g_return_val_if_fail (CDK_IS_DISPLAY (display), NULL)do{ (void)0; }while (0);
442
443 if (envp == NULL((void*)0))
444 envp = environ;
445
446 for (env_len = 0; envp[env_len]; env_len++)
447 if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
448 display_index = env_len;
449
450 retval = g_new (char *, env_len + 1)((char * *) g_malloc_n ((env_len + 1), sizeof (char *)));
451 retval[env_len] = NULL((void*)0);
452
453 display_name = cdk_display_get_name (display);
454
455 for (i = 0; i < env_len; i++)
456 if (i == display_index)
457 retval[i] = g_strconcat ("DISPLAY=", display_name, NULL((void*)0));
458 else
459 retval[i] = g_strdup (envp[i])g_strdup_inline (envp[i]);
460
461 g_assert (i == env_len)do { (void) 0; } while (0);
462
463 return retval;
464}
465
466static gboolean
467spawn_command_line_on_display_sync (CdkDisplay *display,
468 const gchar *command_line,
469 char **standard_output,
470 char **standard_error,
471 int *exit_status,
472 GError **error)
473{
474 char **argv = NULL((void*)0);
475 char **envp = NULL((void*)0);
476 gboolean retval;
477
478 g_return_val_if_fail (command_line != NULL, FALSE)do{ (void)0; }while (0);
479
480 if (! g_shell_parse_argv (command_line, NULL((void*)0), &argv, error))
481 {
482 return FALSE(0);
483 }
484
485 envp = spawn_make_environment_for_display (display, NULL((void*)0));
486
487 retval = g_spawn_sync (NULL((void*)0),
488 argv,
489 envp,
490 G_SPAWN_SEARCH_PATH,
491 NULL((void*)0),
492 NULL((void*)0),
493 standard_output,
494 standard_error,
495 exit_status,
496 error);
497
498 g_strfreev (argv);
499 g_strfreev (envp);
500
501 return retval;
502}
503
504static CdkVisual *
505get_best_visual_for_display (CdkDisplay *display)
506{
507 CdkScreen *screen;
508 char *command;
509 char *std_output;
510 int exit_status;
511 GError *error;
512 unsigned long v;
513 char c;
514 CdkVisual *visual;
515 gboolean res;
516
517 visual = NULL((void*)0);
518 screen = cdk_display_get_default_screen (display);
519
520 command = g_build_filename (LIBEXECDIR"/usr/libexec", "cafe-screensaver-gl-helper", NULL((void*)0));
521
522 error = NULL((void*)0);
523 std_output = NULL((void*)0);
524 res = spawn_command_line_on_display_sync (display,
525 command,
526 &std_output,
527 NULL((void*)0),
528 &exit_status,
529 &error);
530 if (! res)
531 {
532 gs_debug ("Could not run command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, command, error->message)
;
533 g_error_free (error);
534 goto out;
535 }
536
537 if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
538 {
539 if (v != 0)
540 {
541 VisualID visual_id;
542
543 visual_id = (VisualID) v;
544 visual = cdk_x11_screen_lookup_visual (screen, visual_id);
545
546 gs_debug ("Found best GL visual for display %s: 0x%x",gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, cdk_display_get_name (display), (unsigned int) visual_id)
547 cdk_display_get_name (display),gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, cdk_display_get_name (display), (unsigned int) visual_id)
548 (unsigned int) visual_id)gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, cdk_display_get_name (display), (unsigned int) visual_id)
;
549 }
550 }
551out:
552 g_free (std_output);
553 g_free (command);
554
555 return g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual));
556}
557
558static void
559widget_set_best_visual (CtkWidget *widget)
560{
561 CdkVisual *visual;
562
563 g_return_if_fail (widget != NULL)do{ (void)0; }while (0);
564
565 visual = get_best_visual_for_display (ctk_widget_get_display (widget));
566 if (visual != NULL((void*)0))
567 {
568 ctk_widget_set_visual (widget, visual);
569 g_object_unref (visual);
570 }
571}
572
573static void
574gs_window_real_realize (CtkWidget *widget)
575{
576 CdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
577
578 widget_set_best_visual (widget);
579
580 if (CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->realize)
581 {
582 CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->realize (widget);
583 }
584
585 gs_window_override_user_time (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
586
587 gs_window_move_resize_window (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)));
588
589 g_signal_connect (monitor,g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
590 "notify::geometry",g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
591 G_CALLBACK (monitor_geometry_notify),g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
592 widget)g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
;
593}
594
595/* every so often we should raise the window in case
596 another window has somehow gotten on top */
597static gboolean
598watchdog_timer (GSWindow *window)
599{
600 CtkWidget *widget = CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
;
601
602 cdk_window_focus (ctk_widget_get_window (widget), CDK_CURRENT_TIME0L);
603
604 return TRUE(!(0));
605}
606
607static void
608remove_watchdog_timer (GSWindow *window)
609{
610 if (window->priv->watchdog_timer_id != 0)
611 {
612 g_source_remove (window->priv->watchdog_timer_id);
613 window->priv->watchdog_timer_id = 0;
614 }
615}
616
617static void
618add_watchdog_timer (GSWindow *window,
619 glong timeout)
620{
621 window->priv->watchdog_timer_id = g_timeout_add (timeout,
622 (GSourceFunc)watchdog_timer,
623 window);
624}
625
626static void
627remove_popup_dialog_idle (GSWindow *window)
628{
629 if (window->priv->popup_dialog_idle_id != 0)
630 {
631 g_source_remove (window->priv->popup_dialog_idle_id);
632 window->priv->popup_dialog_idle_id = 0;
633 }
634}
635
636static void
637add_popup_dialog_idle (GSWindow *window)
638{
639 window->priv->popup_dialog_idle_id = g_idle_add ((GSourceFunc)popup_dialog_idle, window);
640}
641
642static gboolean
643emit_deactivated_idle (GSWindow *window)
644{
645 g_signal_emit (window, signals [DEACTIVATED], 0);
646
647 return FALSE(0);
648}
649
650static void
651add_emit_deactivated_idle (GSWindow *window)
652{
653 g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
654}
655
656static void
657gs_window_raise (GSWindow *window)
658{
659 CdkWindow *win;
660
661 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
662
663 gs_debug ("Raising screensaver window")gs_debug_real (__func__, "gs-window-x11.c", 663, "Raising screensaver window"
)
;
664
665 win = ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
666
667 cdk_window_raise (win);
668}
669
670static gboolean
671x11_window_is_ours (Window window)
672{
673 CdkWindow *gwindow;
674 gboolean ret;
675
676 ret = FALSE(0);
677
678 gwindow = cdk_x11_window_lookup_for_display (cdk_display_get_default (), window);
679 if (gwindow && (window != CDK_ROOT_WINDOW ()(cdk_x11_get_default_root_xwindow ())))
680 {
681 ret = TRUE(!(0));
682 }
683
684 return ret;
685}
686
687#ifdef HAVE_SHAPE_EXT1
688static void
689unshape_window (GSWindow *window)
690{
691 cdk_window_shape_combine_region (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
),
692 NULL((void*)0),
693 0,
694 0);
695}
696#endif
697
698static void
699gs_window_xevent (GSWindow *window,
700 CdkXEvent *xevent)
701{
702 XEvent *ev;
703
704 ev = xevent;
705
706 /* MapNotify is used to tell us when new windows are mapped.
707 ConfigureNofify is used to tell us when windows are raised. */
708 switch (ev->xany.type)
709 {
710 case MapNotify19:
711 {
712 XMapEvent *xme = &ev->xmap;
713
714 if (! x11_window_is_ours (xme->window))
715 {
716 gs_window_raise (window);
717 }
718 else
719 {
720 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 720, "not raising our windows"
)
;
721 }
722
723 break;
724 }
725 case ConfigureNotify22:
726 {
727 XConfigureEvent *xce = &ev->xconfigure;
728
729 if (! x11_window_is_ours (xce->window))
730 {
731 gs_window_raise (window);
732 }
733 else
734 {
735 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 735, "not raising our windows"
)
;
736 }
737
738 break;
739 }
740 default:
741 /* extension events */
742#ifdef HAVE_SHAPE_EXT1
743 if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify0))
744 {
745 /*XShapeEvent *xse = (XShapeEvent *) ev;*/
746 unshape_window (window);
747 gs_debug ("Window was reshaped!")gs_debug_real (__func__, "gs-window-x11.c", 747, "Window was reshaped!"
)
;
748 }
749#endif
750
751 break;
752 }
753
754}
755
756static CdkFilterReturn
757xevent_filter (CdkXEvent *xevent,
758 CdkEvent *event,
759 GSWindow *window)
760{
761 gs_window_xevent (window, xevent);
762
763 return CDK_FILTER_CONTINUE;
764}
765
766static void
767select_popup_events (void)
768{
769 XWindowAttributes attr;
770 unsigned long events;
771 CdkDisplay *display;
772
773 display = cdk_display_get_default ();
774
775 cdk_x11_display_error_trap_push (display);
776
777 memset (&attr, 0, sizeof (attr));
778 XGetWindowAttributes (CDK_DISPLAY_XDISPLAY (display)(cdk_x11_display_get_xdisplay (display)), CDK_ROOT_WINDOW ()(cdk_x11_get_default_root_xwindow ()), &attr);
779
780 events = SubstructureNotifyMask(1L<<19) | attr.your_event_mask;
781 XSelectInput (CDK_DISPLAY_XDISPLAY (display)(cdk_x11_display_get_xdisplay (display)), CDK_ROOT_WINDOW ()(cdk_x11_get_default_root_xwindow ()), events);
782
783 cdk_x11_display_error_trap_pop_ignored (display);
784}
785
786static void
787window_select_shape_events (GSWindow *window)
788{
789#ifdef HAVE_SHAPE_EXT1
790 unsigned long events;
791 int shape_error_base;
792 CdkDisplay *display;
793
794 display = ctk_widget_get_display (CTK_WIDGET(window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
795
796 cdk_x11_display_error_trap_push (display);
797
798 if (XShapeQueryExtension (CDK_DISPLAY_XDISPLAY (display)(cdk_x11_display_get_xdisplay (display)), &window->priv->shape_event_base, &shape_error_base)) {
799 events = ShapeNotifyMask(1L << 0);
800 XShapeSelectInput (CDK_DISPLAY_XDISPLAY (display)(cdk_x11_display_get_xdisplay (display)), CDK_WINDOW_XID (ctk_widget_get_window (CTK_WIDGET (window)))(cdk_x11_window_get_xid (ctk_widget_get_window (((((CtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((ctk_widget_get_type ())))))))))
, events);
801 }
802
803 cdk_x11_display_error_trap_pop_ignored (display);
804#endif
805}
806
807static gboolean
808gs_window_real_draw (CtkWidget *widget,
809 cairo_t *cr)
810{
811 GSWindow *window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
812 cairo_surface_t *bg_surface = window->priv->background_surface;
813
814 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
815 if (bg_surface != NULL((void*)0))
816 {
817 cairo_set_source_surface (cr, bg_surface, 0, 0);
818 }
819 else
820 {
821 cairo_set_source_rgb (cr, 0, 0, 0);
822 }
823 cairo_paint (cr);
824
825 return FALSE(0);
826}
827
828static void
829gs_window_real_show (CtkWidget *widget)
830{
831 GSWindow *window;
832
833 if (CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->show)
834 {
835 CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->show (widget);
836 }
837
838 gs_window_clear (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
839
840 set_invisible_cursor (ctk_widget_get_window (widget), TRUE(!(0)));
841
842 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
843 if (window->priv->timer)
844 {
845 g_timer_destroy (window->priv->timer);
846 }
847 window->priv->timer = g_timer_new ();
848
849 remove_watchdog_timer (window);
850 add_watchdog_timer (window, 30000);
851
852 select_popup_events ();
853 window_select_shape_events (window);
854 cdk_window_add_filter (NULL((void*)0), (CdkFilterFunc)xevent_filter, window);
855}
856
857static void
858set_info_text_and_icon (GSWindow *window,
859 const char *icon_name,
860 const char *primary_text,
861 const char *secondary_text)
862{
863 CtkWidget *content_area;
864 CtkWidget *hbox_content;
865 CtkWidget *image;
866 CtkWidget *vbox;
867 gchar *primary_markup;
868 gchar *secondary_markup;
869 CtkWidget *primary_label;
870 CtkWidget *secondary_label;
871
872 hbox_content = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 8);
873 ctk_widget_show (hbox_content);
874
875 image = ctk_image_new_from_icon_name (icon_name, CTK_ICON_SIZE_DIALOG);
876 ctk_widget_show (image);
877 ctk_box_pack_start (CTK_BOX (hbox_content)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((ctk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
878 ctk_widget_set_valign (image, CTK_ALIGN_START);
879
880 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
881 ctk_widget_show (vbox);
882 ctk_box_pack_start (CTK_BOX (hbox_content)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((ctk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
883
884 primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
885 primary_label = ctk_label_new (primary_markup);
886 g_free (primary_markup);
887 ctk_widget_show (primary_label);
888 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, primary_label, TRUE(!(0)), TRUE(!(0)), 0);
889 ctk_label_set_use_markup (CTK_LABEL (primary_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
890 ctk_label_set_line_wrap (CTK_LABEL (primary_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
891 ctk_widget_set_halign (primary_label, CTK_ALIGN_START);
892
893 if (secondary_text != NULL((void*)0))
894 {
895 secondary_markup = g_strdup_printf ("<small>%s</small>",
896 secondary_text);
897 secondary_label = ctk_label_new (secondary_markup);
898 g_free (secondary_markup);
899 ctk_widget_show (secondary_label);
900 ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, secondary_label, TRUE(!(0)), TRUE(!(0)), 0);
901 ctk_label_set_use_markup (CTK_LABEL (secondary_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
902 ctk_label_set_line_wrap (CTK_LABEL (secondary_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((ctk_label_get_type ()))))))
, TRUE(!(0)));
903 ctk_widget_set_halign (secondary_label, CTK_ALIGN_START);
904 }
905
906 /* remove old content */
907 content_area = ctk_info_bar_get_content_area (CTK_INFO_BAR (window->priv->info_bar)((((CtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->info_bar)), ((ctk_info_bar_get_type(
)))))))
);
908 if (window->priv->info_content != NULL((void*)0))
909 {
910 ctk_container_remove (CTK_CONTAINER (content_area)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((ctk_container_get_type ()))))))
, window->priv->info_content);
911 }
912 ctk_box_pack_start (CTK_BOX (content_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((ctk_box_get_type ()))))))
,
913 hbox_content,
914 TRUE(!(0)), FALSE(0), 0);
915 window->priv->info_content = hbox_content;
916}
917
918static gboolean
919info_bar_timeout (GSWindow *window)
920{
921 window->priv->info_bar_timer_id = 0;
922 ctk_widget_hide (window->priv->info_bar);
923 return FALSE(0);
924}
925
926void
927gs_window_show_message (GSWindow *window,
928 const char *summary,
929 const char *body,
930 const char *icon)
931{
932 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
933
934 set_info_text_and_icon (window,
935 icon,
936 summary,
937 body);
938 ctk_widget_show (window->priv->info_bar);
939
940 if (window->priv->info_bar_timer_id > 0)
941 {
942 g_source_remove (window->priv->info_bar_timer_id);
943 }
944
945 window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS30,
946 (GSourceFunc)info_bar_timeout,
947 window);
948}
949
950void
951gs_window_show (GSWindow *window)
952{
953 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
954
955 ctk_widget_show (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
956}
957
958static void
959gs_window_real_hide (CtkWidget *widget)
960{
961 GSWindow *window;
962
963 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
964
965 cdk_window_remove_filter (NULL((void*)0), (CdkFilterFunc)xevent_filter, window);
966
967 remove_watchdog_timer (window);
968
969 if (CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->hide)
970 {
971 CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->hide (widget);
972 }
973}
974
975void
976gs_window_destroy (GSWindow *window)
977{
978 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
979
980 gs_window_cancel_unlock_request (window);
981
982 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
983}
984
985CdkWindow *
986gs_window_get_cdk_window (GSWindow *window)
987{
988 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
989
990 return ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
991}
992
993CtkWidget *
994gs_window_get_drawing_area (GSWindow *window)
995{
996 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
997
998 return window->priv->drawing_area;
999}
1000
1001/* just for debugging */
1002static gboolean
1003error_watch (GIOChannel *source,
1004 GIOCondition condition,
1005 gpointer data)
1006{
1007 gboolean finished = FALSE(0);
1008
1009 if (condition & G_IO_IN)
1010 {
1011 GIOStatus status;
1012 GError *error = NULL((void*)0);
1013 char *line;
1014
1015 line = NULL((void*)0);
1016 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1017
1018 switch (status)
1019 {
1020 case G_IO_STATUS_NORMAL:
1021 gs_debug ("command error output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1021, "command error output: %s"
, line)
;
1022 break;
1023 case G_IO_STATUS_EOF:
1024 finished = TRUE(!(0));
1025 break;
1026 case G_IO_STATUS_ERROR:
1027 finished = TRUE(!(0));
Value stored to 'finished' is never read
1028 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1028, "Error reading from child: %s\n"
, error->message)
;
1029 g_error_free (error);
1030 return FALSE(0);
1031 case G_IO_STATUS_AGAIN:
1032 default:
1033 break;
1034 }
1035 g_free (line);
1036 }
1037 else if (condition & G_IO_HUP)
1038 {
1039 finished = TRUE(!(0));
1040 }
1041
1042 if (finished)
1043 {
1044 return FALSE(0);
1045 }
1046
1047 return TRUE(!(0));
1048}
1049
1050static gboolean
1051spawn_on_window (GSWindow *window,
1052 char *command,
1053 int *pid,
1054 GIOFunc watch_func,
1055 gpointer user_data,
1056 gint *watch_id)
1057{
1058 int argc;
1059 char **argv;
1060 char **envp;
1061 GError *error;
1062 gboolean result;
1063 GIOChannel *channel;
1064 int standard_output;
1065 int standard_error;
1066 int child_pid;
1067 int id;
1068
1069 error = NULL((void*)0);
1070 if (! g_shell_parse_argv (command, &argc, &argv, &error))
1071 {
1072 gs_debug ("Could not parse command: %s", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1072, "Could not parse command: %s"
, error->message)
;
1073 g_error_free (error);
1074 return FALSE(0);
1075 }
1076
1077 error = NULL((void*)0);
1078 envp = spawn_make_environment_for_display (ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
), NULL((void*)0));
1079 result = g_spawn_async_with_pipes (NULL((void*)0),
1080 argv,
1081 envp,
1082 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
1083 NULL((void*)0),
1084 NULL((void*)0),
1085 &child_pid,
1086 NULL((void*)0),
1087 &standard_output,
1088 &standard_error,
1089 &error);
1090
1091 if (! result)
1092 {
1093 gs_debug ("Could not start command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 1093, "Could not start command '%s': %s"
, command, error->message)
;
1094 g_error_free (error);
1095 g_strfreev (argv);
1096 return FALSE(0);
1097 }
1098
1099 if (pid != NULL((void*)0))
1100 {
1101 *pid = child_pid;
1102 }
1103 else
1104 {
1105 g_spawn_close_pid (child_pid);
1106 }
1107
1108 /* output channel */
1109 channel = g_io_channel_unix_new (standard_output);
1110 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1111 g_io_channel_set_flags (channel,
1112 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1113 NULL((void*)0));
1114 id = g_io_add_watch (channel,
1115 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1116 watch_func,
1117 user_data);
1118 if (watch_id != NULL((void*)0))
1119 {
1120 *watch_id = id;
1121 }
1122 g_io_channel_unref (channel);
1123
1124 /* error channel */
1125 channel = g_io_channel_unix_new (standard_error);
1126 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1127 g_io_channel_set_flags (channel,
1128 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1129 NULL((void*)0));
1130 id = g_io_add_watch (channel,
1131 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1132 error_watch,
1133 NULL((void*)0));
1134 g_io_channel_unref (channel);
1135
1136 g_strfreev (argv);
1137 g_strfreev (envp);
1138
1139 return result;
1140}
1141
1142static void
1143lock_plug_added (CtkWidget *widget,
1144 GSWindow *window)
1145{
1146 ctk_widget_show (widget);
1147}
1148
1149static gboolean
1150lock_plug_removed (CtkWidget *widget,
1151 GSWindow *window)
1152{
1153 ctk_widget_hide (widget);
1154 ctk_container_remove (CTK_CONTAINER (window->priv->vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_container_get_type ())
)))))
, CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
);
1155 window->priv->lock_box = NULL((void*)0);
1156
1157 return TRUE(!(0));
1158}
1159
1160static void
1161keyboard_plug_added (CtkWidget *widget,
1162 GSWindow *window)
1163{
1164 ctk_widget_show (widget);
1165}
1166
1167static gboolean
1168keyboard_plug_removed (CtkWidget *widget,
1169 GSWindow *window)
1170{
1171 ctk_widget_hide (widget);
1172 ctk_container_remove (CTK_CONTAINER (window->priv->vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_container_get_type ())
)))))
, CTK_WIDGET (window->priv->keyboard_socket)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((ctk_widget_get_type
()))))))
);
1173
1174 return TRUE(!(0));
1175}
1176
1177static void
1178keyboard_socket_destroyed (CtkWidget *widget,
1179 GSWindow *window)
1180{
1181 g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_socket_destroyed), (window))
;
1182 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_added), (window))
;
1183 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_removed), (window))
;
1184
1185 window->priv->keyboard_socket = NULL((void*)0);
1186}
1187
1188static void
1189forward_key_events (GSWindow *window)
1190{
1191 window->priv->key_events = g_list_reverse (window->priv->key_events);
1192
1193 while (window->priv->key_events != NULL((void*)0))
1194 {
1195 CdkEventKey *event = window->priv->key_events->data;
1196
1197 ctk_window_propagate_key_event (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, event);
1198
1199 cdk_event_free ((CdkEvent *)event);
1200 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1201 window->priv->key_events);
1202 }
1203}
1204
1205static void
1206remove_key_events (GSWindow *window)
1207{
1208 window->priv->key_events = g_list_reverse (window->priv->key_events);
1209
1210 while (window->priv->key_events)
1211 {
1212 CdkEventKey *event = window->priv->key_events->data;
1213
1214 cdk_event_free ((CdkEvent *)event);
1215 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1216 window->priv->key_events);
1217 }
1218}
1219
1220static void
1221lock_socket_show (CtkWidget *widget,
1222 GSWindow *window)
1223{
1224 ctk_widget_child_focus (window->priv->lock_socket, CTK_DIR_TAB_FORWARD);
1225
1226 /* send queued events to the dialog */
1227 forward_key_events (window);
1228}
1229
1230static void
1231lock_socket_destroyed (CtkWidget *widget,
1232 GSWindow *window)
1233{
1234 g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_show), (window))
;
1235 g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_destroyed), (window))
;
1236 g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_added), (window))
;
1237 g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_removed), (window))
;
1238
1239 window->priv->lock_socket = NULL((void*)0);
1240}
1241
1242static void
1243create_keyboard_socket (GSWindow *window,
1244 guint32 id)
1245{
1246 int height;
1247
1248 height = (HeightOfScreen (cdk_x11_screen_get_xscreen (ctk_widget_get_screen (CTK_WIDGET (window))))((cdk_x11_screen_get_xscreen (ctk_widget_get_screen (((((CtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((ctk_widget_get_type ())))))))))->height)
) / 4;
1249
1250 window->priv->keyboard_socket = ctk_socket_new ();
1251 ctk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
1252
1253 g_signal_connect (window->priv->keyboard_socket, "destroy",g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
1254 G_CALLBACK (keyboard_socket_destroyed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
;
1255 g_signal_connect (window->priv->keyboard_socket, "plug_added",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
1256 G_CALLBACK (keyboard_plug_added), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
;
1257 g_signal_connect (window->priv->keyboard_socket, "plug_removed",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
1258 G_CALLBACK (keyboard_plug_removed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
;
1259 ctk_box_pack_start (CTK_BOX (window->priv->vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_box_get_type ()))))))
, window->priv->keyboard_socket, FALSE(0), FALSE(0), 0);
1260 ctk_socket_add_id (CTK_SOCKET (window->priv->keyboard_socket)((((CtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((ctk_socket_get_type
()))))))
, id);
1261}
1262
1263/* adapted from gspawn.c */
1264static int
1265wait_on_child (int pid)
1266{
1267 int status;
1268
1269wait_again:
1270 if (waitpid (pid, &status, 0) < 0)
1271 {
1272 if (errno(*__errno_location ()) == EINTR4)
1273 {
1274 goto wait_again;
1275 }
1276 else if (errno(*__errno_location ()) == ECHILD10)
1277 {
1278 ; /* do nothing, child already reaped */
1279 }
1280 else
1281 {
1282 gs_debug ("waitpid () should not fail in 'GSWindow'")gs_debug_real (__func__, "gs-window-x11.c", 1282, "waitpid () should not fail in 'GSWindow'"
)
;
1283 }
1284 }
1285
1286 return status;
1287}
1288
1289static void
1290kill_keyboard_command (GSWindow *window)
1291{
1292 if (window->priv->keyboard_pid > 0)
1293 {
1294 signal_pid (window->priv->keyboard_pid, SIGTERM15);
1295 }
1296}
1297
1298static void
1299kill_dialog_command (GSWindow *window)
1300{
1301 /* If a dialog is up we need to signal it
1302 and wait on it */
1303 if (window->priv->lock_pid > 0)
1304 {
1305 signal_pid (window->priv->lock_pid, SIGTERM15);
1306 }
1307}
1308
1309static void
1310keyboard_command_finish (GSWindow *window)
1311{
1312 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1313
1314 /* send a signal just in case */
1315 kill_keyboard_command (window);
1316
1317 gs_debug ("Keyboard finished")gs_debug_real (__func__, "gs-window-x11.c", 1317, "Keyboard finished"
)
;
1318
1319 if (window->priv->keyboard_pid > 0)
1320 {
1321 wait_on_child (window->priv->keyboard_pid);
1322
1323 g_spawn_close_pid (window->priv->keyboard_pid);
1324 window->priv->keyboard_pid = 0;
1325 }
1326}
1327
1328static gboolean
1329keyboard_command_watch (GIOChannel *source,
1330 GIOCondition condition,
1331 GSWindow *window)
1332{
1333 gboolean finished = FALSE(0);
1334
1335 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1336
1337 if (condition & G_IO_IN)
1338 {
1339 GIOStatus status;
1340 GError *error = NULL((void*)0);
1341 char *line;
1342
1343 line = NULL((void*)0);
1344 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1345
1346 switch (status)
1347 {
1348 case G_IO_STATUS_NORMAL:
1349 {
1350 guint32 id;
1351 char c;
1352 gs_debug ("keyboard command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1352, "keyboard command output: %s"
, line)
;
1353 if (1 == sscanf (line, " %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1354 {
1355 create_keyboard_socket (window, id);
1356 }
1357 }
1358 break;
1359 case G_IO_STATUS_EOF:
1360 finished = TRUE(!(0));
1361 break;
1362 case G_IO_STATUS_ERROR:
1363 finished = TRUE(!(0));
1364 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1364, "Error reading from child: %s\n"
, error->message)
;
1365 g_error_free (error);
1366 return FALSE(0);
1367 case G_IO_STATUS_AGAIN:
1368 default:
1369 break;
1370 }
1371
1372 g_free (line);
1373 }
1374 else if (condition & G_IO_HUP)
1375 {
1376 finished = TRUE(!(0));
1377 }
1378
1379 if (finished)
1380 {
1381 window->priv->keyboard_watch_id = 0;
1382 keyboard_command_finish (window);
1383 return FALSE(0);
1384 }
1385
1386 return TRUE(!(0));
1387}
1388
1389static void
1390embed_keyboard (GSWindow *window)
1391{
1392 gboolean res;
1393
1394 if (! window->priv->keyboard_enabled
1395 || window->priv->keyboard_command == NULL((void*)0))
1396 return;
1397
1398 gs_debug ("Adding embedded keyboard widget")gs_debug_real (__func__, "gs-window-x11.c", 1398, "Adding embedded keyboard widget"
)
;
1399
1400 /* FIXME: verify command is safe */
1401
1402 gs_debug ("Running command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1402, "Running command: %s"
, window->priv->keyboard_command)
;
1403
1404 res = spawn_on_window (window,
1405 window->priv->keyboard_command,
1406 &window->priv->keyboard_pid,
1407 (GIOFunc)keyboard_command_watch,
1408 window,
1409 &window->priv->keyboard_watch_id);
1410 if (! res)
1411 {
1412 gs_debug ("Could not start command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1412, "Could not start command: %s"
, window->priv->keyboard_command)
;
1413 }
1414}
1415
1416static void
1417create_lock_socket (GSWindow *window,
1418 guint32 id)
1419{
1420 window->priv->lock_socket = ctk_socket_new ();
1421 window->priv->lock_box = ctk_grid_new ();
1422 ctk_widget_set_halign (CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
,
1423 CTK_ALIGN_CENTER);
1424 ctk_widget_set_valign (CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
,
1425 CTK_ALIGN_CENTER);
1426 ctk_widget_show (window->priv->lock_box);
1427 ctk_box_pack_start (CTK_BOX (window->priv->vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_box_get_type ()))))))
, window->priv->lock_box, TRUE(!(0)), TRUE(!(0)), 0);
1428
1429 ctk_container_add (CTK_CONTAINER (window->priv->lock_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_container_get_type
()))))))
, window->priv->lock_socket);
1430
1431 g_signal_connect (window->priv->lock_socket, "show",g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
1432 G_CALLBACK (lock_socket_show), window)g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
;
1433 g_signal_connect (window->priv->lock_socket, "destroy",g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
1434 G_CALLBACK (lock_socket_destroyed), window)g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
;
1435 g_signal_connect (window->priv->lock_socket, "plug_added",g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
1436 G_CALLBACK (lock_plug_added), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
;
1437 g_signal_connect (window->priv->lock_socket, "plug_removed",g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
1438 G_CALLBACK (lock_plug_removed), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
;
1439
1440 ctk_socket_add_id (CTK_SOCKET (window->priv->lock_socket)((((CtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_socket)), ((ctk_socket_get_type
()))))))
, id);
1441
1442 if (window->priv->keyboard_enabled)
1443 {
1444 embed_keyboard (window);
1445 }
1446}
1447
1448static void
1449gs_window_dialog_finish (GSWindow *window)
1450{
1451 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1452
1453 gs_debug ("Dialog finished")gs_debug_real (__func__, "gs-window-x11.c", 1453, "Dialog finished"
)
;
1454
1455 /* make sure we finish the keyboard thing too */
1456 keyboard_command_finish (window);
1457
1458 /* send a signal just in case */
1459 kill_dialog_command (window);
1460
1461 if (window->priv->lock_pid > 0)
1462 {
1463 wait_on_child (window->priv->lock_pid);
1464
1465 g_spawn_close_pid (window->priv->lock_pid);
1466 window->priv->lock_pid = 0;
1467 }
1468
1469 /* remove events for the case were we failed to show socket */
1470 remove_key_events (window);
1471}
1472
1473static void
1474maybe_kill_dialog (GSWindow *window)
1475{
1476 if (!window->priv->dialog_shake_in_progress
1477 && window->priv->dialog_quit_requested
1478 && window->priv->lock_pid > 0)
1479 {
1480 kill (window->priv->lock_pid, SIGTERM15);
1481 }
1482}
1483
1484/* very rudimentary animation for indicating an auth failure */
1485static void
1486shake_dialog (GSWindow *window)
1487{
1488 int i;
1489 guint start, end;
1490
1491 window->priv->dialog_shake_in_progress = TRUE(!(0));
1492
1493 for (i = 0; i < 8; i++)
1494 {
1495 if (i % 2 == 0)
1496 {
1497 start = 30;
1498 end = 0;
1499 }
1500 else
1501 {
1502 start = 0;
1503 end = 30;
1504 }
1505
1506 if (! window->priv->lock_box)
1507 {
1508 break;
1509 }
1510
1511 ctk_widget_set_margin_start (CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
,
1512 start);
1513 ctk_widget_set_margin_end (CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
,
1514 end);
1515
1516 while (ctk_events_pending ())
1517 {
1518 ctk_main_iteration ();
1519 }
1520
1521 g_usleep (10000);
1522 }
1523
1524 window->priv->dialog_shake_in_progress = FALSE(0);
1525 maybe_kill_dialog (window);
1526}
1527
1528static void
1529window_set_dialog_up (GSWindow *window,
1530 gboolean dialog_up)
1531{
1532 if (window->priv->dialog_up == dialog_up)
1533 {
1534 return;
1535 }
1536
1537 window->priv->dialog_up = dialog_up;
1538 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "dialog-up");
1539}
1540
1541static void
1542popdown_dialog (GSWindow *window)
1543{
1544 gs_window_dialog_finish (window);
1545
1546 ctk_widget_show (window->priv->drawing_area);
1547
1548 gs_window_clear (window);
1549 set_invisible_cursor (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
), TRUE(!(0)));
1550
1551 window_set_dialog_up (window, FALSE(0));
1552
1553 /* reset the pointer positions */
1554 window->priv->last_x = -1;
1555 window->priv->last_y = -1;
1556
1557 if (window->priv->lock_box != NULL((void*)0))
1558 {
1559 ctk_container_remove (CTK_CONTAINER (window->priv->vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_container_get_type ())
)))))
, CTK_WIDGET (window->priv->lock_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((ctk_widget_get_type ()
))))))
);
1560 window->priv->lock_box = NULL((void*)0);
1561 }
1562
1563 remove_popup_dialog_idle (window);
1564 remove_command_watches (window);
1565}
1566
1567static gboolean
1568lock_command_watch (GIOChannel *source,
1569 GIOCondition condition,
1570 GSWindow *window)
1571{
1572 gboolean finished = FALSE(0);
1573
1574 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1575
1576 if (condition & G_IO_IN)
1577 {
1578 GIOStatus status;
1579 GError *error = NULL((void*)0);
1580 char *line;
1581
1582 line = NULL((void*)0);
1583 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1584
1585 switch (status)
1586 {
1587 case G_IO_STATUS_NORMAL:
1588 gs_debug ("command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1588, "command output: %s"
, line)
;
1589
1590 if (strstr (line, "WINDOW ID=") != NULL((void*)0))
1591 {
1592 guint32 id;
1593 char c;
1594 if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1595 {
1596 create_lock_socket (window, id);
1597 }
1598 }
1599 else if (strstr (line, "NOTICE=") != NULL((void*)0))
1600 {
1601 if (strstr (line, "NOTICE=AUTH FAILED") != NULL((void*)0))
1602 {
1603 shake_dialog (window);
1604 }
1605 }
1606 else if (strstr (line, "RESPONSE=") != NULL((void*)0))
1607 {
1608 if (strstr (line, "RESPONSE=OK") != NULL((void*)0))
1609 {
1610 gs_debug ("Got OK response")gs_debug_real (__func__, "gs-window-x11.c", 1610, "Got OK response"
)
;
1611 window->priv->dialog_response = DIALOG_RESPONSE_OK;
1612 }
1613 else
1614 {
1615 gs_debug ("Got CANCEL response")gs_debug_real (__func__, "gs-window-x11.c", 1615, "Got CANCEL response"
)
;
1616 window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
1617 }
1618 finished = TRUE(!(0));
1619 }
1620 else if (strstr (line, "REQUEST QUIT") != NULL((void*)0))
1621 {
1622 gs_debug ("Got request for quit")gs_debug_real (__func__, "gs-window-x11.c", 1622, "Got request for quit"
)
;
1623 window->priv->dialog_quit_requested = TRUE(!(0));
1624 maybe_kill_dialog (window);
1625 }
1626 break;
1627 case G_IO_STATUS_EOF:
1628 finished = TRUE(!(0));
1629 break;
1630 case G_IO_STATUS_ERROR:
1631 finished = TRUE(!(0));
1632 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1632, "Error reading from child: %s\n"
, error->message)
;
1633 g_error_free (error);
1634 return FALSE(0);
1635 case G_IO_STATUS_AGAIN:
1636 default:
1637 break;
1638 }
1639
1640 g_free (line);
1641 }
1642 else if (condition & G_IO_HUP)
1643 {
1644 finished = TRUE(!(0));
1645 }
1646
1647 if (finished)
1648 {
1649 popdown_dialog (window);
1650
1651 if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
1652 {
1653 add_emit_deactivated_idle (window);
1654 }
1655
1656 window->priv->lock_watch_id = 0;
1657
1658 return FALSE(0);
1659 }
1660
1661 return TRUE(!(0));
1662}
1663
1664static gboolean
1665is_logout_enabled (GSWindow *window)
1666{
1667 double elapsed;
1668
1669 if (! window->priv->logout_enabled)
1670 {
1671 return FALSE(0);
1672 }
1673
1674 if (! window->priv->logout_command)
1675 {
1676 return FALSE(0);
1677 }
1678
1679 elapsed = g_timer_elapsed (window->priv->timer, NULL((void*)0));
1680
1681 if (window->priv->logout_timeout < (elapsed * 1000))
1682 {
1683 return TRUE(!(0));
1684 }
1685
1686 return FALSE(0);
1687}
1688
1689static gboolean
1690is_user_switch_enabled (GSWindow *window)
1691{
1692 return window->priv->user_switch_enabled;
1693}
1694
1695static void
1696popup_dialog (GSWindow *window)
1697{
1698 gboolean result;
1699 char *tmp;
1700 GString *command;
1701
1702 gs_debug ("Popping up dialog")gs_debug_real (__func__, "gs-window-x11.c", 1702, "Popping up dialog"
)
;
1703
1704 tmp = g_build_filename (LIBEXECDIR"/usr/libexec", "cafe-screensaver-dialog", NULL((void*)0));
1705 command = g_string_new (tmp);
1706 g_free (tmp);
1707
1708 if (is_logout_enabled (window))
1709 {
1710 command = g_string_append (command, " --enable-logout")(__builtin_constant_p (" --enable-logout") ? __extension__ ({
const char * const __val = (" --enable-logout"); g_string_append_len_inline
(command, __val, (__val != ((void*)0)) ? (gssize) strlen (((
__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(command, " --enable-logout", (gssize) -1))
;
1711 g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
1712 }
1713
1714 if (window->priv->status_message)
1715 {
1716 char *quoted;
1717
1718 quoted = g_shell_quote (window->priv->status_message);
1719 g_string_append_printf (command, " --status-message=%s", quoted);
1720 g_free (quoted);
1721 }
1722
1723 if (is_user_switch_enabled (window))
1724 {
1725 command = g_string_append (command, " --enable-switch")(__builtin_constant_p (" --enable-switch") ? __extension__ ({
const char * const __val = (" --enable-switch"); g_string_append_len_inline
(command, __val, (__val != ((void*)0)) ? (gssize) strlen (((
__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(command, " --enable-switch", (gssize) -1))
;
1726 }
1727
1728 if (gs_debug_enabled ())
1729 {
1730 command = g_string_append (command, " --verbose")(__builtin_constant_p (" --verbose") ? __extension__ ({ const
char * const __val = (" --verbose"); g_string_append_len_inline
(command, __val, (__val != ((void*)0)) ? (gssize) strlen (((
__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(command, " --verbose", (gssize) -1))
;
1731 }
1732
1733 ctk_widget_hide (window->priv->drawing_area);
1734
1735 ctk_widget_queue_draw (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1736 set_invisible_cursor (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
), FALSE(0));
1737
1738 window->priv->dialog_quit_requested = FALSE(0);
1739 window->priv->dialog_shake_in_progress = FALSE(0);
1740
1741 result = spawn_on_window (window,
1742 command->str,
1743 &window->priv->lock_pid,
1744 (GIOFunc)lock_command_watch,
1745 window,
1746 &window->priv->lock_watch_id);
1747 if (! result)
1748 {
1749 gs_debug ("Could not start command: %s", command->str)gs_debug_real (__func__, "gs-window-x11.c", 1749, "Could not start command: %s"
, command->str)
;
1750 }
1751
1752 g_string_free (command, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(command), ((!(0)))) : g_string_free_and_steal (command)) : (
g_string_free) ((command), ((!(0)))))
;
1753}
1754
1755static gboolean
1756popup_dialog_idle (GSWindow *window)
1757{
1758 popup_dialog (window);
1759
1760 window->priv->popup_dialog_idle_id = 0;
1761
1762 return FALSE(0);
1763}
1764
1765void
1766gs_window_request_unlock (GSWindow *window)
1767{
1768 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1769
1770 gs_debug ("Requesting unlock")gs_debug_real (__func__, "gs-window-x11.c", 1770, "Requesting unlock"
)
;
1771
1772 if (! ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
1773 {
1774 gs_debug ("Request unlock but window is not visible!")gs_debug_real (__func__, "gs-window-x11.c", 1774, "Request unlock but window is not visible!"
)
;
1775 return;
1776 }
1777
1778 if (window->priv->lock_watch_id > 0)
1779 {
1780 return;
1781 }
1782
1783 if (! window->priv->lock_enabled)
1784 {
1785 add_emit_deactivated_idle (window);
1786
1787 return;
1788 }
1789
1790 if (window->priv->popup_dialog_idle_id == 0)
1791 {
1792 add_popup_dialog_idle (window);
1793 }
1794
1795 window_set_dialog_up (window, TRUE(!(0)));
1796}
1797
1798void
1799gs_window_cancel_unlock_request (GSWindow *window)
1800{
1801 /* FIXME: This is a bit of a hammer approach...
1802 * Maybe we should send a delete-event to
1803 * the plug?
1804 */
1805 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1806
1807 popdown_dialog (window);
1808}
1809
1810void
1811gs_window_set_lock_enabled (GSWindow *window,
1812 gboolean lock_enabled)
1813{
1814 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1815
1816 if (window->priv->lock_enabled == lock_enabled)
1817 {
1818 return;
1819 }
1820
1821 window->priv->lock_enabled = lock_enabled;
1822 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "lock-enabled");
1823}
1824
1825CdkDisplay *
1826gs_window_get_display (GSWindow *window)
1827{
1828 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1829
1830 return ctk_widget_get_display (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1831}
1832
1833void
1834gs_window_set_keyboard_enabled (GSWindow *window,
1835 gboolean enabled)
1836{
1837 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1838
1839 window->priv->keyboard_enabled = enabled;
1840}
1841
1842void
1843gs_window_set_keyboard_command (GSWindow *window,
1844 const char *command)
1845{
1846 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1847
1848 g_free (window->priv->keyboard_command);
1849
1850 if (command != NULL((void*)0))
1851 {
1852 window->priv->keyboard_command = g_strdup (command)g_strdup_inline (command);
1853 }
1854 else
1855 {
1856 window->priv->keyboard_command = NULL((void*)0);
1857 }
1858}
1859
1860void
1861gs_window_set_logout_enabled (GSWindow *window,
1862 gboolean logout_enabled)
1863{
1864 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1865
1866 window->priv->logout_enabled = logout_enabled;
1867}
1868
1869void
1870gs_window_set_user_switch_enabled (GSWindow *window,
1871 gboolean user_switch_enabled)
1872{
1873 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1874
1875 window->priv->user_switch_enabled = user_switch_enabled;
1876}
1877
1878void
1879gs_window_set_logout_timeout (GSWindow *window,
1880 glong logout_timeout)
1881{
1882 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1883
1884 if (logout_timeout < 0)
1885 {
1886 window->priv->logout_timeout = 0;
1887 }
1888 else
1889 {
1890 window->priv->logout_timeout = logout_timeout;
1891 }
1892}
1893
1894void
1895gs_window_set_logout_command (GSWindow *window,
1896 const char *command)
1897{
1898 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1899
1900 g_free (window->priv->logout_command);
1901
1902 if (command)
1903 {
1904 window->priv->logout_command = g_strdup (command)g_strdup_inline (command);
1905 }
1906 else
1907 {
1908 window->priv->logout_command = NULL((void*)0);
1909 }
1910}
1911
1912void
1913gs_window_set_status_message (GSWindow *window,
1914 const char *status_message)
1915{
1916 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1917
1918 g_free (window->priv->status_message);
1919 window->priv->status_message = g_strdup (status_message)g_strdup_inline (status_message);
1920}
1921
1922void
1923gs_window_set_monitor (GSWindow *window,
1924 CdkMonitor *monitor)
1925{
1926 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1927
1928 if (window->priv->monitor == monitor)
1929 {
1930 return;
1931 }
1932
1933 window->priv->monitor = monitor;
1934
1935 ctk_widget_queue_resize (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1936
1937 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "monitor");
1938}
1939
1940CdkMonitor *
1941gs_window_get_monitor (GSWindow *window)
1942{
1943 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1944
1945 return window->priv->monitor;
1946}
1947
1948static void
1949gs_window_set_property (GObject *object,
1950 guint prop_id,
1951 const GValue *value,
1952 GParamSpec *pspec)
1953{
1954 GSWindow *self;
1955
1956 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1957
1958 switch (prop_id)
1959 {
1960 case PROP_LOCK_ENABLED:
1961 gs_window_set_lock_enabled (self, g_value_get_boolean (value));
1962 break;
1963 case PROP_KEYBOARD_ENABLED:
1964 gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
1965 break;
1966 case PROP_KEYBOARD_COMMAND:
1967 gs_window_set_keyboard_command (self, g_value_get_string (value));
1968 break;
1969 case PROP_LOGOUT_ENABLED:
1970 gs_window_set_logout_enabled (self, g_value_get_boolean (value));
1971 break;
1972 case PROP_LOGOUT_COMMAND:
1973 gs_window_set_logout_command (self, g_value_get_string (value));
1974 break;
1975 case PROP_STATUS_MESSAGE:
1976 gs_window_set_status_message (self, g_value_get_string (value));
1977 break;
1978 case PROP_LOGOUT_TIMEOUT:
1979 gs_window_set_logout_timeout (self, g_value_get_long (value));
1980 break;
1981 case PROP_MONITOR:
1982 gs_window_set_monitor (self, g_value_get_pointer (value));
1983 break;
1984 default:
1985 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 1985, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1986 break;
1987 }
1988}
1989
1990static void
1991gs_window_get_property (GObject *object,
1992 guint prop_id,
1993 GValue *value,
1994 GParamSpec *pspec)
1995{
1996 GSWindow *self;
1997
1998 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1999
2000 switch (prop_id)
2001 {
2002 case PROP_LOCK_ENABLED:
2003 g_value_set_boolean (value, self->priv->lock_enabled);
2004 break;
2005 case PROP_KEYBOARD_ENABLED:
2006 g_value_set_boolean (value, self->priv->keyboard_enabled);
2007 break;
2008 case PROP_KEYBOARD_COMMAND:
2009 g_value_set_string (value, self->priv->keyboard_command);
2010 break;
2011 case PROP_LOGOUT_ENABLED:
2012 g_value_set_boolean (value, self->priv->logout_enabled);
2013 break;
2014 case PROP_LOGOUT_COMMAND:
2015 g_value_set_string (value, self->priv->logout_command);
2016 break;
2017 case PROP_STATUS_MESSAGE:
2018 g_value_set_string (value, self->priv->status_message);
2019 break;
2020 case PROP_LOGOUT_TIMEOUT:
2021 g_value_set_long (value, self->priv->logout_timeout);
2022 break;
2023 case PROP_MONITOR:
2024 g_value_set_pointer (value, (gpointer) self->priv->monitor);
2025 break;
2026 case PROP_OBSCURED:
2027 g_value_set_boolean (value, self->priv->obscured);
2028 break;
2029 case PROP_DIALOG_UP:
2030 g_value_set_boolean (value, self->priv->dialog_up);
2031 break;
2032 default:
2033 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 2033, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2034 break;
2035 }
2036}
2037
2038static void
2039queue_key_event (GSWindow *window,
2040 CdkEventKey *event)
2041{
2042 /* Eat the first return, enter, escape, or space */
2043 if (window->priv->key_events == NULL((void*)0)
2044 && (event->keyval == CDK_KEY_Return0xff0d
2045 || event->keyval == CDK_KEY_KP_Enter0xff8d
2046 || event->keyval == CDK_KEY_Escape0xff1b
2047 || event->keyval == CDK_KEY_space0x020))
2048 {
2049 return;
2050 }
2051
2052 /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
2053 something is wrong */
2054 /* Don't queue keys that may cause focus navigation in the dialog */
2055 if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS16
2056 && event->keyval != CDK_KEY_Tab0xff09
2057 && event->keyval != CDK_KEY_Up0xff52
2058 && event->keyval != CDK_KEY_Down0xff54)
2059 {
2060 window->priv->key_events = g_list_prepend (window->priv->key_events,
2061 cdk_event_copy ((CdkEvent *)event));
2062 }
2063}
2064
2065static gboolean
2066maybe_handle_activity (GSWindow *window)
2067{
2068 gboolean handled;
2069
2070 handled = FALSE(0);
2071
2072 /* if we already have a socket then don't bother */
2073 if (! window->priv->lock_socket
2074 && ctk_widget_get_sensitive (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2075 {
2076 g_signal_emit (window, signals [ACTIVITY], 0, &handled);
2077 }
2078
2079 return handled;
2080}
2081
2082static gboolean
2083gs_window_real_key_press_event (CtkWidget *widget,
2084 CdkEventKey *event)
2085{
2086 /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
2087
2088 /* Ignore brightness keys */
2089 if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
2090 {
2091 gs_debug ("Ignoring brightness keys")gs_debug_real (__func__, "gs-window-x11.c", 2091, "Ignoring brightness keys"
)
;
2092 return TRUE(!(0));
2093 }
2094
2095 maybe_handle_activity (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
2096
2097 queue_key_event (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, event);
2098
2099 if (CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->key_press_event)
2100 {
2101 CTK_WIDGET_CLASS (gs_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((ctk_widget_get_type ()))))))
->key_press_event (widget, event);
2102 }
2103
2104 return TRUE(!(0));
2105}
2106
2107static gboolean
2108gs_window_real_motion_notify_event (CtkWidget *widget,
2109 CdkEventMotion *event)
2110{
2111 GSWindow *window;
2112 gdouble distance;
2113 gdouble min_distance;
2114 gdouble min_percentage = 0.1;
2115 CdkDisplay *display;
2116 CdkScreen *screen;
2117
2118 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2119
2120 display = gs_window_get_display (window);
2121 screen = cdk_display_get_default_screen (display);
2122 min_distance = WidthOfScreen (cdk_x11_screen_get_xscreen (screen))((cdk_x11_screen_get_xscreen (screen))->width) * min_percentage;
2123
2124 /* if the last position was not set then don't detect motion */
2125 if (window->priv->last_x < 0 || window->priv->last_y < 0)
2126 {
2127 window->priv->last_x = event->x;
2128 window->priv->last_y = event->y;
2129
2130 return FALSE(0);
2131 }
2132
2133 /* just an approximate distance */
2134 distance = MAX (ABS (window->priv->last_x - event->x),((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
2135 ABS (window->priv->last_y - event->y))((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
;
2136
2137 if (distance > min_distance)
2138 {
2139 maybe_handle_activity (window);
2140
2141 window->priv->last_x = -1;
2142 window->priv->last_y = -1;
2143 }
2144
2145 return FALSE(0);
2146}
2147
2148static gboolean
2149gs_window_real_button_press_event (CtkWidget *widget,
2150 CdkEventButton *event)
2151{
2152 GSWindow *window;
2153
2154 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2155 maybe_handle_activity (window);
2156
2157 return FALSE(0);
2158}
2159
2160static gboolean
2161gs_window_real_scroll_event (CtkWidget *widget,
2162 CdkEventScroll *event)
2163{
2164 GSWindow *window;
2165
2166 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2167 maybe_handle_activity (window);
2168
2169 return FALSE(0);
2170}
2171
2172static void
2173gs_window_real_size_request (CtkWidget *widget,
2174 CtkRequisition *requisition)
2175{
2176 GSWindow *window;
2177 CtkBin *bin;
2178 CtkWidget *child;
2179 CdkRectangle old_geometry;
2180 int position_changed = FALSE(0);
2181 int size_changed = FALSE(0);
2182
2183 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2184 bin = CTK_BIN (widget)((((CtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((ctk_bin_get_type ()))))))
;
2185 child = ctk_bin_get_child (bin);
2186
2187 if (child && ctk_widget_get_visible (child))
2188 {
2189 ctk_widget_get_preferred_size (child, requisition, NULL((void*)0));
2190 }
2191
2192 old_geometry = window->priv->geometry;
2193
2194 update_geometry (window);
2195
2196 requisition->width = window->priv->geometry.width;
2197 requisition->height = window->priv->geometry.height;
2198
2199 if (! ctk_widget_get_realized (widget))
2200 {
2201 return;
2202 }
2203
2204 if (old_geometry.width != window->priv->geometry.width ||
2205 old_geometry.height != window->priv->geometry.height)
2206 {
2207 size_changed = TRUE(!(0));
2208 }
2209
2210 if (old_geometry.x != window->priv->geometry.x ||
2211 old_geometry.y != window->priv->geometry.y)
2212 {
2213 position_changed = TRUE(!(0));
2214 }
2215
2216 gs_window_move_resize_window (window, position_changed, size_changed);
2217}
2218
2219static void
2220gs_window_real_get_preferred_width (CtkWidget *widget,
2221 gint *minimal_width,
2222 gint *natural_width)
2223{
2224 CtkRequisition requisition;
2225 gs_window_real_size_request (widget, &requisition);
2226 *minimal_width = *natural_width = requisition.width;
2227}
2228
2229static void
2230gs_window_real_get_preferred_height (CtkWidget *widget,
2231 gint *minimal_height,
2232 gint *natural_height)
2233{
2234 CtkRequisition requisition;
2235 gs_window_real_size_request (widget, &requisition);
2236 *minimal_height = *natural_height = requisition.height;
2237}
2238
2239static gboolean
2240gs_window_real_grab_broken (CtkWidget *widget,
2241 CdkEventGrabBroken *event)
2242{
2243 if (event->grab_window != NULL((void*)0))
2244 {
2245 gs_debug ("Grab broken on window %X %s, new grab on window %X",gs_debug_real (__func__, "gs-window-x11.c", 2248, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (cdk_x11_window_get_xid
(event->grab_window)))
2246 (guint32) CDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2248, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (cdk_x11_window_get_xid
(event->grab_window)))
2247 event->keyboard ? "keyboard" : "pointer",gs_debug_real (__func__, "gs-window-x11.c", 2248, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (cdk_x11_window_get_xid
(event->grab_window)))
2248 (guint32) CDK_WINDOW_XID (event->grab_window))gs_debug_real (__func__, "gs-window-x11.c", 2248, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (cdk_x11_window_get_xid
(event->grab_window)))
;
2249 }
2250 else
2251 {
2252 gs_debug ("Grab broken on window %X %s, new grab is outside application",gs_debug_real (__func__, "gs-window-x11.c", 2254, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2253 (guint32) CDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2254, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2254 event->keyboard ? "keyboard" : "pointer")gs_debug_real (__func__, "gs-window-x11.c", 2254, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (cdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
;
2255 }
2256
2257 return FALSE(0);
2258}
2259
2260gboolean
2261gs_window_is_obscured (GSWindow *window)
2262{
2263 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2264
2265 return window->priv->obscured;
2266}
2267
2268gboolean
2269gs_window_is_dialog_up (GSWindow *window)
2270{
2271 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2272
2273 return window->priv->dialog_up;
2274}
2275
2276static void
2277window_set_obscured (GSWindow *window,
2278 gboolean obscured)
2279{
2280 if (window->priv->obscured == obscured)
2281 {
2282 return;
2283 }
2284
2285 window->priv->obscured = obscured;
2286 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "obscured");
2287}
2288
2289static gboolean
2290gs_window_real_visibility_notify_event (CtkWidget *widget,
2291 CdkEventVisibility *event)
2292{
2293 switch (event->state)
2294 {
2295 case CDK_VISIBILITY_FULLY_OBSCURED:
2296 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)));
2297 break;
2298 case CDK_VISIBILITY_PARTIAL:
2299 break;
2300 case CDK_VISIBILITY_UNOBSCURED:
2301 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, FALSE(0));
2302 break;
2303 default:
2304 break;
2305 }
2306
2307 return FALSE(0);
2308}
2309
2310static void
2311gs_window_class_init (GSWindowClass *klass)
2312{
2313 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2314 CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
2315
2316 object_class->finalize = gs_window_finalize;
2317 object_class->get_property = gs_window_get_property;
2318 object_class->set_property = gs_window_set_property;
2319
2320 widget_class->show = gs_window_real_show;
2321 widget_class->hide = gs_window_real_hide;
2322 widget_class->draw = gs_window_real_draw;
2323 widget_class->realize = gs_window_real_realize;
2324 widget_class->unrealize = gs_window_real_unrealize;
2325 widget_class->key_press_event = gs_window_real_key_press_event;
2326 widget_class->motion_notify_event = gs_window_real_motion_notify_event;
2327 widget_class->button_press_event = gs_window_real_button_press_event;
2328 widget_class->scroll_event = gs_window_real_scroll_event;
2329 widget_class->get_preferred_width = gs_window_real_get_preferred_width;
2330 widget_class->get_preferred_height = gs_window_real_get_preferred_height;
2331 widget_class->grab_broken_event = gs_window_real_grab_broken;
2332 widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
2333
2334 signals [ACTIVITY] =
2335 g_signal_new ("activity",
2336 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2337 G_SIGNAL_RUN_LAST,
2338 G_STRUCT_OFFSET (GSWindowClass, activity)((glong) __builtin_offsetof(GSWindowClass, activity)),
2339 NULL((void*)0),
2340 NULL((void*)0),
2341 gs_marshal_BOOLEAN__VOID,
2342 G_TYPE_BOOLEAN((GType) ((5) << (2))),
2343 0);
2344 signals [DEACTIVATED] =
2345 g_signal_new ("deactivated",
2346 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2347 G_SIGNAL_RUN_LAST,
2348 G_STRUCT_OFFSET (GSWindowClass, deactivated)((glong) __builtin_offsetof(GSWindowClass, deactivated)),
2349 NULL((void*)0),
2350 NULL((void*)0),
2351 g_cclosure_marshal_VOID__VOID,
2352 G_TYPE_NONE((GType) ((1) << (2))),
2353 0);
2354
2355 g_object_class_install_property (object_class,
2356 PROP_OBSCURED,
2357 g_param_spec_boolean ("obscured",
2358 NULL((void*)0),
2359 NULL((void*)0),
2360 FALSE(0),
2361 G_PARAM_READABLE));
2362 g_object_class_install_property (object_class,
2363 PROP_DIALOG_UP,
2364 g_param_spec_boolean ("dialog-up",
2365 NULL((void*)0),
2366 NULL((void*)0),
2367 FALSE(0),
2368 G_PARAM_READABLE));
2369 g_object_class_install_property (object_class,
2370 PROP_LOCK_ENABLED,
2371 g_param_spec_boolean ("lock-enabled",
2372 NULL((void*)0),
2373 NULL((void*)0),
2374 FALSE(0),
2375 G_PARAM_READWRITE));
2376 g_object_class_install_property (object_class,
2377 PROP_LOGOUT_ENABLED,
2378 g_param_spec_boolean ("logout-enabled",
2379 NULL((void*)0),
2380 NULL((void*)0),
2381 FALSE(0),
2382 G_PARAM_READWRITE));
2383 g_object_class_install_property (object_class,
2384 PROP_LOGOUT_TIMEOUT,
2385 g_param_spec_long ("logout-timeout",
2386 NULL((void*)0),
2387 NULL((void*)0),
2388 -1,
2389 G_MAXLONG9223372036854775807L,
2390 0,
2391 G_PARAM_READWRITE));
2392 g_object_class_install_property (object_class,
2393 PROP_LOGOUT_COMMAND,
2394 g_param_spec_string ("logout-command",
2395 NULL((void*)0),
2396 NULL((void*)0),
2397 NULL((void*)0),
2398 G_PARAM_READWRITE));
2399 g_object_class_install_property (object_class,
2400 PROP_STATUS_MESSAGE,
2401 g_param_spec_string ("status-message",
2402 NULL((void*)0),
2403 NULL((void*)0),
2404 NULL((void*)0),
2405 G_PARAM_READWRITE));
2406 g_object_class_install_property (object_class,
2407 PROP_KEYBOARD_ENABLED,
2408 g_param_spec_boolean ("keyboard-enabled",
2409 NULL((void*)0),
2410 NULL((void*)0),
2411 FALSE(0),
2412 G_PARAM_READWRITE));
2413 g_object_class_install_property (object_class,
2414 PROP_KEYBOARD_COMMAND,
2415 g_param_spec_string ("keyboard-command",
2416 NULL((void*)0),
2417 NULL((void*)0),
2418 NULL((void*)0),
2419 G_PARAM_READWRITE));
2420
2421 g_object_class_install_property (object_class,
2422 PROP_MONITOR,
2423 g_param_spec_pointer ("monitor",
2424 "Cdk monitor",
2425 "The monitor (in terms of Cdk) which the window is on",
2426 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
2427}
2428
2429static void
2430create_info_bar (GSWindow *window)
2431{
2432 window->priv->info_bar = ctk_info_bar_new ();
2433 ctk_widget_set_no_show_all (window->priv->info_bar, TRUE(!(0)));
2434 ctk_box_pack_end (CTK_BOX (window->priv->vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_box_get_type ()))))))
, window->priv->info_bar, FALSE(0), FALSE(0), 0);
2435}
2436
2437static gboolean
2438on_drawing_area_draw (CtkWidget *widget,
2439 cairo_t *cr)
2440{
2441 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2442 cairo_set_source_rgb (cr, 0, 0, 0);
2443 cairo_paint (cr);
2444
2445 return FALSE(0);
2446}
2447
2448static void
2449gs_window_init (GSWindow *window)
2450{
2451 window->priv = gs_window_get_instance_private (window);
2452
2453 window->priv->geometry.x = -1;
2454 window->priv->geometry.y = -1;
2455 window->priv->geometry.width = -1;
2456 window->priv->geometry.height = -1;
2457
2458 window->priv->last_x = -1;
2459 window->priv->last_y = -1;
2460
2461 ctk_window_set_decorated (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, FALSE(0));
2462
2463 ctk_window_set_skip_taskbar_hint (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
2464 ctk_window_set_skip_pager_hint (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
2465
2466 ctk_window_set_keep_above (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
2467
2468 ctk_window_fullscreen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
2469
2470 ctk_widget_set_events (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
,
2471 ctk_widget_get_events (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
)
2472 | CDK_POINTER_MOTION_MASK
2473 | CDK_BUTTON_PRESS_MASK
2474 | CDK_BUTTON_RELEASE_MASK
2475 | CDK_KEY_PRESS_MASK
2476 | CDK_KEY_RELEASE_MASK
2477 | CDK_EXPOSURE_MASK
2478 | CDK_VISIBILITY_NOTIFY_MASK
2479 | CDK_ENTER_NOTIFY_MASK
2480 | CDK_LEAVE_NOTIFY_MASK);
2481
2482 window->priv->vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 12);
2483 ctk_widget_show (window->priv->vbox);
2484 ctk_container_add (CTK_CONTAINER (window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_container_get_type ()))))))
, window->priv->vbox);
2485
2486 window->priv->drawing_area = ctk_drawing_area_new ();
2487 ctk_widget_show (window->priv->drawing_area);
2488 ctk_widget_set_app_paintable (window->priv->drawing_area, TRUE(!(0)));
2489 ctk_box_pack_start (CTK_BOX (window->priv->vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((ctk_box_get_type ()))))))
,
2490 window->priv->drawing_area, TRUE(!(0)), TRUE(!(0)), 0);
2491 g_signal_connect (window->priv->drawing_area,g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2492 "draw",g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2493 G_CALLBACK (on_drawing_area_draw),g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2494 NULL)g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
2495 create_info_bar (window);
2496
2497}
2498
2499static void
2500remove_command_watches (GSWindow *window)
2501{
2502 if (window->priv->lock_watch_id != 0)
2503 {
2504 g_source_remove (window->priv->lock_watch_id);
2505 window->priv->lock_watch_id = 0;
2506 }
2507 if (window->priv->keyboard_watch_id != 0)
2508 {
2509 g_source_remove (window->priv->keyboard_watch_id);
2510 window->priv->keyboard_watch_id = 0;
2511 }
2512}
2513
2514static void
2515gs_window_finalize (GObject *object)
2516{
2517 GSWindow *window;
2518
2519 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
2520 g_return_if_fail (GS_IS_WINDOW (object))do{ (void)0; }while (0);
2521
2522 window = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
2523
2524 g_return_if_fail (window->priv != NULL)do{ (void)0; }while (0);
2525
2526 g_free (window->priv->logout_command);
2527 g_free (window->priv->keyboard_command);
2528
2529 if (window->priv->info_bar_timer_id > 0)
2530 {
2531 g_source_remove (window->priv->info_bar_timer_id);
2532 window->priv->info_bar_timer_id = 0;
2533 }
2534
2535 remove_watchdog_timer (window);
2536 remove_popup_dialog_idle (window);
2537
2538 if (window->priv->timer)
2539 {
2540 g_timer_destroy (window->priv->timer);
2541 }
2542
2543 remove_key_events (window);
2544
2545 remove_command_watches (window);
2546
2547 gs_window_dialog_finish (window);
2548
2549 if (window->priv->background_surface)
2550 {
2551 cairo_surface_destroy (window->priv->background_surface);
2552 }
2553
2554 G_OBJECT_CLASS (gs_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
2555}
2556
2557GSWindow *
2558gs_window_new (CdkMonitor *monitor,
2559 gboolean lock_enabled)
2560{
2561 GObject *result;
2562 CdkDisplay *display = cdk_monitor_get_display (monitor);
2563 CdkScreen *screen = cdk_display_get_default_screen (display);
2564
2565 result = g_object_new (GS_TYPE_WINDOW(gs_window_get_type ()),
2566 "type", CTK_WINDOW_POPUP,
2567 "screen", screen,
2568 "monitor", monitor,
2569 "lock-enabled", lock_enabled,
2570 "app-paintable", TRUE(!(0)),
2571 NULL((void*)0));
2572
2573 return GS_WINDOW (result)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((result)), ((gs_window_get_type ()))))))
;
2574}