all repos — tint2 @ 7582b9f9600be5195908351e28258b222f4c698c

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Add option primary_monitor_first (fixes issue #538)
o9000 mrovi9000@gmail.com
commit

7582b9f9600be5195908351e28258b222f4c698c

parent

da0c52ecff5eaf4a24b5ab6c476bb1ac96eb49d5

M src/config.csrc/config.c

@@ -294,6 +294,8 @@

/* Panel */ else if (strcmp(key, "panel_monitor") == 0) { panel_config.monitor = config_get_monitor(value); + } else if (strcmp(key, "primary_monitor_first") == 0) { + primary_monitor_first = atoi(value); } else if (strcmp(key, "panel_size") == 0) { extract_values(value, &value1, &value2, &value3);
M src/server.csrc/server.c

@@ -31,6 +31,8 @@ #include "window.h"

Server server; +gboolean primary_monitor_first = FALSE; + void server_catch_error(Display *d, XErrorEvent *ev) { }

@@ -261,6 +263,13 @@ {

const Monitor *m1 = (const Monitor *)monitor1; const Monitor *m2 = (const Monitor *)monitor2; + if (primary_monitor_first) { + if (m1->primary && !m2->primary) + return 1; + if (m2->primary && !m1->primary) + return -1; + } + if (m1->x < m2->x) { return -1; } else if (m1->x > m2->x) {

@@ -294,6 +303,7 @@ if (XineramaIsActive(server.dsp)) {

int num_monitors; XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &num_monitors); XRRScreenResources *res = XRRGetScreenResourcesCurrent(server.dsp, server.root_win); + RROutput primary_output = XRRGetOutputPrimary(server.dsp, server.root_win); if (res && res->ncrtc >= num_monitors) { // use xrandr to identify monitors (does not work with proprietery nvidia drivers)

@@ -323,6 +333,7 @@ XRROutputInfo *output_info = XRRGetOutputInfo(server.dsp, res, crtc_info->outputs[j]);

printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i); server.monitors[i].names[j] = g_strdup(output_info->name); XRRFreeOutputInfo(output_info); + server.monitors[i].primary = crtc_info->outputs[j] == primary_output; } server.monitors[i].names[crtc_info->noutput] = NULL; XRRFreeCrtcInfo(crtc_info);
M src/server.hsrc/server.h

@@ -18,6 +18,8 @@ #include <libsn/sn.h>

#endif #include <glib.h> +extern gboolean primary_monitor_first; + typedef struct Global_atom { Atom _XROOTPMAP_ID; Atom _XROOTMAP_ID;

@@ -96,6 +98,7 @@ int x;

int y; int width; int height; + gboolean primary; gchar **names; } Monitor;
M src/tint2conf/properties.csrc/tint2conf/properties.c

@@ -37,6 +37,7 @@ GtkWidget *panel_window_name, *disable_transparency;

GtkWidget *panel_mouse_effects; GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness; +GtkWidget *panel_primary_monitor_first; GtkListStore *panel_items, *all_items; GtkWidget *panel_items_view, *all_items_view;

@@ -1129,6 +1130,20 @@ gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("5"));

gtk_combo_box_append_text(GTK_COMBO_BOX(panel_combo_monitor), _("6")); gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 0); gtk_tooltips_set_tip(tooltips, panel_combo_monitor, _("The monitor on which the panel is placed"), NULL); + + row++; + col = 2; + label = gtk_label_new(_("Primary monitor first")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + + panel_primary_monitor_first = gtk_check_button_new(); + gtk_widget_show(panel_primary_monitor_first); + gtk_table_attach(GTK_TABLE(table), panel_primary_monitor_first, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, panel_primary_monitor_first, _("If enabled, the primary monitor will have index 1 in the monitor list even if it is not top-left."), NULL); row++; col = 2;
M src/tint2conf/properties.hsrc/tint2conf/properties.h

@@ -17,6 +17,7 @@ extern GtkWidget *panel_window_name, *disable_transparency;

extern GtkWidget *panel_mouse_effects; extern GtkWidget *mouse_hover_icon_opacity, *mouse_hover_icon_saturation, *mouse_hover_icon_brightness; extern GtkWidget *mouse_pressed_icon_opacity, *mouse_pressed_icon_saturation, *mouse_pressed_icon_brightness; +extern GtkWidget *panel_primary_monitor_first; enum { itemsColName = 0,
M src/tint2conf/properties_rw.csrc/tint2conf/properties_rw.c

@@ -228,6 +228,8 @@ fprintf(fp, "%d", gtk_combo_box_get_active(GTK_COMBO_BOX(panel_combo_monitor)));

} fprintf(fp, "\n"); + fprintf(fp, "primary_monitor_first = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first)) ? 1 : 0); + fprintf(fp, "autohide = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(panel_autohide)) ? 1 : 0); fprintf(fp, "autohide_show_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_show_time))); fprintf(fp, "autohide_hide_timeout = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(panel_autohide_hide_time)));

@@ -1021,6 +1023,9 @@ else if (strcmp(value, "5") == 0)

gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 5); else if (strcmp(value, "6") == 0) gtk_combo_box_set_active(GTK_COMBO_BOX(panel_combo_monitor), 6); + } + else if (strcmp(key, "primary_monitor_first") == 0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(panel_primary_monitor_first), atoi(value)); } /* autohide options */