Merge lp:~noskcaj/ubuntu/trusty/xfdesktop4/merge into lp:ubuntu/trusty/xfdesktop4
- Trusty (14.04)
- merge
- Merge into trusty
Proposed by
Jackson Doak
Status: | Merged |
---|---|
Merge reported by: | Dmitry Shachnev |
Merged at revision: | not available |
Proposed branch: | lp:~noskcaj/ubuntu/trusty/xfdesktop4/merge |
Merge into: | lp:ubuntu/trusty/xfdesktop4 |
Diff against target: |
1819 lines (+1750/-0) 8 files modified
.pc/applied-patches (+1/-0) .pc/git-fix-segfault-on-session-start.patch/src/xfce-desktop.c (+1695/-0) .pc/xubuntu_improve-nautilus-interactions.patch/src/xfce-desktop.c (+4/-0) .pc/xubuntu_set-accountsservice-user-bg.patch/src/xfce-desktop.c (+4/-0) debian/changelog (+18/-0) debian/patches/git-fix-segfault-on-session-start.patch (+23/-0) debian/patches/series (+1/-0) src/xfce-desktop.c (+4/-0) |
To merge this branch: | bzr merge lp:~noskcaj/ubuntu/trusty/xfdesktop4/merge |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dmitry Shachnev | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+208918@code.launchpad.net |
Commit message
Description of the change
Fixes xubuntu's current biggest bug
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.pc/applied-patches' | |||
2 | --- .pc/applied-patches 2014-01-22 11:02:26 +0000 | |||
3 | +++ .pc/applied-patches 2014-03-01 05:37:37 +0000 | |||
4 | @@ -1,2 +1,3 @@ | |||
5 | 1 | git-fix-segfault-on-session-start.patch | ||
6 | 1 | xubuntu_set-accountsservice-user-bg.patch | 2 | xubuntu_set-accountsservice-user-bg.patch |
7 | 2 | xubuntu_improve-nautilus-interactions.patch | 3 | xubuntu_improve-nautilus-interactions.patch |
8 | 3 | 4 | ||
9 | === added directory '.pc/git-fix-segfault-on-session-start.patch' | |||
10 | === added file '.pc/git-fix-segfault-on-session-start.patch/.timestamp' | |||
11 | === added directory '.pc/git-fix-segfault-on-session-start.patch/src' | |||
12 | === added file '.pc/git-fix-segfault-on-session-start.patch/src/xfce-desktop.c' | |||
13 | --- .pc/git-fix-segfault-on-session-start.patch/src/xfce-desktop.c 1970-01-01 00:00:00 +0000 | |||
14 | +++ .pc/git-fix-segfault-on-session-start.patch/src/xfce-desktop.c 2014-03-01 05:37:37 +0000 | |||
15 | @@ -0,0 +1,1695 @@ | |||
16 | 1 | /* | ||
17 | 2 | * xfdesktop - xfce4's desktop manager | ||
18 | 3 | * | ||
19 | 4 | * Copyright (c) 2004-2007 Brian Tarricone, <bjt23@cornell.edu> | ||
20 | 5 | * | ||
21 | 6 | * This program is free software; you can redistribute it and/or modify | ||
22 | 7 | * it under the terms of the GNU General Public License as published by | ||
23 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
24 | 9 | * (at your option) any later version. | ||
25 | 10 | * | ||
26 | 11 | * This program is distributed in the hope that it will be useful, | ||
27 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
28 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
29 | 14 | * GNU Library General Public License for more details. | ||
30 | 15 | * | ||
31 | 16 | * You should have received a copy of the GNU General Public License | ||
32 | 17 | * along with this program; if not, write to the Free Software Foundation, | ||
33 | 18 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
34 | 19 | * | ||
35 | 20 | * Random portions taken from or inspired by the original xfdesktop for xfce4: | ||
36 | 21 | * Copyright (C) 2002-2003 Jasper Huijsmans (huysmans@users.sourceforge.net) | ||
37 | 22 | * Copyright (C) 2003 Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de> | ||
38 | 23 | */ | ||
39 | 24 | |||
40 | 25 | #ifdef HAVE_CONFIG_H | ||
41 | 26 | #include <config.h> | ||
42 | 27 | #endif | ||
43 | 28 | |||
44 | 29 | #include <stdio.h> | ||
45 | 30 | |||
46 | 31 | #ifdef HAVE_STDLIB_H | ||
47 | 32 | #include <stdlib.h> | ||
48 | 33 | #endif | ||
49 | 34 | |||
50 | 35 | #ifdef HAVE_STRING_H | ||
51 | 36 | #include <string.h> | ||
52 | 37 | #endif | ||
53 | 38 | |||
54 | 39 | #ifdef HAVE_SYS_TYPES_H | ||
55 | 40 | #include <sys/types.h> | ||
56 | 41 | #endif | ||
57 | 42 | #ifdef HAVE_SYS_STAT_H | ||
58 | 43 | #include <sys/stat.h> | ||
59 | 44 | #endif | ||
60 | 45 | #ifdef HAVE_UNISTD_H | ||
61 | 46 | #include <unistd.h> | ||
62 | 47 | #endif | ||
63 | 48 | |||
64 | 49 | #ifdef HAVE_FCNTL_H | ||
65 | 50 | #include <fcntl.h> | ||
66 | 51 | #endif | ||
67 | 52 | |||
68 | 53 | #include <ctype.h> | ||
69 | 54 | #include <errno.h> | ||
70 | 55 | |||
71 | 56 | #ifdef HAVE_TIME_H | ||
72 | 57 | #include <time.h> | ||
73 | 58 | #endif | ||
74 | 59 | |||
75 | 60 | #include <X11/Xlib.h> | ||
76 | 61 | #include <X11/Xatom.h> | ||
77 | 62 | |||
78 | 63 | #include <glib.h> | ||
79 | 64 | #include <gdk/gdkx.h> | ||
80 | 65 | #include <gtk/gtk.h> | ||
81 | 66 | |||
82 | 67 | #ifdef ENABLE_DESKTOP_ICONS | ||
83 | 68 | #include "xfdesktop-icon-view.h" | ||
84 | 69 | #include "xfdesktop-window-icon-manager.h" | ||
85 | 70 | # ifdef ENABLE_FILE_ICONS | ||
86 | 71 | # include "xfdesktop-file-icon-manager.h" | ||
87 | 72 | # include "xfdesktop-special-file-icon.h" | ||
88 | 73 | # endif | ||
89 | 74 | #endif | ||
90 | 75 | |||
91 | 76 | #include <libxfce4util/libxfce4util.h> | ||
92 | 77 | #include <libxfce4ui/libxfce4ui.h> | ||
93 | 78 | |||
94 | 79 | #include <xfconf/xfconf.h> | ||
95 | 80 | #include <libwnck/libwnck.h> | ||
96 | 81 | |||
97 | 82 | #include "xfdesktop-common.h" | ||
98 | 83 | #include "xfce-desktop.h" | ||
99 | 84 | #include "xfce-desktop-enum-types.h" | ||
100 | 85 | #include "xfce-workspace.h" | ||
101 | 86 | |||
102 | 87 | /* disable setting the x background for bug 7442 */ | ||
103 | 88 | //#define DISABLE_FOR_BUG7442 | ||
104 | 89 | |||
105 | 90 | struct _XfceDesktopPriv | ||
106 | 91 | { | ||
107 | 92 | GdkScreen *gscreen; | ||
108 | 93 | WnckScreen *wnck_screen; | ||
109 | 94 | gboolean updates_frozen; | ||
110 | 95 | |||
111 | 96 | XfconfChannel *channel; | ||
112 | 97 | gchar *property_prefix; | ||
113 | 98 | |||
114 | 99 | GdkPixmap *bg_pixmap; | ||
115 | 100 | |||
116 | 101 | gint nworkspaces; | ||
117 | 102 | XfceWorkspace **workspaces; | ||
118 | 103 | gint current_workspace; | ||
119 | 104 | |||
120 | 105 | gboolean single_workspace_mode; | ||
121 | 106 | gint single_workspace_num; | ||
122 | 107 | |||
123 | 108 | SessionLogoutFunc session_logout_func; | ||
124 | 109 | |||
125 | 110 | guint32 grab_time; | ||
126 | 111 | |||
127 | 112 | #ifdef ENABLE_DESKTOP_ICONS | ||
128 | 113 | XfceDesktopIconStyle icons_style; | ||
129 | 114 | gboolean icons_font_size_set; | ||
130 | 115 | guint icons_font_size; | ||
131 | 116 | guint icons_size; | ||
132 | 117 | gint style_refresh_timer; | ||
133 | 118 | GtkWidget *icon_view; | ||
134 | 119 | gdouble system_font_size; | ||
135 | 120 | #endif | ||
136 | 121 | }; | ||
137 | 122 | |||
138 | 123 | enum | ||
139 | 124 | { | ||
140 | 125 | SIG_POPULATE_ROOT_MENU = 0, | ||
141 | 126 | SIG_POPULATE_SECONDARY_ROOT_MENU, | ||
142 | 127 | N_SIGNALS | ||
143 | 128 | }; | ||
144 | 129 | |||
145 | 130 | enum | ||
146 | 131 | { | ||
147 | 132 | PROP_0 = 0, | ||
148 | 133 | #ifdef ENABLE_DESKTOP_ICONS | ||
149 | 134 | PROP_ICON_STYLE, | ||
150 | 135 | PROP_ICON_SIZE, | ||
151 | 136 | PROP_ICON_FONT_SIZE, | ||
152 | 137 | PROP_ICON_FONT_SIZE_SET, | ||
153 | 138 | #endif | ||
154 | 139 | PROP_SINGLE_WORKSPACE_MODE, | ||
155 | 140 | PROP_SINGLE_WORKSPACE_NUMBER, | ||
156 | 141 | }; | ||
157 | 142 | |||
158 | 143 | |||
159 | 144 | static void xfce_desktop_finalize(GObject *object); | ||
160 | 145 | static void xfce_desktop_set_property(GObject *object, | ||
161 | 146 | guint property_id, | ||
162 | 147 | const GValue *value, | ||
163 | 148 | GParamSpec *pspec); | ||
164 | 149 | static void xfce_desktop_get_property(GObject *object, | ||
165 | 150 | guint property_id, | ||
166 | 151 | GValue *value, | ||
167 | 152 | GParamSpec *pspec); | ||
168 | 153 | |||
169 | 154 | static void xfce_desktop_realize(GtkWidget *widget); | ||
170 | 155 | static void xfce_desktop_unrealize(GtkWidget *widget); | ||
171 | 156 | static gboolean xfce_desktop_button_press_event(GtkWidget *widget, | ||
172 | 157 | GdkEventButton *evt); | ||
173 | 158 | static gboolean xfce_desktop_button_release_event(GtkWidget *widget, | ||
174 | 159 | GdkEventButton *evt); | ||
175 | 160 | static gboolean xfce_desktop_popup_menu(GtkWidget *widget); | ||
176 | 161 | |||
177 | 162 | static gboolean xfce_desktop_expose(GtkWidget *w, | ||
178 | 163 | GdkEventExpose *evt); | ||
179 | 164 | static gboolean xfce_desktop_delete_event(GtkWidget *w, | ||
180 | 165 | GdkEventAny *evt); | ||
181 | 166 | static void xfce_desktop_style_set(GtkWidget *w, | ||
182 | 167 | GtkStyle *old_style); | ||
183 | 168 | |||
184 | 169 | static void xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, | ||
185 | 170 | gboolean single_workspace); | ||
186 | 171 | static void xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, | ||
187 | 172 | gint workspace_num); | ||
188 | 173 | |||
189 | 174 | static gboolean xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop); | ||
190 | 175 | static gint xfce_desktop_get_current_workspace(XfceDesktop *desktop); | ||
191 | 176 | |||
192 | 177 | static guint signals[N_SIGNALS] = { 0, }; | ||
193 | 178 | |||
194 | 179 | /* private functions */ | ||
195 | 180 | |||
196 | 181 | #ifdef ENABLE_DESKTOP_ICONS | ||
197 | 182 | static gdouble | ||
198 | 183 | xfce_desktop_ensure_system_font_size(XfceDesktop *desktop) | ||
199 | 184 | { | ||
200 | 185 | GdkScreen *gscreen; | ||
201 | 186 | GtkSettings *settings; | ||
202 | 187 | gchar *font_name = NULL; | ||
203 | 188 | PangoFontDescription *pfd; | ||
204 | 189 | |||
205 | 190 | gscreen = gtk_widget_get_screen(GTK_WIDGET(desktop)); | ||
206 | 191 | |||
207 | 192 | settings = gtk_settings_get_for_screen(gscreen); | ||
208 | 193 | g_object_get(G_OBJECT(settings), "gtk-font-name", &font_name, NULL); | ||
209 | 194 | |||
210 | 195 | pfd = pango_font_description_from_string(font_name); | ||
211 | 196 | desktop->priv->system_font_size = pango_font_description_get_size(pfd); | ||
212 | 197 | /* FIXME: this seems backwards from the documentation */ | ||
213 | 198 | if(!pango_font_description_get_size_is_absolute(pfd)) { | ||
214 | 199 | DBG("dividing by PANGO_SCALE"); | ||
215 | 200 | desktop->priv->system_font_size /= PANGO_SCALE; | ||
216 | 201 | } | ||
217 | 202 | DBG("system font size is %.05f", desktop->priv->system_font_size); | ||
218 | 203 | |||
219 | 204 | g_free(font_name); | ||
220 | 205 | pango_font_description_free(pfd); | ||
221 | 206 | |||
222 | 207 | return desktop->priv->system_font_size; | ||
223 | 208 | } | ||
224 | 209 | |||
225 | 210 | static void | ||
226 | 211 | xfce_desktop_setup_icon_view(XfceDesktop *desktop) | ||
227 | 212 | { | ||
228 | 213 | XfdesktopIconViewManager *manager = NULL; | ||
229 | 214 | |||
230 | 215 | switch(desktop->priv->icons_style) { | ||
231 | 216 | case XFCE_DESKTOP_ICON_STYLE_NONE: | ||
232 | 217 | /* nada */ | ||
233 | 218 | break; | ||
234 | 219 | |||
235 | 220 | case XFCE_DESKTOP_ICON_STYLE_WINDOWS: | ||
236 | 221 | manager = xfdesktop_window_icon_manager_new(desktop->priv->gscreen); | ||
237 | 222 | break; | ||
238 | 223 | |||
239 | 224 | #ifdef ENABLE_FILE_ICONS | ||
240 | 225 | case XFCE_DESKTOP_ICON_STYLE_FILES: | ||
241 | 226 | { | ||
242 | 227 | GFile *file; | ||
243 | 228 | const gchar *desktop_path; | ||
244 | 229 | |||
245 | 230 | desktop_path = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP); | ||
246 | 231 | file = g_file_new_for_path(desktop_path); | ||
247 | 232 | manager = xfdesktop_file_icon_manager_new(file, desktop->priv->channel); | ||
248 | 233 | g_object_unref(file); | ||
249 | 234 | } | ||
250 | 235 | break; | ||
251 | 236 | #endif | ||
252 | 237 | |||
253 | 238 | default: | ||
254 | 239 | g_critical("Unusable XfceDesktopIconStyle: %d. Unable to " \ | ||
255 | 240 | "display desktop icons.", | ||
256 | 241 | desktop->priv->icons_style); | ||
257 | 242 | break; | ||
258 | 243 | } | ||
259 | 244 | |||
260 | 245 | if(manager) { | ||
261 | 246 | xfce_desktop_ensure_system_font_size(desktop); | ||
262 | 247 | |||
263 | 248 | desktop->priv->icon_view = xfdesktop_icon_view_new(manager); | ||
264 | 249 | /* If the user set a custom font size, use it. Otherwise use the system | ||
265 | 250 | * font size */ | ||
266 | 251 | xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
267 | 252 | (!desktop->priv->icons_font_size_set) | ||
268 | 253 | ? desktop->priv->system_font_size | ||
269 | 254 | : desktop->priv->icons_font_size); | ||
270 | 255 | if(desktop->priv->icons_size > 0) { | ||
271 | 256 | xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
272 | 257 | desktop->priv->icons_size); | ||
273 | 258 | } | ||
274 | 259 | gtk_widget_show(desktop->priv->icon_view); | ||
275 | 260 | gtk_container_add(GTK_CONTAINER(desktop), desktop->priv->icon_view); | ||
276 | 261 | } | ||
277 | 262 | |||
278 | 263 | gtk_widget_queue_draw(GTK_WIDGET(desktop)); | ||
279 | 264 | } | ||
280 | 265 | #endif | ||
281 | 266 | |||
282 | 267 | static void | ||
283 | 268 | set_imgfile_root_property(XfceDesktop *desktop, const gchar *filename, | ||
284 | 269 | gint monitor) | ||
285 | 270 | { | ||
286 | 271 | gchar property_name[128]; | ||
287 | 272 | |||
288 | 273 | gdk_error_trap_push(); | ||
289 | 274 | |||
290 | 275 | g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, monitor); | ||
291 | 276 | if(filename) { | ||
292 | 277 | gdk_property_change(gdk_screen_get_root_window(desktop->priv->gscreen), | ||
293 | 278 | gdk_atom_intern(property_name, FALSE), | ||
294 | 279 | gdk_x11_xatom_to_atom(XA_STRING), 8, | ||
295 | 280 | GDK_PROP_MODE_REPLACE, | ||
296 | 281 | (guchar *)filename, strlen(filename)+1); | ||
297 | 282 | } else { | ||
298 | 283 | gdk_property_delete(gdk_screen_get_root_window(desktop->priv->gscreen), | ||
299 | 284 | gdk_atom_intern(property_name, FALSE)); | ||
300 | 285 | } | ||
301 | 286 | |||
302 | 287 | gdk_error_trap_pop(); | ||
303 | 288 | } | ||
304 | 289 | |||
305 | 290 | static void | ||
306 | 291 | set_real_root_window_pixmap(GdkScreen *gscreen, | ||
307 | 292 | GdkPixmap *pmap) | ||
308 | 293 | { | ||
309 | 294 | #ifndef DISABLE_FOR_BUG7442 | ||
310 | 295 | Window xid; | ||
311 | 296 | GdkWindow *groot; | ||
312 | 297 | |||
313 | 298 | xid = GDK_DRAWABLE_XID(pmap); | ||
314 | 299 | groot = gdk_screen_get_root_window(gscreen); | ||
315 | 300 | |||
316 | 301 | gdk_error_trap_push(); | ||
317 | 302 | |||
318 | 303 | /* set root property for transparent Eterms */ | ||
319 | 304 | gdk_property_change(groot, | ||
320 | 305 | gdk_atom_intern("_XROOTPMAP_ID", FALSE), | ||
321 | 306 | gdk_atom_intern("PIXMAP", FALSE), 32, | ||
322 | 307 | GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); | ||
323 | 308 | /* and set the root window's BG pixmap, because aterm is somewhat lame. */ | ||
324 | 309 | gdk_window_set_back_pixmap(groot, pmap, FALSE); | ||
325 | 310 | /* there really should be a standard for this crap... */ | ||
326 | 311 | |||
327 | 312 | gdk_error_trap_pop(); | ||
328 | 313 | #endif | ||
329 | 314 | } | ||
330 | 315 | |||
331 | 316 | static GdkPixmap * | ||
332 | 317 | create_bg_pixmap(GdkScreen *gscreen, gpointer user_data) | ||
333 | 318 | { | ||
334 | 319 | XfceDesktop *desktop = user_data; | ||
335 | 320 | gint w, h; | ||
336 | 321 | |||
337 | 322 | TRACE("entering"); | ||
338 | 323 | |||
339 | 324 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), NULL); | ||
340 | 325 | |||
341 | 326 | /* If the workspaces haven't been created yet there's no need to do the | ||
342 | 327 | * background pixmap */ | ||
343 | 328 | if(desktop->priv->workspaces == NULL) { | ||
344 | 329 | DBG("exiting, desktop->priv->workspaces == NULL"); | ||
345 | 330 | return NULL; | ||
346 | 331 | } | ||
347 | 332 | |||
348 | 333 | TRACE("really entering"); | ||
349 | 334 | |||
350 | 335 | w = gdk_screen_get_width(gscreen); | ||
351 | 336 | h = gdk_screen_get_height(gscreen); | ||
352 | 337 | gtk_widget_set_size_request(GTK_WIDGET(desktop), w, h); | ||
353 | 338 | gtk_window_resize(GTK_WINDOW(desktop), w, h); | ||
354 | 339 | |||
355 | 340 | if(desktop->priv->bg_pixmap) | ||
356 | 341 | g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); | ||
357 | 342 | desktop->priv->bg_pixmap = gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(GTK_WIDGET(desktop))), | ||
358 | 343 | w, h, -1); | ||
359 | 344 | |||
360 | 345 | if(!GDK_IS_PIXMAP(desktop->priv->bg_pixmap)) | ||
361 | 346 | return NULL; | ||
362 | 347 | |||
363 | 348 | gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), | ||
364 | 349 | desktop->priv->bg_pixmap, FALSE); | ||
365 | 350 | |||
366 | 351 | return desktop->priv->bg_pixmap; | ||
367 | 352 | } | ||
368 | 353 | |||
369 | 354 | static void | ||
370 | 355 | backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data) | ||
371 | 356 | { | ||
372 | 357 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
373 | 358 | GdkPixmap *pmap = desktop->priv->bg_pixmap; | ||
374 | 359 | GdkScreen *gscreen = desktop->priv->gscreen; | ||
375 | 360 | GdkRectangle rect; | ||
376 | 361 | GdkRegion *clip_region = NULL; | ||
377 | 362 | gint i, monitor = -1, current_workspace; | ||
378 | 363 | #ifdef G_ENABLE_DEBUG | ||
379 | 364 | gchar *monitor_name = NULL; | ||
380 | 365 | #endif | ||
381 | 366 | |||
382 | 367 | TRACE("entering"); | ||
383 | 368 | |||
384 | 369 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
385 | 370 | |||
386 | 371 | if(desktop->priv->updates_frozen || !gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
387 | 372 | return; | ||
388 | 373 | |||
389 | 374 | TRACE("really entering"); | ||
390 | 375 | |||
391 | 376 | current_workspace = xfce_desktop_get_current_workspace(desktop); | ||
392 | 377 | |||
393 | 378 | /* Find out which monitor the backdrop is on */ | ||
394 | 379 | for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { | ||
395 | 380 | if(backdrop == xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i)) { | ||
396 | 381 | monitor = i; | ||
397 | 382 | break; | ||
398 | 383 | } | ||
399 | 384 | } | ||
400 | 385 | if(monitor == -1) | ||
401 | 386 | return; | ||
402 | 387 | |||
403 | 388 | #ifdef G_ENABLE_DEBUG | ||
404 | 389 | monitor_name = gdk_screen_get_monitor_plug_name(gscreen, monitor); | ||
405 | 390 | |||
406 | 391 | DBG("backdrop changed for workspace %d, monitor %d (%s)", current_workspace, monitor, monitor_name); | ||
407 | 392 | |||
408 | 393 | g_free(monitor_name); | ||
409 | 394 | #endif | ||
410 | 395 | |||
411 | 396 | if(xfce_desktop_get_n_monitors(desktop) > 1 | ||
412 | 397 | && xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { | ||
413 | 398 | /* Spanning screens */ | ||
414 | 399 | GdkRectangle monitor_rect; | ||
415 | 400 | |||
416 | 401 | gdk_screen_get_monitor_geometry(gscreen, 0, &rect); | ||
417 | 402 | /* Get the lowest x and y value for all the monitors in | ||
418 | 403 | * case none of them start at 0,0 for whatever reason. | ||
419 | 404 | */ | ||
420 | 405 | for(i = 1; i < xfce_desktop_get_n_monitors(desktop); i++) { | ||
421 | 406 | gdk_screen_get_monitor_geometry(gscreen, i, &monitor_rect); | ||
422 | 407 | |||
423 | 408 | if(monitor_rect.x < rect.x) | ||
424 | 409 | rect.x = monitor_rect.x; | ||
425 | 410 | if(monitor_rect.y < rect.y) | ||
426 | 411 | rect.y = monitor_rect.y; | ||
427 | 412 | } | ||
428 | 413 | |||
429 | 414 | rect.width = gdk_screen_get_width(gscreen); | ||
430 | 415 | rect.height = gdk_screen_get_height(gscreen); | ||
431 | 416 | DBG("xinerama_stretch x %d, y %d, width %d, height %d", | ||
432 | 417 | rect.x, rect.y, rect.width, rect.height); | ||
433 | 418 | } else { | ||
434 | 419 | gdk_screen_get_monitor_geometry(gscreen, monitor, &rect); | ||
435 | 420 | DBG("monitor x %d, y %d, width %d, height %d", | ||
436 | 421 | rect.x, rect.y, rect.width, rect.height); | ||
437 | 422 | } | ||
438 | 423 | |||
439 | 424 | xfce_backdrop_set_size(backdrop, rect.width, rect.height); | ||
440 | 425 | |||
441 | 426 | if(monitor > 0 | ||
442 | 427 | && !xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { | ||
443 | 428 | clip_region = gdk_region_rectangle(&rect); | ||
444 | 429 | |||
445 | 430 | DBG("clip_region: x: %d, y: %d, w: %d, h: %d", | ||
446 | 431 | rect.x, rect.y, rect.width, rect.height); | ||
447 | 432 | |||
448 | 433 | /* If we are not monitor 0 on a multi-monitor setup we need to subtract | ||
449 | 434 | * all the previous monitor regions so we don't draw over them. This | ||
450 | 435 | * should prevent the overlap and double backdrop drawing bugs. | ||
451 | 436 | */ | ||
452 | 437 | for(i = 0; i < monitor; i++) { | ||
453 | 438 | GdkRectangle previous_monitor; | ||
454 | 439 | GdkRegion *previous_region; | ||
455 | 440 | gdk_screen_get_monitor_geometry(gscreen, i, &previous_monitor); | ||
456 | 441 | |||
457 | 442 | DBG("previous_monitor: x: %d, y: %d, w: %d, h: %d", | ||
458 | 443 | previous_monitor.x, previous_monitor.y, | ||
459 | 444 | previous_monitor.width, previous_monitor.height); | ||
460 | 445 | |||
461 | 446 | previous_region = gdk_region_rectangle(&previous_monitor); | ||
462 | 447 | |||
463 | 448 | gdk_region_subtract(clip_region, previous_region); | ||
464 | 449 | |||
465 | 450 | gdk_region_destroy(previous_region); | ||
466 | 451 | } | ||
467 | 452 | } | ||
468 | 453 | |||
469 | 454 | if(clip_region != NULL) { | ||
470 | 455 | /* Update the area to redraw to limit the icons/area painted */ | ||
471 | 456 | gdk_region_get_clipbox(clip_region, &rect); | ||
472 | 457 | DBG("area to update: x: %d, y: %d, w: %d, h: %d", | ||
473 | 458 | rect.x, rect.y, rect.width, rect.height); | ||
474 | 459 | } | ||
475 | 460 | |||
476 | 461 | if(rect.width != 0 && rect.height != 0) { | ||
477 | 462 | /* get the composited backdrop pixmap */ | ||
478 | 463 | GdkPixbuf *pix = xfce_backdrop_get_pixbuf(backdrop); | ||
479 | 464 | cairo_t *cr; | ||
480 | 465 | |||
481 | 466 | /* create the backdrop if needed */ | ||
482 | 467 | if(!pix) { | ||
483 | 468 | xfce_backdrop_generate_async(backdrop); | ||
484 | 469 | |||
485 | 470 | if(clip_region != NULL) | ||
486 | 471 | gdk_region_destroy(clip_region); | ||
487 | 472 | |||
488 | 473 | return; | ||
489 | 474 | } | ||
490 | 475 | |||
491 | 476 | /* Create the background pixmap if it isn't already */ | ||
492 | 477 | if(!GDK_IS_PIXMAP(pmap)) { | ||
493 | 478 | pmap = create_bg_pixmap(gscreen, desktop); | ||
494 | 479 | |||
495 | 480 | if(!GDK_IS_PIXMAP(pmap)) { | ||
496 | 481 | g_object_unref(pix); | ||
497 | 482 | |||
498 | 483 | if(clip_region != NULL) | ||
499 | 484 | gdk_region_destroy(clip_region); | ||
500 | 485 | |||
501 | 486 | return; | ||
502 | 487 | } | ||
503 | 488 | } | ||
504 | 489 | |||
505 | 490 | cr = gdk_cairo_create(GDK_DRAWABLE(pmap)); | ||
506 | 491 | gdk_cairo_set_source_pixbuf(cr, pix, rect.x, rect.y); | ||
507 | 492 | |||
508 | 493 | /* clip the area so we don't draw over a previous wallpaper */ | ||
509 | 494 | if(clip_region != NULL) { | ||
510 | 495 | gdk_cairo_region(cr, clip_region); | ||
511 | 496 | cairo_clip(cr); | ||
512 | 497 | } | ||
513 | 498 | |||
514 | 499 | cairo_paint(cr); | ||
515 | 500 | |||
516 | 501 | /* tell gtk to redraw the repainted area */ | ||
517 | 502 | gtk_widget_queue_draw_area(GTK_WIDGET(desktop), rect.x, rect.y, | ||
518 | 503 | rect.width, rect.height); | ||
519 | 504 | |||
520 | 505 | set_imgfile_root_property(desktop, | ||
521 | 506 | xfce_backdrop_get_image_filename(backdrop), | ||
522 | 507 | monitor); | ||
523 | 508 | |||
524 | 509 | /* do this again so apps watching the root win notice the update */ | ||
525 | 510 | set_real_root_window_pixmap(gscreen, pmap); | ||
526 | 511 | |||
527 | 512 | g_object_unref(G_OBJECT(pix)); | ||
528 | 513 | cairo_destroy(cr); | ||
529 | 514 | gtk_widget_show(GTK_WIDGET(desktop)); | ||
530 | 515 | } | ||
531 | 516 | |||
532 | 517 | if(clip_region != NULL) | ||
533 | 518 | gdk_region_destroy(clip_region); | ||
534 | 519 | } | ||
535 | 520 | |||
536 | 521 | static void | ||
537 | 522 | screen_size_changed_cb(GdkScreen *gscreen, gpointer user_data) | ||
538 | 523 | { | ||
539 | 524 | XfceDesktop *desktop = user_data; | ||
540 | 525 | gint current_workspace; | ||
541 | 526 | |||
542 | 527 | TRACE("entering"); | ||
543 | 528 | |||
544 | 529 | current_workspace = xfce_desktop_get_current_workspace(desktop); | ||
545 | 530 | |||
546 | 531 | if(desktop->priv->nworkspaces <= current_workspace) | ||
547 | 532 | return; | ||
548 | 533 | |||
549 | 534 | if(current_workspace < 0) | ||
550 | 535 | return; | ||
551 | 536 | |||
552 | 537 | /* release the bg_pixmap since the dimensions may have changed */ | ||
553 | 538 | if(desktop->priv->bg_pixmap) { | ||
554 | 539 | g_object_unref(desktop->priv->bg_pixmap); | ||
555 | 540 | desktop->priv->bg_pixmap = NULL; | ||
556 | 541 | } | ||
557 | 542 | |||
558 | 543 | /* special case for 1 backdrop to handle xinerama stretching */ | ||
559 | 544 | if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[current_workspace])) { | ||
560 | 545 | backdrop_changed_cb(xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], 0), desktop); | ||
561 | 546 | } else { | ||
562 | 547 | gint i; | ||
563 | 548 | |||
564 | 549 | for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { | ||
565 | 550 | XfceBackdrop *current_backdrop; | ||
566 | 551 | current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); | ||
567 | 552 | backdrop_changed_cb(current_backdrop, desktop); | ||
568 | 553 | } | ||
569 | 554 | } | ||
570 | 555 | } | ||
571 | 556 | |||
572 | 557 | static void | ||
573 | 558 | screen_composited_changed_cb(GdkScreen *gscreen, | ||
574 | 559 | gpointer user_data) | ||
575 | 560 | { | ||
576 | 561 | TRACE("entering"); | ||
577 | 562 | /* fake a screen size changed, so the background is properly set */ | ||
578 | 563 | screen_size_changed_cb(gscreen, user_data); | ||
579 | 564 | } | ||
580 | 565 | |||
581 | 566 | static void | ||
582 | 567 | xfce_desktop_monitors_changed(GdkScreen *gscreen, | ||
583 | 568 | gpointer user_data) | ||
584 | 569 | { | ||
585 | 570 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
586 | 571 | gint i; | ||
587 | 572 | |||
588 | 573 | TRACE("entering"); | ||
589 | 574 | |||
590 | 575 | /* Update the workspaces */ | ||
591 | 576 | for(i = 0; i < desktop->priv->nworkspaces; i++) { | ||
592 | 577 | xfce_workspace_monitors_changed(desktop->priv->workspaces[i], | ||
593 | 578 | gscreen); | ||
594 | 579 | } | ||
595 | 580 | |||
596 | 581 | /* fake a screen size changed, so the background is properly set */ | ||
597 | 582 | screen_size_changed_cb(gscreen, user_data); | ||
598 | 583 | } | ||
599 | 584 | |||
600 | 585 | static void | ||
601 | 586 | workspace_backdrop_changed_cb(XfceWorkspace *workspace, | ||
602 | 587 | XfceBackdrop *backdrop, | ||
603 | 588 | gpointer user_data) | ||
604 | 589 | { | ||
605 | 590 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
606 | 591 | |||
607 | 592 | TRACE("entering"); | ||
608 | 593 | |||
609 | 594 | g_return_if_fail(XFCE_IS_WORKSPACE(workspace) && XFCE_IS_BACKDROP(backdrop)); | ||
610 | 595 | |||
611 | 596 | if(xfce_desktop_get_current_workspace(desktop) == xfce_workspace_get_workspace_num(workspace)) | ||
612 | 597 | backdrop_changed_cb(backdrop, user_data); | ||
613 | 598 | } | ||
614 | 599 | |||
615 | 600 | static void | ||
616 | 601 | workspace_changed_cb(WnckScreen *wnck_screen, | ||
617 | 602 | WnckWorkspace *previously_active_space, | ||
618 | 603 | gpointer user_data) | ||
619 | 604 | { | ||
620 | 605 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
621 | 606 | gint current_workspace, new_workspace, i; | ||
622 | 607 | XfceBackdrop *new_backdrop; | ||
623 | 608 | |||
624 | 609 | TRACE("entering"); | ||
625 | 610 | |||
626 | 611 | /* Ignore workspace changes in single workspace mode so long as we | ||
627 | 612 | * already have the bg_pixmap loaded */ | ||
628 | 613 | if(xfce_desktop_get_single_workspace_mode(desktop) && desktop->priv->bg_pixmap) | ||
629 | 614 | return; | ||
630 | 615 | |||
631 | 616 | current_workspace = desktop->priv->current_workspace; | ||
632 | 617 | new_workspace = xfce_desktop_get_current_workspace(desktop); | ||
633 | 618 | |||
634 | 619 | if(new_workspace < 0 || new_workspace >= desktop->priv->nworkspaces) | ||
635 | 620 | return; | ||
636 | 621 | |||
637 | 622 | desktop->priv->current_workspace = new_workspace; | ||
638 | 623 | |||
639 | 624 | DBG("current_workspace %d, new_workspace %d", | ||
640 | 625 | current_workspace, new_workspace); | ||
641 | 626 | |||
642 | 627 | for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { | ||
643 | 628 | /* Sanity check */ | ||
644 | 629 | if(current_workspace < desktop->priv->nworkspaces && current_workspace >= 0) { | ||
645 | 630 | /* update! */ | ||
646 | 631 | new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); | ||
647 | 632 | backdrop_changed_cb(new_backdrop, user_data); | ||
648 | 633 | } else { | ||
649 | 634 | /* If current_workspace was removed or never existed, get the new | ||
650 | 635 | * backdrop and apply it */ | ||
651 | 636 | new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i); | ||
652 | 637 | backdrop_changed_cb(new_backdrop, user_data); | ||
653 | 638 | } | ||
654 | 639 | |||
655 | 640 | /* When we're spanning screens we only care about the first monitor */ | ||
656 | 641 | if(xfce_workspace_get_xinerama_stretch(desktop->priv->workspaces[new_workspace])) | ||
657 | 642 | break; | ||
658 | 643 | } | ||
659 | 644 | } | ||
660 | 645 | |||
661 | 646 | static void | ||
662 | 647 | workspace_created_cb(WnckScreen *wnck_screen, | ||
663 | 648 | WnckWorkspace *new_workspace, | ||
664 | 649 | gpointer user_data) | ||
665 | 650 | { | ||
666 | 651 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
667 | 652 | gint nlast_workspace; | ||
668 | 653 | TRACE("entering"); | ||
669 | 654 | |||
670 | 655 | nlast_workspace = desktop->priv->nworkspaces; | ||
671 | 656 | |||
672 | 657 | /* add one more workspace */ | ||
673 | 658 | desktop->priv->nworkspaces = nlast_workspace + 1; | ||
674 | 659 | |||
675 | 660 | /* allocate size for it */ | ||
676 | 661 | desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, | ||
677 | 662 | desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); | ||
678 | 663 | |||
679 | 664 | /* create the new workspace and set it up */ | ||
680 | 665 | desktop->priv->workspaces[nlast_workspace] = xfce_workspace_new(desktop->priv->gscreen, | ||
681 | 666 | desktop->priv->channel, | ||
682 | 667 | desktop->priv->property_prefix, | ||
683 | 668 | nlast_workspace); | ||
684 | 669 | |||
685 | 670 | /* Tell workspace whether to cache pixbufs */ | ||
686 | 671 | xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[nlast_workspace], | ||
687 | 672 | !desktop->priv->single_workspace_mode); | ||
688 | 673 | |||
689 | 674 | xfce_workspace_monitors_changed(desktop->priv->workspaces[nlast_workspace], | ||
690 | 675 | desktop->priv->gscreen); | ||
691 | 676 | |||
692 | 677 | g_signal_connect(desktop->priv->workspaces[nlast_workspace], | ||
693 | 678 | "workspace-backdrop-changed", | ||
694 | 679 | G_CALLBACK(workspace_backdrop_changed_cb), desktop); | ||
695 | 680 | } | ||
696 | 681 | |||
697 | 682 | static void | ||
698 | 683 | workspace_destroyed_cb(WnckScreen *wnck_screen, | ||
699 | 684 | WnckWorkspace *old_workspace, | ||
700 | 685 | gpointer user_data) | ||
701 | 686 | { | ||
702 | 687 | XfceDesktop *desktop = XFCE_DESKTOP(user_data); | ||
703 | 688 | gint nlast_workspace; | ||
704 | 689 | TRACE("entering"); | ||
705 | 690 | |||
706 | 691 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
707 | 692 | g_return_if_fail(desktop->priv->nworkspaces - 1 >= 0); | ||
708 | 693 | g_return_if_fail(XFCE_IS_WORKSPACE(desktop->priv->workspaces[desktop->priv->nworkspaces-1])); | ||
709 | 694 | |||
710 | 695 | nlast_workspace = desktop->priv->nworkspaces - 1; | ||
711 | 696 | |||
712 | 697 | g_signal_handlers_disconnect_by_func(desktop->priv->workspaces[nlast_workspace], | ||
713 | 698 | G_CALLBACK(workspace_backdrop_changed_cb), | ||
714 | 699 | desktop); | ||
715 | 700 | |||
716 | 701 | g_object_unref(desktop->priv->workspaces[nlast_workspace]); | ||
717 | 702 | |||
718 | 703 | /* Remove one workspace */ | ||
719 | 704 | desktop->priv->nworkspaces = nlast_workspace; | ||
720 | 705 | |||
721 | 706 | /* deallocate it */ | ||
722 | 707 | desktop->priv->workspaces = g_realloc(desktop->priv->workspaces, | ||
723 | 708 | desktop->priv->nworkspaces * sizeof(XfceWorkspace *)); | ||
724 | 709 | |||
725 | 710 | /* Make sure we stay within bounds now that we removed a workspace */ | ||
726 | 711 | if(desktop->priv->current_workspace > desktop->priv->nworkspaces) | ||
727 | 712 | desktop->priv->current_workspace = desktop->priv->nworkspaces; | ||
728 | 713 | } | ||
729 | 714 | |||
730 | 715 | static void | ||
731 | 716 | screen_set_selection(XfceDesktop *desktop) | ||
732 | 717 | { | ||
733 | 718 | Window xwin; | ||
734 | 719 | gint xscreen; | ||
735 | 720 | gchar selection_name[100]; | ||
736 | 721 | Atom selection_atom, manager_atom; | ||
737 | 722 | |||
738 | 723 | xwin = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); | ||
739 | 724 | xscreen = gdk_screen_get_number(desktop->priv->gscreen); | ||
740 | 725 | |||
741 | 726 | g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen); | ||
742 | 727 | selection_atom = XInternAtom(gdk_x11_get_default_xdisplay(), selection_name, False); | ||
743 | 728 | manager_atom = XInternAtom(gdk_x11_get_default_xdisplay(), "MANAGER", False); | ||
744 | 729 | |||
745 | 730 | /* the previous check in src/main.c occurs too early, so workaround by | ||
746 | 731 | * adding this one. */ | ||
747 | 732 | if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) != None) { | ||
748 | 733 | g_warning("%s: already running, quitting.", PACKAGE); | ||
749 | 734 | exit(0); | ||
750 | 735 | } | ||
751 | 736 | |||
752 | 737 | XSelectInput(gdk_x11_get_default_xdisplay(), xwin, PropertyChangeMask | ButtonPressMask); | ||
753 | 738 | XSetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom, xwin, GDK_CURRENT_TIME); | ||
754 | 739 | |||
755 | 740 | /* Check to see if we managed to claim the selection. If not, | ||
756 | 741 | * we treat it as if we got it then immediately lost it */ | ||
757 | 742 | if(XGetSelectionOwner(gdk_x11_get_default_xdisplay(), selection_atom) == xwin) { | ||
758 | 743 | XClientMessageEvent xev; | ||
759 | 744 | Window xroot = GDK_WINDOW_XID(gdk_screen_get_root_window(desktop->priv->gscreen)); | ||
760 | 745 | |||
761 | 746 | xev.type = ClientMessage; | ||
762 | 747 | xev.window = xroot; | ||
763 | 748 | xev.message_type = manager_atom; | ||
764 | 749 | xev.format = 32; | ||
765 | 750 | xev.data.l[0] = GDK_CURRENT_TIME; | ||
766 | 751 | xev.data.l[1] = selection_atom; | ||
767 | 752 | xev.data.l[2] = xwin; | ||
768 | 753 | xev.data.l[3] = 0; /* manager specific data */ | ||
769 | 754 | xev.data.l[4] = 0; /* manager specific data */ | ||
770 | 755 | |||
771 | 756 | XSendEvent(gdk_x11_get_default_xdisplay(), xroot, False, StructureNotifyMask, (XEvent *)&xev); | ||
772 | 757 | } else { | ||
773 | 758 | g_error("%s: could not set selection ownership", PACKAGE); | ||
774 | 759 | exit(1); | ||
775 | 760 | } | ||
776 | 761 | } | ||
777 | 762 | |||
778 | 763 | |||
779 | 764 | |||
780 | 765 | /* gobject-related functions */ | ||
781 | 766 | |||
782 | 767 | |||
783 | 768 | G_DEFINE_TYPE(XfceDesktop, xfce_desktop, GTK_TYPE_WINDOW) | ||
784 | 769 | |||
785 | 770 | |||
786 | 771 | static void | ||
787 | 772 | xfce_desktop_class_init(XfceDesktopClass *klass) | ||
788 | 773 | { | ||
789 | 774 | GObjectClass *gobject_class = (GObjectClass *)klass; | ||
790 | 775 | GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; | ||
791 | 776 | |||
792 | 777 | g_type_class_add_private(klass, sizeof(XfceDesktopPriv)); | ||
793 | 778 | |||
794 | 779 | gobject_class->finalize = xfce_desktop_finalize; | ||
795 | 780 | gobject_class->set_property = xfce_desktop_set_property; | ||
796 | 781 | gobject_class->get_property = xfce_desktop_get_property; | ||
797 | 782 | |||
798 | 783 | widget_class->realize = xfce_desktop_realize; | ||
799 | 784 | widget_class->unrealize = xfce_desktop_unrealize; | ||
800 | 785 | widget_class->button_press_event = xfce_desktop_button_press_event; | ||
801 | 786 | widget_class->button_release_event = xfce_desktop_button_release_event; | ||
802 | 787 | widget_class->expose_event = xfce_desktop_expose; | ||
803 | 788 | widget_class->delete_event = xfce_desktop_delete_event; | ||
804 | 789 | widget_class->popup_menu = xfce_desktop_popup_menu; | ||
805 | 790 | widget_class->style_set = xfce_desktop_style_set; | ||
806 | 791 | |||
807 | 792 | signals[SIG_POPULATE_ROOT_MENU] = g_signal_new("populate-root-menu", | ||
808 | 793 | XFCE_TYPE_DESKTOP, | ||
809 | 794 | G_SIGNAL_RUN_LAST, | ||
810 | 795 | G_STRUCT_OFFSET(XfceDesktopClass, | ||
811 | 796 | populate_root_menu), | ||
812 | 797 | NULL, NULL, | ||
813 | 798 | g_cclosure_marshal_VOID__OBJECT, | ||
814 | 799 | G_TYPE_NONE, 1, | ||
815 | 800 | GTK_TYPE_MENU_SHELL); | ||
816 | 801 | |||
817 | 802 | signals[SIG_POPULATE_SECONDARY_ROOT_MENU] = g_signal_new("populate-secondary-root-menu", | ||
818 | 803 | XFCE_TYPE_DESKTOP, | ||
819 | 804 | G_SIGNAL_RUN_LAST, | ||
820 | 805 | G_STRUCT_OFFSET(XfceDesktopClass, | ||
821 | 806 | populate_secondary_root_menu), | ||
822 | 807 | NULL, NULL, | ||
823 | 808 | g_cclosure_marshal_VOID__OBJECT, | ||
824 | 809 | G_TYPE_NONE, 1, | ||
825 | 810 | GTK_TYPE_MENU_SHELL); | ||
826 | 811 | |||
827 | 812 | #define XFDESKTOP_PARAM_FLAGS (G_PARAM_READWRITE \ | ||
828 | 813 | | G_PARAM_CONSTRUCT \ | ||
829 | 814 | | G_PARAM_STATIC_NAME \ | ||
830 | 815 | | G_PARAM_STATIC_NICK \ | ||
831 | 816 | | G_PARAM_STATIC_BLURB) | ||
832 | 817 | |||
833 | 818 | #ifdef ENABLE_DESKTOP_ICONS | ||
834 | 819 | g_object_class_install_property(gobject_class, PROP_ICON_STYLE, | ||
835 | 820 | g_param_spec_enum("icon-style", | ||
836 | 821 | "icon style", | ||
837 | 822 | "icon style", | ||
838 | 823 | XFCE_TYPE_DESKTOP_ICON_STYLE, | ||
839 | 824 | #ifdef ENABLE_FILE_ICONS | ||
840 | 825 | XFCE_DESKTOP_ICON_STYLE_FILES, | ||
841 | 826 | #else | ||
842 | 827 | XFCE_DESKTOP_ICON_STYLE_WINDOWS, | ||
843 | 828 | #endif /* ENABLE_FILE_ICONS */ | ||
844 | 829 | XFDESKTOP_PARAM_FLAGS)); | ||
845 | 830 | |||
846 | 831 | g_object_class_install_property(gobject_class, PROP_ICON_SIZE, | ||
847 | 832 | g_param_spec_uint("icon-size", | ||
848 | 833 | "icon size", | ||
849 | 834 | "icon size", | ||
850 | 835 | 8, 192, 36, | ||
851 | 836 | XFDESKTOP_PARAM_FLAGS)); | ||
852 | 837 | |||
853 | 838 | g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE, | ||
854 | 839 | g_param_spec_uint("icon-font-size", | ||
855 | 840 | "icon font size", | ||
856 | 841 | "icon font size", | ||
857 | 842 | 0, 144, 12, | ||
858 | 843 | XFDESKTOP_PARAM_FLAGS)); | ||
859 | 844 | |||
860 | 845 | g_object_class_install_property(gobject_class, PROP_ICON_FONT_SIZE_SET, | ||
861 | 846 | g_param_spec_boolean("icon-font-size-set", | ||
862 | 847 | "icon font size set", | ||
863 | 848 | "icon font size set", | ||
864 | 849 | FALSE, | ||
865 | 850 | XFDESKTOP_PARAM_FLAGS)); | ||
866 | 851 | |||
867 | 852 | #endif /* ENABLE_DESKTOP_ICONS */ | ||
868 | 853 | |||
869 | 854 | g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_MODE, | ||
870 | 855 | g_param_spec_boolean("single-workspace-mode", | ||
871 | 856 | "single-workspace-mode", | ||
872 | 857 | "single-workspace-mode", | ||
873 | 858 | TRUE, | ||
874 | 859 | XFDESKTOP_PARAM_FLAGS)); | ||
875 | 860 | |||
876 | 861 | g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_NUMBER, | ||
877 | 862 | g_param_spec_int("single-workspace-number", | ||
878 | 863 | "single-workspace-number", | ||
879 | 864 | "single-workspace-number", | ||
880 | 865 | 0, G_MAXINT16, 0, | ||
881 | 866 | XFDESKTOP_PARAM_FLAGS)); | ||
882 | 867 | |||
883 | 868 | #undef XFDESKTOP_PARAM_FLAGS | ||
884 | 869 | } | ||
885 | 870 | |||
886 | 871 | static void | ||
887 | 872 | xfce_desktop_init(XfceDesktop *desktop) | ||
888 | 873 | { | ||
889 | 874 | desktop->priv = G_TYPE_INSTANCE_GET_PRIVATE(desktop, XFCE_TYPE_DESKTOP, | ||
890 | 875 | XfceDesktopPriv); | ||
891 | 876 | |||
892 | 877 | gtk_window_set_type_hint(GTK_WINDOW(desktop), GDK_WINDOW_TYPE_HINT_DESKTOP); | ||
893 | 878 | /* Accept focus is needed for the menu pop up either by the menu key on | ||
894 | 879 | * the keyboard or Shift+F10. */ | ||
895 | 880 | gtk_window_set_accept_focus(GTK_WINDOW(desktop), TRUE); | ||
896 | 881 | /* Can focus is needed for the gtk_grab_add/remove commands */ | ||
897 | 882 | gtk_widget_set_can_focus(GTK_WIDGET(desktop), TRUE); | ||
898 | 883 | gtk_window_set_resizable(GTK_WINDOW(desktop), FALSE); | ||
899 | 884 | } | ||
900 | 885 | |||
901 | 886 | static void | ||
902 | 887 | xfce_desktop_finalize(GObject *object) | ||
903 | 888 | { | ||
904 | 889 | XfceDesktop *desktop = XFCE_DESKTOP(object); | ||
905 | 890 | |||
906 | 891 | g_object_unref(G_OBJECT(desktop->priv->channel)); | ||
907 | 892 | g_free(desktop->priv->property_prefix); | ||
908 | 893 | |||
909 | 894 | if(desktop->priv->style_refresh_timer != 0) | ||
910 | 895 | g_source_remove(desktop->priv->style_refresh_timer); | ||
911 | 896 | |||
912 | 897 | G_OBJECT_CLASS(xfce_desktop_parent_class)->finalize(object); | ||
913 | 898 | } | ||
914 | 899 | |||
915 | 900 | static void | ||
916 | 901 | xfce_desktop_set_property(GObject *object, | ||
917 | 902 | guint property_id, | ||
918 | 903 | const GValue *value, | ||
919 | 904 | GParamSpec *pspec) | ||
920 | 905 | { | ||
921 | 906 | XfceDesktop *desktop = XFCE_DESKTOP(object); | ||
922 | 907 | |||
923 | 908 | switch(property_id) { | ||
924 | 909 | #ifdef ENABLE_DESKTOP_ICONS | ||
925 | 910 | case PROP_ICON_STYLE: | ||
926 | 911 | xfce_desktop_set_icon_style(desktop, | ||
927 | 912 | g_value_get_enum(value)); | ||
928 | 913 | break; | ||
929 | 914 | |||
930 | 915 | case PROP_ICON_SIZE: | ||
931 | 916 | xfce_desktop_set_icon_size(desktop, | ||
932 | 917 | g_value_get_uint(value)); | ||
933 | 918 | break; | ||
934 | 919 | |||
935 | 920 | case PROP_ICON_FONT_SIZE: | ||
936 | 921 | xfce_desktop_set_icon_font_size(desktop, | ||
937 | 922 | g_value_get_uint(value)); | ||
938 | 923 | break; | ||
939 | 924 | |||
940 | 925 | case PROP_ICON_FONT_SIZE_SET: | ||
941 | 926 | xfce_desktop_set_use_icon_font_size(desktop, | ||
942 | 927 | g_value_get_boolean(value)); | ||
943 | 928 | break; | ||
944 | 929 | |||
945 | 930 | #endif | ||
946 | 931 | case PROP_SINGLE_WORKSPACE_MODE: | ||
947 | 932 | xfce_desktop_set_single_workspace_mode(desktop, | ||
948 | 933 | g_value_get_boolean(value)); | ||
949 | 934 | break; | ||
950 | 935 | |||
951 | 936 | case PROP_SINGLE_WORKSPACE_NUMBER: | ||
952 | 937 | xfce_desktop_set_single_workspace_number(desktop, | ||
953 | 938 | g_value_get_int(value)); | ||
954 | 939 | break; | ||
955 | 940 | |||
956 | 941 | default: | ||
957 | 942 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | ||
958 | 943 | break; | ||
959 | 944 | } | ||
960 | 945 | } | ||
961 | 946 | |||
962 | 947 | static void | ||
963 | 948 | xfce_desktop_get_property(GObject *object, | ||
964 | 949 | guint property_id, | ||
965 | 950 | GValue *value, | ||
966 | 951 | GParamSpec *pspec) | ||
967 | 952 | { | ||
968 | 953 | XfceDesktop *desktop = XFCE_DESKTOP(object); | ||
969 | 954 | |||
970 | 955 | switch(property_id) { | ||
971 | 956 | #ifdef ENABLE_DESKTOP_ICONS | ||
972 | 957 | case PROP_ICON_STYLE: | ||
973 | 958 | g_value_set_enum(value, desktop->priv->icons_style); | ||
974 | 959 | break; | ||
975 | 960 | |||
976 | 961 | case PROP_ICON_SIZE: | ||
977 | 962 | g_value_set_uint(value, desktop->priv->icons_size); | ||
978 | 963 | break; | ||
979 | 964 | |||
980 | 965 | case PROP_ICON_FONT_SIZE: | ||
981 | 966 | g_value_set_uint(value, desktop->priv->icons_font_size); | ||
982 | 967 | break; | ||
983 | 968 | |||
984 | 969 | case PROP_ICON_FONT_SIZE_SET: | ||
985 | 970 | g_value_set_boolean(value, desktop->priv->icons_font_size_set); | ||
986 | 971 | break; | ||
987 | 972 | |||
988 | 973 | #endif | ||
989 | 974 | case PROP_SINGLE_WORKSPACE_MODE: | ||
990 | 975 | g_value_set_boolean(value, desktop->priv->single_workspace_mode); | ||
991 | 976 | break; | ||
992 | 977 | |||
993 | 978 | case PROP_SINGLE_WORKSPACE_NUMBER: | ||
994 | 979 | g_value_set_int(value, desktop->priv->single_workspace_num); | ||
995 | 980 | break; | ||
996 | 981 | |||
997 | 982 | default: | ||
998 | 983 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); | ||
999 | 984 | break; | ||
1000 | 985 | } | ||
1001 | 986 | } | ||
1002 | 987 | |||
1003 | 988 | static void | ||
1004 | 989 | xfce_desktop_realize(GtkWidget *widget) | ||
1005 | 990 | { | ||
1006 | 991 | XfceDesktop *desktop = XFCE_DESKTOP(widget); | ||
1007 | 992 | GdkAtom atom; | ||
1008 | 993 | gint sw, sh; | ||
1009 | 994 | Window xid; | ||
1010 | 995 | GdkWindow *groot; | ||
1011 | 996 | WnckScreen *wnck_screen; | ||
1012 | 997 | |||
1013 | 998 | TRACE("entering"); | ||
1014 | 999 | |||
1015 | 1000 | gtk_window_set_screen(GTK_WINDOW(desktop), desktop->priv->gscreen); | ||
1016 | 1001 | sw = gdk_screen_get_width(desktop->priv->gscreen); | ||
1017 | 1002 | sh = gdk_screen_get_height(desktop->priv->gscreen); | ||
1018 | 1003 | if(gtk_major_version > 2 | ||
1019 | 1004 | || (gtk_major_version == 2 && gtk_minor_version >= 13)) | ||
1020 | 1005 | { | ||
1021 | 1006 | g_signal_connect(G_OBJECT(desktop->priv->gscreen), | ||
1022 | 1007 | "monitors-changed", | ||
1023 | 1008 | G_CALLBACK(xfce_desktop_monitors_changed), | ||
1024 | 1009 | desktop); | ||
1025 | 1010 | } | ||
1026 | 1011 | |||
1027 | 1012 | /* chain up */ | ||
1028 | 1013 | GTK_WIDGET_CLASS(xfce_desktop_parent_class)->realize(widget); | ||
1029 | 1014 | |||
1030 | 1015 | gtk_window_set_title(GTK_WINDOW(desktop), _("Desktop")); | ||
1031 | 1016 | |||
1032 | 1017 | gtk_widget_set_size_request(GTK_WIDGET(desktop), sw, sh); | ||
1033 | 1018 | gtk_window_move(GTK_WINDOW(desktop), 0, 0); | ||
1034 | 1019 | |||
1035 | 1020 | atom = gdk_atom_intern("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE); | ||
1036 | 1021 | gdk_property_change(gtk_widget_get_window(GTK_WIDGET(desktop)), | ||
1037 | 1022 | gdk_atom_intern("_NET_WM_WINDOW_TYPE", FALSE), | ||
1038 | 1023 | gdk_atom_intern("ATOM", FALSE), 32, | ||
1039 | 1024 | GDK_PROP_MODE_REPLACE, (guchar *)&atom, 1); | ||
1040 | 1025 | |||
1041 | 1026 | xid = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(desktop))); | ||
1042 | 1027 | groot = gdk_screen_get_root_window(desktop->priv->gscreen); | ||
1043 | 1028 | |||
1044 | 1029 | gdk_property_change(groot, | ||
1045 | 1030 | gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE), | ||
1046 | 1031 | gdk_atom_intern("WINDOW", FALSE), 32, | ||
1047 | 1032 | GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); | ||
1048 | 1033 | |||
1049 | 1034 | gdk_property_change(groot, | ||
1050 | 1035 | gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE), | ||
1051 | 1036 | gdk_atom_intern("WINDOW", FALSE), 32, | ||
1052 | 1037 | GDK_PROP_MODE_REPLACE, (guchar *)&xid, 1); | ||
1053 | 1038 | |||
1054 | 1039 | screen_set_selection(desktop); | ||
1055 | 1040 | |||
1056 | 1041 | wnck_screen = wnck_screen_get(gdk_screen_get_number(desktop->priv->gscreen)); | ||
1057 | 1042 | desktop->priv->wnck_screen = wnck_screen; | ||
1058 | 1043 | |||
1059 | 1044 | /* Watch for single workspace setting changes */ | ||
1060 | 1045 | xfconf_g_property_bind(desktop->priv->channel, | ||
1061 | 1046 | SINGLE_WORKSPACE_MODE, G_TYPE_BOOLEAN, | ||
1062 | 1047 | G_OBJECT(desktop), "single-workspace-mode"); | ||
1063 | 1048 | xfconf_g_property_bind(desktop->priv->channel, | ||
1064 | 1049 | SINGLE_WORKSPACE_NUMBER, G_TYPE_INT, | ||
1065 | 1050 | G_OBJECT(desktop), "single-workspace-number"); | ||
1066 | 1051 | |||
1067 | 1052 | /* watch for workspace changes */ | ||
1068 | 1053 | g_signal_connect(desktop->priv->wnck_screen, "active-workspace-changed", | ||
1069 | 1054 | G_CALLBACK(workspace_changed_cb), desktop); | ||
1070 | 1055 | g_signal_connect(desktop->priv->wnck_screen, "workspace-created", | ||
1071 | 1056 | G_CALLBACK(workspace_created_cb), desktop); | ||
1072 | 1057 | g_signal_connect(desktop->priv->wnck_screen, "workspace-destroyed", | ||
1073 | 1058 | G_CALLBACK(workspace_destroyed_cb), desktop); | ||
1074 | 1059 | |||
1075 | 1060 | /* watch for screen changes */ | ||
1076 | 1061 | g_signal_connect(G_OBJECT(desktop->priv->gscreen), "size-changed", | ||
1077 | 1062 | G_CALLBACK(screen_size_changed_cb), desktop); | ||
1078 | 1063 | g_signal_connect(G_OBJECT(desktop->priv->gscreen), "composited-changed", | ||
1079 | 1064 | G_CALLBACK(screen_composited_changed_cb), desktop); | ||
1080 | 1065 | |||
1081 | 1066 | gtk_widget_add_events(GTK_WIDGET(desktop), GDK_EXPOSURE_MASK); | ||
1082 | 1067 | |||
1083 | 1068 | #ifdef ENABLE_DESKTOP_ICONS | ||
1084 | 1069 | xfce_desktop_setup_icon_view(desktop); | ||
1085 | 1070 | #endif | ||
1086 | 1071 | |||
1087 | 1072 | TRACE("exiting"); | ||
1088 | 1073 | } | ||
1089 | 1074 | |||
1090 | 1075 | static void | ||
1091 | 1076 | xfce_desktop_unrealize(GtkWidget *widget) | ||
1092 | 1077 | { | ||
1093 | 1078 | XfceDesktop *desktop = XFCE_DESKTOP(widget); | ||
1094 | 1079 | gint i; | ||
1095 | 1080 | GdkWindow *groot; | ||
1096 | 1081 | gchar property_name[128]; | ||
1097 | 1082 | |||
1098 | 1083 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1099 | 1084 | |||
1100 | 1085 | /* disconnect all the xfconf settings to this desktop */ | ||
1101 | 1086 | xfconf_g_property_unbind_all(G_OBJECT(desktop)); | ||
1102 | 1087 | |||
1103 | 1088 | g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), | ||
1104 | 1089 | G_CALLBACK(xfce_desktop_monitors_changed), | ||
1105 | 1090 | desktop); | ||
1106 | 1091 | |||
1107 | 1092 | if(gtk_widget_get_mapped(widget)) | ||
1108 | 1093 | gtk_widget_unmap(widget); | ||
1109 | 1094 | gtk_widget_set_mapped(widget, FALSE); | ||
1110 | 1095 | |||
1111 | 1096 | gtk_container_forall(GTK_CONTAINER(widget), | ||
1112 | 1097 | (GtkCallback)gtk_widget_unrealize, | ||
1113 | 1098 | NULL); | ||
1114 | 1099 | |||
1115 | 1100 | g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), | ||
1116 | 1101 | G_CALLBACK(screen_size_changed_cb), desktop); | ||
1117 | 1102 | g_signal_handlers_disconnect_by_func(G_OBJECT(desktop->priv->gscreen), | ||
1118 | 1103 | G_CALLBACK(screen_composited_changed_cb), desktop); | ||
1119 | 1104 | |||
1120 | 1105 | gdk_error_trap_push(); | ||
1121 | 1106 | |||
1122 | 1107 | groot = gdk_screen_get_root_window(desktop->priv->gscreen); | ||
1123 | 1108 | gdk_property_delete(groot, gdk_atom_intern("XFCE_DESKTOP_WINDOW", FALSE)); | ||
1124 | 1109 | gdk_property_delete(groot, gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE)); | ||
1125 | 1110 | |||
1126 | 1111 | #ifndef DISABLE_FOR_BUG7442 | ||
1127 | 1112 | gdk_property_delete(groot, gdk_atom_intern("_XROOTPMAP_ID", FALSE)); | ||
1128 | 1113 | gdk_property_delete(groot, gdk_atom_intern("ESETROOT_PMAP_ID", FALSE)); | ||
1129 | 1114 | gdk_window_set_back_pixmap(groot, NULL, FALSE); | ||
1130 | 1115 | #endif | ||
1131 | 1116 | |||
1132 | 1117 | if(desktop->priv->workspaces) { | ||
1133 | 1118 | for(i = 0; i < desktop->priv->nworkspaces; i++) { | ||
1134 | 1119 | g_snprintf(property_name, 128, XFDESKTOP_IMAGE_FILE_FMT, i); | ||
1135 | 1120 | gdk_property_delete(groot, gdk_atom_intern(property_name, FALSE)); | ||
1136 | 1121 | g_object_unref(G_OBJECT(desktop->priv->workspaces[i])); | ||
1137 | 1122 | } | ||
1138 | 1123 | g_free(desktop->priv->workspaces); | ||
1139 | 1124 | desktop->priv->workspaces = NULL; | ||
1140 | 1125 | } | ||
1141 | 1126 | |||
1142 | 1127 | gdk_flush(); | ||
1143 | 1128 | gdk_error_trap_pop(); | ||
1144 | 1129 | |||
1145 | 1130 | if(desktop->priv->bg_pixmap) { | ||
1146 | 1131 | g_object_unref(G_OBJECT(desktop->priv->bg_pixmap)); | ||
1147 | 1132 | desktop->priv->bg_pixmap = NULL; | ||
1148 | 1133 | } | ||
1149 | 1134 | |||
1150 | 1135 | gtk_window_set_icon(GTK_WINDOW(widget), NULL); | ||
1151 | 1136 | |||
1152 | 1137 | gtk_style_detach(gtk_widget_get_style(widget)); | ||
1153 | 1138 | g_object_unref(G_OBJECT(gtk_widget_get_window(widget))); | ||
1154 | 1139 | gtk_widget_set_window(widget, NULL); | ||
1155 | 1140 | |||
1156 | 1141 | gtk_selection_remove_all(widget); | ||
1157 | 1142 | |||
1158 | 1143 | gtk_widget_set_realized(widget, FALSE); | ||
1159 | 1144 | } | ||
1160 | 1145 | |||
1161 | 1146 | static gboolean | ||
1162 | 1147 | xfce_desktop_button_press_event(GtkWidget *w, | ||
1163 | 1148 | GdkEventButton *evt) | ||
1164 | 1149 | { | ||
1165 | 1150 | guint button = evt->button; | ||
1166 | 1151 | guint state = evt->state; | ||
1167 | 1152 | XfceDesktop *desktop = XFCE_DESKTOP(w); | ||
1168 | 1153 | |||
1169 | 1154 | TRACE("entering"); | ||
1170 | 1155 | |||
1171 | 1156 | g_return_val_if_fail(XFCE_IS_DESKTOP(w), FALSE); | ||
1172 | 1157 | |||
1173 | 1158 | if(evt->type == GDK_BUTTON_PRESS) { | ||
1174 | 1159 | if(button == 3 || (button == 1 && (state & GDK_SHIFT_MASK))) { | ||
1175 | 1160 | #ifdef ENABLE_DESKTOP_ICONS | ||
1176 | 1161 | /* Let the icon view handle these menu pop ups */ | ||
1177 | 1162 | if(desktop->priv->icons_style != XFCE_DESKTOP_ICON_STYLE_NONE) | ||
1178 | 1163 | return FALSE; | ||
1179 | 1164 | #endif | ||
1180 | 1165 | /* no icons on the desktop, grab the focus and pop up the menu */ | ||
1181 | 1166 | if(!gtk_widget_has_grab(w)) | ||
1182 | 1167 | gtk_grab_add(w); | ||
1183 | 1168 | |||
1184 | 1169 | xfce_desktop_popup_root_menu(desktop, button, evt->time); | ||
1185 | 1170 | return TRUE; | ||
1186 | 1171 | } else if(button == 2 || (button == 1 && (state & GDK_SHIFT_MASK) | ||
1187 | 1172 | && (state & GDK_CONTROL_MASK))) | ||
1188 | 1173 | { | ||
1189 | 1174 | /* always grab the focus and pop up the menu */ | ||
1190 | 1175 | if(!gtk_widget_has_grab(w)) | ||
1191 | 1176 | gtk_grab_add(w); | ||
1192 | 1177 | |||
1193 | 1178 | xfce_desktop_popup_secondary_root_menu(desktop, button, evt->time); | ||
1194 | 1179 | return TRUE; | ||
1195 | 1180 | } | ||
1196 | 1181 | } | ||
1197 | 1182 | |||
1198 | 1183 | return FALSE; | ||
1199 | 1184 | } | ||
1200 | 1185 | |||
1201 | 1186 | static gboolean | ||
1202 | 1187 | xfce_desktop_button_release_event(GtkWidget *w, | ||
1203 | 1188 | GdkEventButton *evt) | ||
1204 | 1189 | { | ||
1205 | 1190 | TRACE("entering"); | ||
1206 | 1191 | |||
1207 | 1192 | gtk_grab_remove(w); | ||
1208 | 1193 | |||
1209 | 1194 | return FALSE; | ||
1210 | 1195 | } | ||
1211 | 1196 | |||
1212 | 1197 | /* This function gets called when the user presses the menu key on the keyboard. | ||
1213 | 1198 | * Or Shift+F10 or whatever key binding the user has chosen. */ | ||
1214 | 1199 | static gboolean | ||
1215 | 1200 | xfce_desktop_popup_menu(GtkWidget *w) | ||
1216 | 1201 | { | ||
1217 | 1202 | GdkEventButton *evt; | ||
1218 | 1203 | guint button, etime; | ||
1219 | 1204 | |||
1220 | 1205 | TRACE("entering"); | ||
1221 | 1206 | |||
1222 | 1207 | evt = (GdkEventButton *)gtk_get_current_event(); | ||
1223 | 1208 | if(evt && GDK_BUTTON_PRESS == evt->type) { | ||
1224 | 1209 | button = evt->button; | ||
1225 | 1210 | etime = evt->time; | ||
1226 | 1211 | } else { | ||
1227 | 1212 | button = 0; | ||
1228 | 1213 | etime = gtk_get_current_event_time(); | ||
1229 | 1214 | } | ||
1230 | 1215 | |||
1231 | 1216 | xfce_desktop_popup_root_menu(XFCE_DESKTOP(w), button, etime); | ||
1232 | 1217 | |||
1233 | 1218 | return TRUE; | ||
1234 | 1219 | } | ||
1235 | 1220 | |||
1236 | 1221 | static gboolean | ||
1237 | 1222 | xfce_desktop_expose(GtkWidget *w, | ||
1238 | 1223 | GdkEventExpose *evt) | ||
1239 | 1224 | { | ||
1240 | 1225 | GList *children, *l; | ||
1241 | 1226 | |||
1242 | 1227 | /*TRACE("entering");*/ | ||
1243 | 1228 | |||
1244 | 1229 | if(evt->count != 0) | ||
1245 | 1230 | return FALSE; | ||
1246 | 1231 | |||
1247 | 1232 | gdk_window_clear_area(gtk_widget_get_window(w), evt->area.x, evt->area.y, | ||
1248 | 1233 | evt->area.width, evt->area.height); | ||
1249 | 1234 | |||
1250 | 1235 | children = gtk_container_get_children(GTK_CONTAINER(w)); | ||
1251 | 1236 | for(l = children; l; l = l->next) { | ||
1252 | 1237 | gtk_container_propagate_expose(GTK_CONTAINER(w), | ||
1253 | 1238 | GTK_WIDGET(l->data), | ||
1254 | 1239 | evt); | ||
1255 | 1240 | } | ||
1256 | 1241 | g_list_free(children); | ||
1257 | 1242 | |||
1258 | 1243 | return FALSE; | ||
1259 | 1244 | } | ||
1260 | 1245 | |||
1261 | 1246 | static gboolean | ||
1262 | 1247 | xfce_desktop_delete_event(GtkWidget *w, | ||
1263 | 1248 | GdkEventAny *evt) | ||
1264 | 1249 | { | ||
1265 | 1250 | if(XFCE_DESKTOP(w)->priv->session_logout_func) | ||
1266 | 1251 | XFCE_DESKTOP(w)->priv->session_logout_func(); | ||
1267 | 1252 | |||
1268 | 1253 | return TRUE; | ||
1269 | 1254 | } | ||
1270 | 1255 | |||
1271 | 1256 | static gboolean | ||
1272 | 1257 | style_refresh_cb(gpointer *w) | ||
1273 | 1258 | { | ||
1274 | 1259 | XfceDesktop *desktop = XFCE_DESKTOP(w); | ||
1275 | 1260 | |||
1276 | 1261 | xfce_desktop_refresh(desktop); | ||
1277 | 1262 | desktop->priv->style_refresh_timer = 0; | ||
1278 | 1263 | |||
1279 | 1264 | return FALSE; | ||
1280 | 1265 | } | ||
1281 | 1266 | |||
1282 | 1267 | static void | ||
1283 | 1268 | xfce_desktop_style_set(GtkWidget *w, GtkStyle *old_style) | ||
1284 | 1269 | { | ||
1285 | 1270 | XfceDesktop *desktop = XFCE_DESKTOP(w); | ||
1286 | 1271 | |||
1287 | 1272 | if(desktop->priv->style_refresh_timer != 0) | ||
1288 | 1273 | g_source_remove(desktop->priv->style_refresh_timer); | ||
1289 | 1274 | |||
1290 | 1275 | desktop->priv->style_refresh_timer = g_timeout_add_seconds(1, (GSourceFunc)style_refresh_cb, w); | ||
1291 | 1276 | } | ||
1292 | 1277 | |||
1293 | 1278 | static void | ||
1294 | 1279 | xfce_desktop_connect_settings(XfceDesktop *desktop) | ||
1295 | 1280 | { | ||
1296 | 1281 | #ifdef ENABLE_DESKTOP_ICONS | ||
1297 | 1282 | #define ICONS_PREFIX "/desktop-icons/" | ||
1298 | 1283 | XfconfChannel *channel = desktop->priv->channel; | ||
1299 | 1284 | |||
1300 | 1285 | xfce_desktop_freeze_updates(desktop); | ||
1301 | 1286 | |||
1302 | 1287 | xfconf_g_property_bind(channel, ICONS_PREFIX "style", | ||
1303 | 1288 | XFCE_TYPE_DESKTOP_ICON_STYLE, | ||
1304 | 1289 | G_OBJECT(desktop), "icon-style"); | ||
1305 | 1290 | xfconf_g_property_bind(channel, ICONS_PREFIX "icon-size", G_TYPE_UINT, | ||
1306 | 1291 | G_OBJECT(desktop), "icon-size"); | ||
1307 | 1292 | xfconf_g_property_bind(channel, ICONS_PREFIX "font-size", G_TYPE_UINT, | ||
1308 | 1293 | G_OBJECT(desktop), "icon-font-size"); | ||
1309 | 1294 | xfconf_g_property_bind(channel, ICONS_PREFIX "use-custom-font-size", | ||
1310 | 1295 | G_TYPE_BOOLEAN, | ||
1311 | 1296 | G_OBJECT(desktop), "icon-font-size-set"); | ||
1312 | 1297 | |||
1313 | 1298 | xfce_desktop_thaw_updates(desktop); | ||
1314 | 1299 | #undef ICONS_PREFIX | ||
1315 | 1300 | #endif | ||
1316 | 1301 | } | ||
1317 | 1302 | |||
1318 | 1303 | static gboolean | ||
1319 | 1304 | xfce_desktop_get_single_workspace_mode(XfceDesktop *desktop) | ||
1320 | 1305 | { | ||
1321 | 1306 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), TRUE); | ||
1322 | 1307 | |||
1323 | 1308 | return desktop->priv->single_workspace_mode; | ||
1324 | 1309 | } | ||
1325 | 1310 | |||
1326 | 1311 | static gint | ||
1327 | 1312 | xfce_desktop_get_current_workspace(XfceDesktop *desktop) | ||
1328 | 1313 | { | ||
1329 | 1314 | WnckWorkspace *wnck_workspace; | ||
1330 | 1315 | gint workspace_num, current_workspace; | ||
1331 | 1316 | |||
1332 | 1317 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); | ||
1333 | 1318 | |||
1334 | 1319 | wnck_workspace = wnck_screen_get_active_workspace(desktop->priv->wnck_screen); | ||
1335 | 1320 | |||
1336 | 1321 | if(wnck_workspace != NULL) { | ||
1337 | 1322 | workspace_num = wnck_workspace_get_number(wnck_workspace); | ||
1338 | 1323 | } else { | ||
1339 | 1324 | workspace_num = desktop->priv->nworkspaces; | ||
1340 | 1325 | } | ||
1341 | 1326 | |||
1342 | 1327 | /* If we're in single_workspace mode we need to return the workspace that | ||
1343 | 1328 | * it was set to, if possible, otherwise return the current workspace */ | ||
1344 | 1329 | if(xfce_desktop_get_single_workspace_mode(desktop) && | ||
1345 | 1330 | desktop->priv->single_workspace_num < desktop->priv->nworkspaces) { | ||
1346 | 1331 | current_workspace = desktop->priv->single_workspace_num; | ||
1347 | 1332 | } else { | ||
1348 | 1333 | current_workspace = workspace_num; | ||
1349 | 1334 | } | ||
1350 | 1335 | |||
1351 | 1336 | DBG("workspace_num %d, single_workspace_num %d, current_workspace %d, max workspaces %d", | ||
1352 | 1337 | workspace_num, desktop->priv->single_workspace_num, current_workspace, | ||
1353 | 1338 | desktop->priv->nworkspaces); | ||
1354 | 1339 | |||
1355 | 1340 | return current_workspace; | ||
1356 | 1341 | } | ||
1357 | 1342 | |||
1358 | 1343 | /* public api */ | ||
1359 | 1344 | |||
1360 | 1345 | /** | ||
1361 | 1346 | * xfce_desktop_new: | ||
1362 | 1347 | * @gscreen: The current #GdkScreen. | ||
1363 | 1348 | * @channel: An #XfconfChannel to use for settings. | ||
1364 | 1349 | * @property_prefix: String prefix for per-screen properties. | ||
1365 | 1350 | * | ||
1366 | 1351 | * Creates a new #XfceDesktop for the specified #GdkScreen. If @gscreen is | ||
1367 | 1352 | * %NULL, the default screen will be used. | ||
1368 | 1353 | * | ||
1369 | 1354 | * Return value: A new #XfceDesktop. | ||
1370 | 1355 | **/ | ||
1371 | 1356 | GtkWidget * | ||
1372 | 1357 | xfce_desktop_new(GdkScreen *gscreen, | ||
1373 | 1358 | XfconfChannel *channel, | ||
1374 | 1359 | const gchar *property_prefix) | ||
1375 | 1360 | { | ||
1376 | 1361 | XfceDesktop *desktop; | ||
1377 | 1362 | |||
1378 | 1363 | g_return_val_if_fail(channel && property_prefix, NULL); | ||
1379 | 1364 | |||
1380 | 1365 | desktop = g_object_new(XFCE_TYPE_DESKTOP, NULL); | ||
1381 | 1366 | |||
1382 | 1367 | if(!gscreen) | ||
1383 | 1368 | gscreen = gdk_display_get_default_screen(gdk_display_get_default()); | ||
1384 | 1369 | gtk_window_set_screen(GTK_WINDOW(desktop), gscreen); | ||
1385 | 1370 | desktop->priv->gscreen = gscreen; | ||
1386 | 1371 | |||
1387 | 1372 | desktop->priv->channel = g_object_ref(G_OBJECT(channel)); | ||
1388 | 1373 | desktop->priv->property_prefix = g_strdup(property_prefix); | ||
1389 | 1374 | |||
1390 | 1375 | xfce_desktop_connect_settings(desktop); | ||
1391 | 1376 | |||
1392 | 1377 | return GTK_WIDGET(desktop); | ||
1393 | 1378 | } | ||
1394 | 1379 | |||
1395 | 1380 | gint | ||
1396 | 1381 | xfce_desktop_get_n_monitors(XfceDesktop *desktop) | ||
1397 | 1382 | { | ||
1398 | 1383 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), 0); | ||
1399 | 1384 | |||
1400 | 1385 | return gdk_screen_get_n_monitors(desktop->priv->gscreen); | ||
1401 | 1386 | } | ||
1402 | 1387 | |||
1403 | 1388 | gint | ||
1404 | 1389 | xfce_desktop_get_width(XfceDesktop *desktop) | ||
1405 | 1390 | { | ||
1406 | 1391 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); | ||
1407 | 1392 | |||
1408 | 1393 | return gdk_screen_get_width(desktop->priv->gscreen); | ||
1409 | 1394 | } | ||
1410 | 1395 | |||
1411 | 1396 | gint | ||
1412 | 1397 | xfce_desktop_get_height(XfceDesktop *desktop) | ||
1413 | 1398 | { | ||
1414 | 1399 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), -1); | ||
1415 | 1400 | |||
1416 | 1401 | return gdk_screen_get_height(desktop->priv->gscreen); | ||
1417 | 1402 | } | ||
1418 | 1403 | |||
1419 | 1404 | void | ||
1420 | 1405 | xfce_desktop_set_icon_style(XfceDesktop *desktop, | ||
1421 | 1406 | XfceDesktopIconStyle style) | ||
1422 | 1407 | { | ||
1423 | 1408 | g_return_if_fail(XFCE_IS_DESKTOP(desktop) | ||
1424 | 1409 | && style <= XFCE_DESKTOP_ICON_STYLE_FILES); | ||
1425 | 1410 | |||
1426 | 1411 | #ifdef ENABLE_DESKTOP_ICONS | ||
1427 | 1412 | if(style == desktop->priv->icons_style) | ||
1428 | 1413 | return; | ||
1429 | 1414 | |||
1430 | 1415 | if(desktop->priv->icon_view) { | ||
1431 | 1416 | gtk_widget_destroy(desktop->priv->icon_view); | ||
1432 | 1417 | desktop->priv->icon_view = NULL; | ||
1433 | 1418 | } | ||
1434 | 1419 | |||
1435 | 1420 | desktop->priv->icons_style = style; | ||
1436 | 1421 | if(gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
1437 | 1422 | xfce_desktop_setup_icon_view(desktop); | ||
1438 | 1423 | #endif | ||
1439 | 1424 | } | ||
1440 | 1425 | |||
1441 | 1426 | XfceDesktopIconStyle | ||
1442 | 1427 | xfce_desktop_get_icon_style(XfceDesktop *desktop) | ||
1443 | 1428 | { | ||
1444 | 1429 | g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), XFCE_DESKTOP_ICON_STYLE_NONE); | ||
1445 | 1430 | |||
1446 | 1431 | #ifdef ENABLE_DESKTOP_ICONS | ||
1447 | 1432 | return desktop->priv->icons_style; | ||
1448 | 1433 | #else | ||
1449 | 1434 | return XFCE_DESKTOP_ICON_STYLE_NONE; | ||
1450 | 1435 | #endif | ||
1451 | 1436 | } | ||
1452 | 1437 | |||
1453 | 1438 | void | ||
1454 | 1439 | xfce_desktop_set_icon_size(XfceDesktop *desktop, | ||
1455 | 1440 | guint icon_size) | ||
1456 | 1441 | { | ||
1457 | 1442 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1458 | 1443 | |||
1459 | 1444 | #ifdef ENABLE_DESKTOP_ICONS | ||
1460 | 1445 | if(icon_size == desktop->priv->icons_size) | ||
1461 | 1446 | return; | ||
1462 | 1447 | |||
1463 | 1448 | desktop->priv->icons_size = icon_size; | ||
1464 | 1449 | |||
1465 | 1450 | if(desktop->priv->icon_view) { | ||
1466 | 1451 | xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
1467 | 1452 | icon_size); | ||
1468 | 1453 | } | ||
1469 | 1454 | #endif | ||
1470 | 1455 | } | ||
1471 | 1456 | |||
1472 | 1457 | void | ||
1473 | 1458 | xfce_desktop_set_icon_font_size(XfceDesktop *desktop, | ||
1474 | 1459 | guint font_size_points) | ||
1475 | 1460 | { | ||
1476 | 1461 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1477 | 1462 | |||
1478 | 1463 | #ifdef ENABLE_DESKTOP_ICONS | ||
1479 | 1464 | if(font_size_points == desktop->priv->icons_font_size) | ||
1480 | 1465 | return; | ||
1481 | 1466 | |||
1482 | 1467 | desktop->priv->icons_font_size = font_size_points; | ||
1483 | 1468 | |||
1484 | 1469 | if(desktop->priv->icons_font_size_set && desktop->priv->icon_view) { | ||
1485 | 1470 | xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
1486 | 1471 | font_size_points); | ||
1487 | 1472 | } | ||
1488 | 1473 | #endif | ||
1489 | 1474 | } | ||
1490 | 1475 | |||
1491 | 1476 | void | ||
1492 | 1477 | xfce_desktop_set_use_icon_font_size(XfceDesktop *desktop, | ||
1493 | 1478 | gboolean use_icon_font_size) | ||
1494 | 1479 | { | ||
1495 | 1480 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1496 | 1481 | |||
1497 | 1482 | #ifdef ENABLE_DESKTOP_ICONS | ||
1498 | 1483 | if(use_icon_font_size == desktop->priv->icons_font_size_set) | ||
1499 | 1484 | return; | ||
1500 | 1485 | |||
1501 | 1486 | desktop->priv->icons_font_size_set = use_icon_font_size; | ||
1502 | 1487 | |||
1503 | 1488 | if(desktop->priv->icon_view) { | ||
1504 | 1489 | if(!use_icon_font_size) { | ||
1505 | 1490 | xfce_desktop_ensure_system_font_size(desktop); | ||
1506 | 1491 | xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
1507 | 1492 | desktop->priv->system_font_size); | ||
1508 | 1493 | } else { | ||
1509 | 1494 | xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), | ||
1510 | 1495 | desktop->priv->icons_font_size); | ||
1511 | 1496 | } | ||
1512 | 1497 | } | ||
1513 | 1498 | #endif | ||
1514 | 1499 | } | ||
1515 | 1500 | |||
1516 | 1501 | static void | ||
1517 | 1502 | xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop, | ||
1518 | 1503 | gboolean single_workspace) | ||
1519 | 1504 | { | ||
1520 | 1505 | gint i; | ||
1521 | 1506 | |||
1522 | 1507 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1523 | 1508 | |||
1524 | 1509 | if(single_workspace == desktop->priv->single_workspace_mode) | ||
1525 | 1510 | return; | ||
1526 | 1511 | |||
1527 | 1512 | desktop->priv->single_workspace_mode = single_workspace; | ||
1528 | 1513 | |||
1529 | 1514 | DBG("single_workspace_mode now %s", single_workspace ? "TRUE" : "FALSE"); | ||
1530 | 1515 | |||
1531 | 1516 | /* update the workspaces & backdrops if they should cache their pixbuf */ | ||
1532 | 1517 | if(desktop->priv->workspaces) { | ||
1533 | 1518 | for(i = 0; i < desktop->priv->nworkspaces; i++) { | ||
1534 | 1519 | /* set cache to TRUE when single_workspace is FALSE */ | ||
1535 | 1520 | xfce_workspace_set_cache_pixbufs(desktop->priv->workspaces[i], !single_workspace); | ||
1536 | 1521 | } | ||
1537 | 1522 | } | ||
1538 | 1523 | |||
1539 | 1524 | /* If the desktop has been realized then fake a screen size change to | ||
1540 | 1525 | * update the backdrop. There's no reason to if there's no desktop yet */ | ||
1541 | 1526 | if(gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
1542 | 1527 | screen_size_changed_cb(desktop->priv->gscreen, desktop); | ||
1543 | 1528 | } | ||
1544 | 1529 | |||
1545 | 1530 | static void | ||
1546 | 1531 | xfce_desktop_set_single_workspace_number(XfceDesktop *desktop, | ||
1547 | 1532 | gint workspace_num) | ||
1548 | 1533 | { | ||
1549 | 1534 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1550 | 1535 | |||
1551 | 1536 | if(workspace_num == desktop->priv->single_workspace_num) | ||
1552 | 1537 | return; | ||
1553 | 1538 | |||
1554 | 1539 | DBG("single_workspace_num now %d", workspace_num); | ||
1555 | 1540 | |||
1556 | 1541 | desktop->priv->single_workspace_num = workspace_num; | ||
1557 | 1542 | |||
1558 | 1543 | if(xfce_desktop_get_single_workspace_mode(desktop)) { | ||
1559 | 1544 | /* Fake a screen size changed to update the backdrop */ | ||
1560 | 1545 | screen_size_changed_cb(desktop->priv->gscreen, desktop); | ||
1561 | 1546 | } | ||
1562 | 1547 | } | ||
1563 | 1548 | |||
1564 | 1549 | void | ||
1565 | 1550 | xfce_desktop_set_session_logout_func(XfceDesktop *desktop, | ||
1566 | 1551 | SessionLogoutFunc logout_func) | ||
1567 | 1552 | { | ||
1568 | 1553 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1569 | 1554 | desktop->priv->session_logout_func = logout_func; | ||
1570 | 1555 | } | ||
1571 | 1556 | |||
1572 | 1557 | void | ||
1573 | 1558 | xfce_desktop_freeze_updates(XfceDesktop *desktop) | ||
1574 | 1559 | { | ||
1575 | 1560 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1576 | 1561 | desktop->priv->updates_frozen = TRUE; | ||
1577 | 1562 | } | ||
1578 | 1563 | |||
1579 | 1564 | void | ||
1580 | 1565 | xfce_desktop_thaw_updates(XfceDesktop *desktop) | ||
1581 | 1566 | { | ||
1582 | 1567 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1583 | 1568 | |||
1584 | 1569 | desktop->priv->updates_frozen = FALSE; | ||
1585 | 1570 | if(gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
1586 | 1571 | xfce_desktop_monitors_changed(desktop->priv->gscreen, desktop); | ||
1587 | 1572 | } | ||
1588 | 1573 | |||
1589 | 1574 | static gboolean | ||
1590 | 1575 | xfce_desktop_menu_destroy_idled(gpointer data) | ||
1591 | 1576 | { | ||
1592 | 1577 | gtk_widget_destroy(GTK_WIDGET(data)); | ||
1593 | 1578 | return FALSE; | ||
1594 | 1579 | } | ||
1595 | 1580 | |||
1596 | 1581 | static void | ||
1597 | 1582 | xfce_desktop_do_menu_popup(XfceDesktop *desktop, | ||
1598 | 1583 | guint button, | ||
1599 | 1584 | guint activate_time, | ||
1600 | 1585 | guint populate_signal) | ||
1601 | 1586 | { | ||
1602 | 1587 | GdkScreen *screen; | ||
1603 | 1588 | GtkWidget *menu; | ||
1604 | 1589 | GList *menu_children; | ||
1605 | 1590 | |||
1606 | 1591 | TRACE("entering"); | ||
1607 | 1592 | |||
1608 | 1593 | if(gtk_widget_has_screen(GTK_WIDGET(desktop))) | ||
1609 | 1594 | screen = gtk_widget_get_screen(GTK_WIDGET(desktop)); | ||
1610 | 1595 | else | ||
1611 | 1596 | screen = gdk_display_get_default_screen(gdk_display_get_default()); | ||
1612 | 1597 | |||
1613 | 1598 | menu = gtk_menu_new(); | ||
1614 | 1599 | gtk_menu_set_screen(GTK_MENU(menu), screen); | ||
1615 | 1600 | g_signal_connect_swapped(G_OBJECT(menu), "deactivate", | ||
1616 | 1601 | G_CALLBACK(g_idle_add), | ||
1617 | 1602 | (gpointer)xfce_desktop_menu_destroy_idled); | ||
1618 | 1603 | |||
1619 | 1604 | g_signal_emit(G_OBJECT(desktop), populate_signal, 0, menu); | ||
1620 | 1605 | |||
1621 | 1606 | /* if nobody populated the menu, don't do anything */ | ||
1622 | 1607 | menu_children = gtk_container_get_children(GTK_CONTAINER(menu)); | ||
1623 | 1608 | if(!menu_children) { | ||
1624 | 1609 | gtk_widget_destroy(menu); | ||
1625 | 1610 | return; | ||
1626 | 1611 | } | ||
1627 | 1612 | |||
1628 | 1613 | g_list_free(menu_children); | ||
1629 | 1614 | |||
1630 | 1615 | gtk_menu_attach_to_widget(GTK_MENU(menu), GTK_WIDGET(desktop), NULL); | ||
1631 | 1616 | |||
1632 | 1617 | /* Per gtk_menu_popup's documentation "for conflict-resolve initiation of | ||
1633 | 1618 | * concurrent requests for mouse/keyboard grab requests." */ | ||
1634 | 1619 | if(activate_time == 0) | ||
1635 | 1620 | activate_time = gtk_get_current_event_time(); | ||
1636 | 1621 | |||
1637 | 1622 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, activate_time); | ||
1638 | 1623 | } | ||
1639 | 1624 | |||
1640 | 1625 | void | ||
1641 | 1626 | xfce_desktop_popup_root_menu(XfceDesktop *desktop, | ||
1642 | 1627 | guint button, | ||
1643 | 1628 | guint activate_time) | ||
1644 | 1629 | { | ||
1645 | 1630 | TRACE("entering"); | ||
1646 | 1631 | |||
1647 | 1632 | /* If it's launched by xfdesktop --menu we won't have an event time. | ||
1648 | 1633 | * Grab the keyboard focus */ | ||
1649 | 1634 | if(activate_time == 0) | ||
1650 | 1635 | activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); | ||
1651 | 1636 | |||
1652 | 1637 | xfce_desktop_do_menu_popup(desktop, button, activate_time, | ||
1653 | 1638 | signals[SIG_POPULATE_ROOT_MENU]); | ||
1654 | 1639 | |||
1655 | 1640 | } | ||
1656 | 1641 | |||
1657 | 1642 | void | ||
1658 | 1643 | xfce_desktop_popup_secondary_root_menu(XfceDesktop *desktop, | ||
1659 | 1644 | guint button, | ||
1660 | 1645 | guint activate_time) | ||
1661 | 1646 | { | ||
1662 | 1647 | /* If it's launched by xfdesktop --windowlist we won't have an event time. | ||
1663 | 1648 | * Grab the keyboard focus */ | ||
1664 | 1649 | if(activate_time == 0) | ||
1665 | 1650 | activate_time = xfdesktop_popup_keyboard_grab_available(gtk_widget_get_window(GTK_WIDGET(desktop))); | ||
1666 | 1651 | |||
1667 | 1652 | xfce_desktop_do_menu_popup(desktop, button, activate_time, | ||
1668 | 1653 | signals[SIG_POPULATE_SECONDARY_ROOT_MENU]); | ||
1669 | 1654 | } | ||
1670 | 1655 | void | ||
1671 | 1656 | xfce_desktop_refresh(XfceDesktop *desktop) | ||
1672 | 1657 | { | ||
1673 | 1658 | gint i, current_workspace; | ||
1674 | 1659 | |||
1675 | 1660 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1676 | 1661 | |||
1677 | 1662 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
1678 | 1663 | return; | ||
1679 | 1664 | |||
1680 | 1665 | current_workspace = xfce_desktop_get_current_workspace(desktop); | ||
1681 | 1666 | |||
1682 | 1667 | /* reload backgrounds */ | ||
1683 | 1668 | for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) { | ||
1684 | 1669 | XfceBackdrop *backdrop; | ||
1685 | 1670 | |||
1686 | 1671 | backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i); | ||
1687 | 1672 | |||
1688 | 1673 | backdrop_changed_cb(backdrop, desktop); | ||
1689 | 1674 | } | ||
1690 | 1675 | |||
1691 | 1676 | #ifdef ENABLE_DESKTOP_ICONS | ||
1692 | 1677 | /* reload icon view */ | ||
1693 | 1678 | if(desktop->priv->icon_view) { | ||
1694 | 1679 | gtk_widget_destroy(desktop->priv->icon_view); | ||
1695 | 1680 | desktop->priv->icon_view = NULL; | ||
1696 | 1681 | } | ||
1697 | 1682 | xfce_desktop_setup_icon_view(desktop); | ||
1698 | 1683 | #endif | ||
1699 | 1684 | } | ||
1700 | 1685 | |||
1701 | 1686 | void xfce_desktop_arrange_icons(XfceDesktop *desktop) | ||
1702 | 1687 | { | ||
1703 | 1688 | g_return_if_fail(XFCE_IS_DESKTOP(desktop)); | ||
1704 | 1689 | |||
1705 | 1690 | #ifdef ENABLE_DESKTOP_ICONS | ||
1706 | 1691 | g_return_if_fail(XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view)); | ||
1707 | 1692 | |||
1708 | 1693 | xfdesktop_icon_view_sort_icons(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view)); | ||
1709 | 1694 | #endif | ||
1710 | 1695 | } | ||
1711 | 0 | 1696 | ||
1712 | === added file '.pc/xubuntu_improve-nautilus-interactions.patch/.timestamp' | |||
1713 | === modified file '.pc/xubuntu_improve-nautilus-interactions.patch/src/xfce-desktop.c' | |||
1714 | --- .pc/xubuntu_improve-nautilus-interactions.patch/src/xfce-desktop.c 2014-02-20 15:59:49 +0000 | |||
1715 | +++ .pc/xubuntu_improve-nautilus-interactions.patch/src/xfce-desktop.c 2014-03-01 05:37:37 +0000 | |||
1716 | @@ -1747,6 +1747,10 @@ | |||
1717 | 1747 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) | 1747 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1718 | 1748 | return; | 1748 | return; |
1719 | 1749 | 1749 | ||
1720 | 1750 | if(desktop->priv->workspaces == NULL) { | ||
1721 | 1751 | return; | ||
1722 | 1752 | } | ||
1723 | 1753 | |||
1724 | 1750 | current_workspace = xfce_desktop_get_current_workspace(desktop); | 1754 | current_workspace = xfce_desktop_get_current_workspace(desktop); |
1725 | 1751 | 1755 | ||
1726 | 1752 | /* reload backgrounds */ | 1756 | /* reload backgrounds */ |
1727 | 1753 | 1757 | ||
1728 | === added file '.pc/xubuntu_set-accountsservice-user-bg.patch/.timestamp' | |||
1729 | === modified file '.pc/xubuntu_set-accountsservice-user-bg.patch/src/xfce-desktop.c' | |||
1730 | --- .pc/xubuntu_set-accountsservice-user-bg.patch/src/xfce-desktop.c 2014-02-20 15:59:49 +0000 | |||
1731 | +++ .pc/xubuntu_set-accountsservice-user-bg.patch/src/xfce-desktop.c 2014-03-01 05:37:37 +0000 | |||
1732 | @@ -1662,6 +1662,10 @@ | |||
1733 | 1662 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) | 1662 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1734 | 1663 | return; | 1663 | return; |
1735 | 1664 | 1664 | ||
1736 | 1665 | if(desktop->priv->workspaces == NULL) { | ||
1737 | 1666 | return; | ||
1738 | 1667 | } | ||
1739 | 1668 | |||
1740 | 1665 | current_workspace = xfce_desktop_get_current_workspace(desktop); | 1669 | current_workspace = xfce_desktop_get_current_workspace(desktop); |
1741 | 1666 | 1670 | ||
1742 | 1667 | /* reload backgrounds */ | 1671 | /* reload backgrounds */ |
1743 | 1668 | 1672 | ||
1744 | === modified file 'debian/changelog' | |||
1745 | --- debian/changelog 2014-02-20 15:59:49 +0000 | |||
1746 | +++ debian/changelog 2014-03-01 05:37:37 +0000 | |||
1747 | @@ -1,3 +1,21 @@ | |||
1748 | 1 | xfdesktop4 (4.11.3-2ubuntu1) trusty; urgency=medium | ||
1749 | 2 | |||
1750 | 3 | * Merge from debian. Remaining changes: | ||
1751 | 4 | - debian/patches/xubuntu_improve-nautilus-interactions.patch: added, | ||
1752 | 5 | should prevent nautilus from taking over the desktop if xfdesktop is | ||
1753 | 6 | running (and vice-versa). | ||
1754 | 7 | - debian/patches/xubuntu_set-accountsservice-user-bg.patch: update the | ||
1755 | 8 | user background property of Accountsservice on backdrop change. | ||
1756 | 9 | |||
1757 | 10 | -- Jackson Doak <noskcaj@ubuntu.com> Sat, 01 Mar 2014 16:02:38 +1100 | ||
1758 | 11 | |||
1759 | 12 | xfdesktop4 (4.11.3-2) experimental; urgency=medium | ||
1760 | 13 | |||
1761 | 14 | [ Jackson Doak ] | ||
1762 | 15 | * Add git-fix-segfault-on-session-start.patch. LP: #1282509 | ||
1763 | 16 | |||
1764 | 17 | -- Yves-Alexis Perez <corsac@debian.org> Fri, 28 Feb 2014 21:52:55 +0100 | ||
1765 | 18 | |||
1766 | 1 | xfdesktop4 (4.11.3-1ubuntu1) trusty; urgency=medium | 19 | xfdesktop4 (4.11.3-1ubuntu1) trusty; urgency=medium |
1767 | 2 | 20 | ||
1768 | 3 | * Merge from debian. Remaining changes: | 21 | * Merge from debian. Remaining changes: |
1769 | 4 | 22 | ||
1770 | === added file 'debian/patches/git-fix-segfault-on-session-start.patch' | |||
1771 | --- debian/patches/git-fix-segfault-on-session-start.patch 1970-01-01 00:00:00 +0000 | |||
1772 | +++ debian/patches/git-fix-segfault-on-session-start.patch 2014-03-01 05:37:37 +0000 | |||
1773 | @@ -0,0 +1,23 @@ | |||
1774 | 1 | Description: Stop segfaulting on session start | ||
1775 | 2 | Stop segfaulting on session start. Fix taken from upstream git | ||
1776 | 3 | Author: Thaddäus Tintenfisch | ||
1777 | 4 | Bug: https://bugzilla.xfce.org/show_bug.cgi?id=10705 | ||
1778 | 5 | Bug-Ubuntu: https://launchpad.net/bugs/1282509 | ||
1779 | 6 | |||
1780 | 7 | --- | ||
1781 | 8 | src/xfce-desktop.c | 4 ++++ | ||
1782 | 9 | 1 file changed, 4 insertions(+) | ||
1783 | 10 | |||
1784 | 11 | --- a/src/xfce-desktop.c | ||
1785 | 12 | +++ b/src/xfce-desktop.c | ||
1786 | 13 | @@ -1662,6 +1662,10 @@ xfce_desktop_refresh(XfceDesktop *deskto | ||
1787 | 14 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) | ||
1788 | 15 | return; | ||
1789 | 16 | |||
1790 | 17 | + if(desktop->priv->workspaces == NULL) { | ||
1791 | 18 | + return; | ||
1792 | 19 | + } | ||
1793 | 20 | + | ||
1794 | 21 | current_workspace = xfce_desktop_get_current_workspace(desktop); | ||
1795 | 22 | |||
1796 | 23 | /* reload backgrounds */ | ||
1797 | 0 | 24 | ||
1798 | === modified file 'debian/patches/series' | |||
1799 | --- debian/patches/series 2014-01-22 11:02:26 +0000 | |||
1800 | +++ debian/patches/series 2014-03-01 05:37:37 +0000 | |||
1801 | @@ -1,2 +1,3 @@ | |||
1802 | 1 | git-fix-segfault-on-session-start.patch | ||
1803 | 1 | xubuntu_set-accountsservice-user-bg.patch | 2 | xubuntu_set-accountsservice-user-bg.patch |
1804 | 2 | xubuntu_improve-nautilus-interactions.patch | 3 | xubuntu_improve-nautilus-interactions.patch |
1805 | 3 | 4 | ||
1806 | === modified file 'src/xfce-desktop.c' | |||
1807 | --- src/xfce-desktop.c 2014-02-20 15:59:49 +0000 | |||
1808 | +++ src/xfce-desktop.c 2014-03-01 05:37:37 +0000 | |||
1809 | @@ -1758,6 +1758,10 @@ | |||
1810 | 1758 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) | 1758 | if(!gtk_widget_get_realized(GTK_WIDGET(desktop))) |
1811 | 1759 | return; | 1759 | return; |
1812 | 1760 | 1760 | ||
1813 | 1761 | if(desktop->priv->workspaces == NULL) { | ||
1814 | 1762 | return; | ||
1815 | 1763 | } | ||
1816 | 1764 | |||
1817 | 1761 | current_workspace = xfce_desktop_get_current_workspace(desktop); | 1765 | current_workspace = xfce_desktop_get_current_workspace(desktop); |
1818 | 1762 | 1766 | ||
1819 | 1763 | /* reload backgrounds */ | 1767 | /* reload backgrounds */ |
Thanks, uploaded.