Make behavior by commit ae15e9547e48a2339d9aeb271d85eb46b846e09b optional.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 18 Nov 2014 20:18:25 +0000 (22:18 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Tue, 18 Nov 2014 20:18:25 +0000 (22:18 +0200)
data/ui/launchtaskbar.glade
plugins/launchtaskbar.c

index 50118a4..0eac29e 100644 (file)
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkCheckButton" id="checkbutton_disable_taskbar_upscale">
+                    <property name="label" translatable="yes">Disable enlargement for small task icons</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">8</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkHBox" id="hbox2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">8</property>
+                    <property name="position">9</property>
                   </packing>
                 </child>
                 <child>
                   <packing>
                     <property name="expand">True</property>
                     <property name="fill">True</property>
-                    <property name="position">9</property>
+                    <property name="position">10</property>
                   </packing>
                 </child>
               </object>
index 5e2d9a7..c7143b4 100644 (file)
@@ -163,6 +163,7 @@ struct LaunchTaskBarPlugin {
     gboolean flat_button;          /* User preference: taskbar buttons have visible background */
     gboolean grouped_tasks;        /* User preference: windows from same task are grouped onto a single button */
     gboolean same_monitor_only;    /* User preference: only show windows that are in the same monitor as the taskbar */
+    gboolean disable_taskbar_upscale; /* User preference: don't upscale taskbar icons */
     int task_width_max;            /* Maximum width of a taskbar button in horizontal orientation */
     int spacing;                   /* Spacing between taskbar buttons */
     gboolean use_net_active;       /* NET_WM_ACTIVE_WINDOW is supported by the window manager */
@@ -716,6 +717,8 @@ static void launchtaskbar_constructor_task(LaunchTaskBarPlugin *ltbp)
             ltbp->show_all_desks = (tmp_int != 0);
         if (config_setting_lookup_int(s, "SameMonitorOnly", &tmp_int))
             ltbp->same_monitor_only = (tmp_int != 0);
+        if (config_setting_lookup_int(s, "DisableUpscale", &tmp_int))
+            ltbp->disable_taskbar_upscale = (tmp_int != 0);
         config_setting_lookup_int(s, "MaxTaskWidth", &ltbp->task_width_max);
         config_setting_lookup_int(s, "spacing", &ltbp->spacing);
         if (config_setting_lookup_int(s, "UseMouseWheel", &tmp_int))
@@ -1207,6 +1210,15 @@ static void on_checkbutton_same_monitor_only_toggled(GtkToggleButton *p_togglebu
     taskbar_apply_configuration(ltbp);
 }
 
+static void on_checkbutton_disable_taskbar_upscale_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
+{
+    LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
+    ltbp->disable_taskbar_upscale = gtk_toggle_button_get_active(p_togglebutton);
+    //g_print("\ntb->disable_taskbar_upscale upd\n");
+    config_group_set_int(ltbp->settings, "DisableUpscale", ltbp->disable_taskbar_upscale);
+    taskbar_apply_configuration(ltbp);
+}
+
 static void on_checkbutton_mouse_wheel_toggled(GtkToggleButton *p_togglebutton, gpointer p_data)
 {
     LaunchTaskBarPlugin *ltbp = (LaunchTaskBarPlugin *)p_data;
@@ -1390,7 +1402,15 @@ static GtkWidget *launchtaskbar_configure(LXPanel *panel, GtkWidget *p)
         SETUP_TOGGLE_BUTTON(checkbutton_mouse_wheel, use_mouse_wheel);
         SETUP_TOGGLE_BUTTON(checkbutton_urgency_hint, use_urgency_hint);
         SETUP_TOGGLE_BUTTON(checkbutton_grouped_tasks, grouped_tasks);
+        //SETUP_TOGGLE_BUTTON(checkbutton_disable_taskbar_upscale, disable_taskbar_upscale);
 #undef SETUP_TOGGLE_BUTTON
+        /* FIXME: for transitional period, turn into SETUP_TOGGLE_BUTTON later */
+        object = gtk_builder_get_object(builder, "checkbutton_disable_taskbar_upscale");
+        if (object)
+        {
+            gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object), ltbp->disable_taskbar_upscale); \
+            g_signal_connect(object, "toggled", G_CALLBACK(on_checkbutton_disable_taskbar_upscale_toggled), ltbp);
+        }
 
 #define SETUP_SPIN_BUTTON(button,member) \
         object = gtk_builder_get_object(builder, #button); \
@@ -1985,7 +2005,9 @@ static GdkPixbuf * apply_mask(GdkPixbuf * pixbuf, GdkPixbuf * mask)
 }
 
 /* Get an icon from the window manager for a task, and scale it to a specified size. */
-static GdkPixbuf * get_wm_icon(Window task_win, guint required_width, guint required_height, Atom source, Atom * current_source)
+static GdkPixbuf * get_wm_icon(Window task_win, guint required_width,
+                               guint required_height, Atom source,
+                               Atom * current_source, LaunchTaskBarPlugin * tb)
 {
     /* The result. */
     GdkPixbuf * pixmap = NULL;
@@ -2225,17 +2247,21 @@ static GdkPixbuf * get_wm_icon(Window task_win, guint required_width, guint requ
         return NULL;
     else
     {
-        gulong w = gdk_pixbuf_get_width (pixmap);
-       gulong h = gdk_pixbuf_get_height (pixmap);
-       if ((w > required_width) || (h > required_height))
-       {
-           w = required_width;
-           h = required_height;
-       }
+        GdkPixbuf * ret;
 
-        GdkPixbuf * ret = gdk_pixbuf_scale_simple(pixmap, w, h, GDK_INTERP_TILES);
-        g_object_unref(pixmap);
         *current_source = possible_source;
+        if (tb->disable_taskbar_upscale)
+        {
+            guint w = gdk_pixbuf_get_width (pixmap);
+            guint h = gdk_pixbuf_get_height (pixmap);
+            if (w <= required_width || h <= required_height)
+            {
+                return pixmap;
+            }
+        }
+        ret = gdk_pixbuf_scale_simple(pixmap, required_width, required_height,
+                                      GDK_INTERP_BILINEAR);
+        g_object_unref(pixmap);
         return ret;
     }
 }
@@ -2246,7 +2272,7 @@ static GdkPixbuf * task_update_icon(LaunchTaskBarPlugin * tb, Task * tk, Atom so
     /* Get the icon from the window's hints. */
     GdkPixbuf * pixbuf = get_wm_icon(tk->win, MAX(0, tb->icon_size - ICON_BUTTON_TRIM),
                                      MAX(0, tb->icon_size - ICON_BUTTON_TRIM),
-                                     source, &tk->image_source);
+                                     source, &tk->image_source, tb);
 
     /* If that fails, and we have no other icon yet, return the fallback icon. */
     if ((pixbuf == NULL)