[Xfce4-commits] <xfdesktop:eric/icon-changes> Don't call wnck_screen_force_update
Eric Koegel
noreply at xfce.org
Sun Sep 1 14:32:02 CEST 2013
Updating branch refs/heads/eric/icon-changes
to 9becad1569798894bdae9beaffc9076338fed299 (commit)
from 3b18c3b222314c65789006477a2f0e5e6d9e78c3 (commit)
commit 9becad1569798894bdae9beaffc9076338fed299
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Sun Sep 1 15:23:27 2013 +0300
Don't call wnck_screen_force_update
Remove the call to wnck_screen_force_update and let wnck initialize
during the main idle loop. Also fix a couple memory leaks.
src/xfce-desktop.c | 91 ++++++++++++++++++++-----------------
src/xfdesktop-file-icon-manager.c | 19 ++++----
src/xfdesktop-icon-view.c | 5 +-
3 files changed, 62 insertions(+), 53 deletions(-)
diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 149a833..101bcb6 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -312,6 +312,40 @@ set_real_root_window_pixmap(GdkScreen *gscreen,
#endif
}
+static GdkPixmap *
+create_bg_pixmap(GdkScreen *gscreen, gpointer user_data)
+{
+ XfceDesktop *desktop = user_data;
+ gint w, h;
+
+ TRACE("entering");
+
+ g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), NULL);
+
+ if(desktop->priv->workspaces == NULL)
+ return NULL;
+
+ w = gdk_screen_get_width(gscreen);
+ h = gdk_screen_get_height(gscreen);
+ gtk_widget_set_size_request(GTK_WIDGET(desktop), w, h);
+ gtk_window_resize(GTK_WINDOW(desktop), w, h);
+
+ if(desktop->priv->bg_pixmap)
+ g_object_unref(G_OBJECT(desktop->priv->bg_pixmap));
+ desktop->priv->bg_pixmap = gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(GTK_WIDGET(desktop))),
+ w, h, -1);
+
+ if(!GDK_IS_PIXMAP(desktop->priv->bg_pixmap))
+ return NULL;
+
+ set_real_root_window_pixmap(desktop->priv->gscreen,
+ desktop->priv->bg_pixmap);
+ gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)),
+ desktop->priv->bg_pixmap, FALSE);
+
+ return desktop->priv->bg_pixmap;
+}
+
static void
backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data)
{
@@ -328,7 +362,14 @@ backdrop_changed_cb(XfceBackdrop *backdrop, gpointer user_data)
if(desktop->priv->updates_frozen || !gtk_widget_get_realized(GTK_WIDGET(desktop)))
return;
-
+
+ if(!GDK_IS_PIXMAP(pmap)) {
+ pmap = create_bg_pixmap(gscreen, desktop);
+
+ if(!GDK_IS_PIXMAP(pmap))
+ return;
+ }
+
TRACE("really entering");
current_workspace = xfce_desktop_get_current_workspace(desktop);
@@ -454,28 +495,12 @@ static void
screen_size_changed_cb(GdkScreen *gscreen, gpointer user_data)
{
XfceDesktop *desktop = user_data;
- gint w, h, current_workspace;
+ gint current_workspace;
TRACE("entering");
- g_return_if_fail(XFCE_IS_DESKTOP(desktop));
-
- if(desktop->priv->workspaces == NULL)
+ if(!create_bg_pixmap(gscreen, desktop))
return;
-
- w = gdk_screen_get_width(gscreen);
- h = gdk_screen_get_height(gscreen);
- gtk_widget_set_size_request(GTK_WIDGET(desktop), w, h);
- gtk_window_resize(GTK_WINDOW(desktop), w, h);
-
- if(desktop->priv->bg_pixmap)
- g_object_unref(G_OBJECT(desktop->priv->bg_pixmap));
- desktop->priv->bg_pixmap = gdk_pixmap_new(GDK_DRAWABLE(gtk_widget_get_window(GTK_WIDGET(desktop))),
- w, h, -1);
- set_real_root_window_pixmap(desktop->priv->gscreen,
- desktop->priv->bg_pixmap);
- gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)),
- desktop->priv->bg_pixmap, FALSE);
current_workspace = xfce_desktop_get_current_workspace(desktop);
@@ -567,7 +592,7 @@ workspace_changed_cb(WnckScreen *wnck_screen,
for(i = 0; i < xfce_desktop_get_n_monitors(desktop); i++) {
/* We want to compare the current workspace backdrop with the new one
* and see if we can avoid changing them if they are the same image/style */
- if(current_workspace < desktop->priv->nworkspaces) {
+ if(current_workspace < desktop->priv->nworkspaces && current_workspace >= 0) {
current_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[current_workspace], i);
new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i);
@@ -576,7 +601,8 @@ workspace_changed_cb(WnckScreen *wnck_screen,
backdrop_changed_cb(new_backdrop, user_data);
}
} else {
- /* If current_workspace was removed, get the new backdrop and apply it */
+ /* If current_workspace was removed or never existed, get the new
+ * backdrop and apply it */
new_backdrop = xfce_workspace_get_backdrop(desktop->priv->workspaces[new_workspace], i);
backdrop_changed_cb(new_backdrop, user_data);
}
@@ -920,7 +946,7 @@ xfce_desktop_realize(GtkWidget *widget)
{
XfceDesktop *desktop = XFCE_DESKTOP(widget);
GdkAtom atom;
- gint sw, sh, i;
+ gint sw, sh;
Window xid;
GdkWindow *groot;
WnckScreen *wnck_screen;
@@ -970,7 +996,6 @@ xfce_desktop_realize(GtkWidget *widget)
/* We have to force wnck to initialize */
wnck_screen = wnck_screen_get(gdk_screen_get_number(desktop->priv->gscreen));
- wnck_screen_force_update(wnck_screen);
desktop->priv->wnck_screen = wnck_screen;
xfconf_g_property_bind(desktop->priv->channel,
@@ -981,24 +1006,8 @@ xfce_desktop_realize(GtkWidget *widget)
SINGLE_WORKSPACE_NUMBER, G_TYPE_INT,
G_OBJECT(desktop), "single-workspace-number");
- /* Get the current workspace number */
- desktop->priv->current_workspace = xfce_desktop_get_current_workspace(desktop);
- desktop->priv->nworkspaces = wnck_screen_get_workspace_count(wnck_screen);
-
- desktop->priv->workspaces = g_realloc(desktop->priv->workspaces,
- desktop->priv->nworkspaces * sizeof(XfceWorkspace *));
-
- for(i = 0; i < desktop->priv->nworkspaces; i++) {
- desktop->priv->workspaces[i] = xfce_workspace_new(desktop->priv->gscreen,
- desktop->priv->channel,
- desktop->priv->property_prefix,
- i);
- xfce_workspace_monitors_changed(desktop->priv->workspaces[i],
- desktop->priv->gscreen);
-
- g_signal_connect(desktop->priv->workspaces[i], "workspace-backdrop-changed",
- G_CALLBACK(workspace_backdrop_changed_cb), desktop);
- }
+ /* Start with an invalid workspace so it updates */
+ desktop->priv->current_workspace = -1;
g_signal_connect(desktop->priv->wnck_screen, "active-workspace-changed",
G_CALLBACK(workspace_changed_cb), desktop);
diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c
index d7db8c6..155be45 100644
--- a/src/xfdesktop-file-icon-manager.c
+++ b/src/xfdesktop-file-icon-manager.c
@@ -416,7 +416,10 @@ xfdesktop_file_icon_manager_finalize(GObject *obj)
g_object_unref(fmanager->priv->folder);
g_object_unref(fmanager->priv->thumbnailer);
-
+
+ if(fmanager->priv->volume_monitor != NULL)
+ g_object_unref(fmanager->priv->volume_monitor);
+
G_OBJECT_CLASS(xfdesktop_file_icon_manager_parent_class)->finalize(obj);
}
@@ -537,6 +540,8 @@ xfdesktop_file_icon_manager_check_create_desktop_folder(GFile *folder)
}
}
+ g_object_unref(info);
+
return result;
}
@@ -2263,8 +2268,7 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor *monitor,
switch(event) {
case G_FILE_MONITOR_EVENT_MOVED:
- DBG("got a moved event, old filename: %s new filename: %s",
- g_file_get_path(file), g_file_get_path(other_file));
+ DBG("got a moved event");
icon = g_hash_table_lookup(fmanager->priv->icons, file);
if(!icon) {
@@ -2305,7 +2309,7 @@ xfdesktop_file_icon_manager_file_changed(GFileMonitor *monitor,
break;
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
case G_FILE_MONITOR_EVENT_CHANGED:
- DBG("got changed event: %s", g_file_get_path(file));
+ DBG("got changed event");
icon = g_hash_table_lookup(fmanager->priv->icons, file);
if(icon) {
@@ -2679,12 +2683,8 @@ xfdesktop_file_icon_manager_load_removable_media(XfdesktopFileIconManager *fmana
if(fmanager->priv->removable_icons)
return;
- if(!fmanager->priv->volume_monitor) {
+ if(!fmanager->priv->volume_monitor)
fmanager->priv->volume_monitor = g_volume_monitor_get();
- g_object_add_weak_pointer(G_OBJECT(fmanager->priv->volume_monitor),
- (gpointer)&fmanager->priv->volume_monitor);
- } else
- g_object_ref(G_OBJECT(fmanager->priv->volume_monitor));
fmanager->priv->removable_icons = g_hash_table_new_full(g_direct_hash,
g_direct_equal,
@@ -2745,6 +2745,7 @@ xfdesktop_file_icon_manager_remove_removable_media(XfdesktopFileIconManager *fma
fmanager);
g_object_unref(fmanager->priv->volume_monitor);
+ fmanager->priv->volume_monitor = NULL;
}
}
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index ac97f20..b7fecaa 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -1913,7 +1913,8 @@ xfdesktop_icon_view_realize(GtkWidget *widget)
pctx = gtk_widget_get_pango_context(GTK_WIDGET(icon_view));
icon_view->priv->playout = pango_layout_new(pctx);
-
+ g_object_unref(pctx);
+
if(icon_view->priv->font_size > 0) {
xfdesktop_icon_view_modify_font_size(icon_view,
icon_view->priv->font_size);
@@ -2806,7 +2807,6 @@ xfdesktop_icon_view_setup_pango_layout(XfdesktopIconView *icon_view,
PangoLayout *playout)
{
const gchar *label = xfdesktop_icon_peek_label(icon);
- PangoRectangle prect;
g_return_if_fail(XFDESKTOP_IS_ICON_VIEW(icon_view)
&& XFDESKTOP_IS_ICON(icon));
@@ -2816,7 +2816,6 @@ xfdesktop_icon_view_setup_pango_layout(XfdesktopIconView *icon_view,
pango_layout_set_width(playout, TEXT_WIDTH * PANGO_SCALE);
pango_layout_set_text(playout, label, -1);
- pango_layout_get_pixel_extents(playout, NULL, &prect);
if(!xfdesktop_icon_view_is_icon_selected(icon_view, icon)
&& icon_view->priv->ellipsize_icon_labels) {
/* constrain the text area */
More information about the Xfce4-commits
mailing list