improve multi_monitor mode

git-svn-id: http://tint2.googlecode.com/svn/trunk@29 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-01-29 22:43:31 +00:00
parent e36c729d7b
commit f0adc5c7d0
13 changed files with 120 additions and 109 deletions

View file

@ -1,3 +1,7 @@
2009-01-29
- use panel_margin parameter even with full_width
- multi_monitor mode : monitor number are ordered according to coordinate
so taskbar on the left show task in the left monitor
2009-01-20
- change config file format : add another padding parameter

View file

@ -43,6 +43,7 @@ void init_clock(Clock *clock, int panel_height)
clock->area.posy = panel.area.pix.border.width + panel.area.paddingy;
clock->area.height = panel.area.height - (2 * clock->area.posy);
clock->area.width = 0; // force posx and width detection
clock->area.redraw = 1;
gettimeofday(&clock->clock, 0);

View file

@ -105,18 +105,17 @@ void copy_file(const char *pathSrc, const char *pathDest)
void extract_values (const char *value, char **value1, char **value2, char **value3)
{
char *b, *c;
char *b=0, *c=0;
if (*value1) free (*value1);
if (*value2) free (*value2);
if (*value3) free (*value3);
if (b = strchr (value, ' ')) {
if ((b = strchr (value, ' '))) {
b[0] = '\0';
b++;
}
else {
b = 0;
*value2 = 0;
*value3 = 0;
}
@ -124,7 +123,7 @@ void extract_values (const char *value, char **value1, char **value2, char **val
g_strstrip(*value1);
if (b) {
if (c = strchr (b, ' ')) {
if ((c = strchr (b, ' '))) {
c[0] = '\0';
c++;
}
@ -254,8 +253,9 @@ void add_entry (char *key, char *value)
}
else if (strcmp (key, "panel_margin") == 0) {
extract_values(value, &value1, &value2, &value3);
panel.marginx = atoi (value1);
panel.marginleft = panel.marginright = atoi (value1);
if (value2) panel.marginy = atoi (value2);
if (value3) panel.marginright = atoi (value3);
}
else if (strcmp (key, "panel_padding") == 0) {
extract_values(value, &value1, &value2, &value3);
@ -543,7 +543,7 @@ void config_finish ()
if (panel.monitor > (server.nb_monitor-1)) {
panel.sleep_mode = 1;
printf("tint2 sleep and wait monitor %d.\n", panel.monitor+1);
fprintf(stderr, "tint2 sleep and wait monitor %d.\n", panel.monitor+1);
}
else {
panel.sleep_mode = 0;
@ -552,7 +552,7 @@ void config_finish ()
fprintf(stderr, "tint2 error : invalid monitor size.\n");
}
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width - 1;
if (!panel.area.width) panel.area.width = server.monitor[panel.monitor].width - 1 - panel.marginleft - panel.marginright;
// taskbar
g_taskbar.posy = panel.area.pix.border.width + panel.area.paddingy;
@ -654,8 +654,8 @@ int config_read_file (const char *path)
void save_config ()
{
fprintf(stderr, "tint2 warning : convert user's config file\n");
panel.area.paddingx = panel.area.paddingy = panel.marginx;
panel.marginx = panel.marginy = 0;
panel.area.paddingx = panel.area.paddingy = panel.marginleft;
panel.marginleft = panel.marginright = panel.marginy = 0;
if (panel.old_task_icon == 0) g_task.icon_size1 = 0;
if (panel.old_panel_background == 0) panel.area.pix.back.alpha = 0;
@ -690,7 +690,7 @@ void save_config ()
else if (panel.position & RIGHT) fputs(" right\n", fp);
else fputs(" center\n", fp);
fprintf(fp, "panel_size = %d %d\n", panel.area.width, panel.area.height);
fprintf(fp, "panel_margin = %d %d\n", panel.marginx, panel.marginy);
fprintf(fp, "panel_margin = %d %d\n", panel.marginleft, panel.marginy);
fprintf(fp, "panel_padding = %d %d\n", panel.area.paddingx, panel.area.paddingy);
fprintf(fp, "font_shadow = %d\n", g_task.font_shadow);

View file

@ -115,9 +115,9 @@ void window_draw_panel ()
Window win;
/* panel position determined here */
if (panel.position & LEFT) server.posx = server.monitor[panel.monitor].x + panel.marginx;
if (panel.position & LEFT) server.posx = server.monitor[panel.monitor].x + panel.marginleft;
else {
if (panel.position & RIGHT) server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width - panel.marginx;
if (panel.position & RIGHT) server.posx = server.monitor[panel.monitor].x + server.monitor[panel.monitor].width - panel.area.width - panel.marginright;
else server.posx = server.monitor[panel.monitor].x + ((server.monitor[panel.monitor].width - panel.area.width) / 2);
}
if (panel.position & TOP) server.posy = server.monitor[panel.monitor].y + panel.marginy;
@ -173,6 +173,35 @@ void visible_object()
}
Pixmap get_root_pixmap ()
{
Pixmap ret;
Window root = RootWindow(server.dsp, server.screen);
ret = None;
int act_format, c = 2 ;
u_long nitems ;
u_long bytes_after ;
u_char *prop ;
Atom dummy_id;
do {
if (XGetWindowProperty(server.dsp, root, server.atom._XROOTPMAP_ID, 0, 1,
False, XA_PIXMAP, &dummy_id, &act_format,
&nitems, &bytes_after, &prop) == Success) {
if (prop) {
ret = *((Pixmap *)prop);
XFree(prop);
break;
}
}
} while (--c > 0);
//if (ret == None) printf("pas de background\n");
return ret;
}
void set_panel_background()
{
Pixmap wall = get_root_pixmap();
@ -201,3 +230,4 @@ void set_panel_background()
}

View file

@ -47,7 +47,7 @@ typedef struct {
int refresh;
int monitor;
int position;
int marginx, marginy;
int marginleft, marginright, marginy;
// --------------------------------------------------
// taskbar point to the first taskbar in panel.area.list. number of tasbar == nb_desktop x nb_monitor.

View file

@ -135,71 +135,48 @@ void *server_get_property (Window win, Atom at, Atom type, int *num_results)
}
Pixmap get_root_pixmap ()
int compareMonitor(const void *monitor1, const void *monitor2)
{
Pixmap ret;
Window root = RootWindow(server.dsp, server.screen);
Monitor *m1 = (Monitor*)monitor1;
Monitor *m2 = (Monitor*)monitor2;
ret = None;
int act_format, c = 2 ;
u_long nitems ;
u_long bytes_after ;
u_char *prop ;
Atom dummy_id;
do {
if (XGetWindowProperty(server.dsp, root, server.atom._XROOTPMAP_ID, 0, 1,
False, XA_PIXMAP, &dummy_id, &act_format,
&nitems, &bytes_after, &prop) == Success) {
if (prop) {
ret = *((Pixmap *)prop);
XFree(prop);
break;
}
if (m1->x < m2->x) {
return -1;
}
else
if (m1->x > m2->x) {
return 1;
}
} while (--c > 0);
return ret;
else
if (m1->width < m2->width) {
return 1;
}
else
if (m1->width > m2->width) {
return -1;
}
else {
return 0;
}
}
/*
Pixmap get_root_pixmap ()
{
// conky capture correctement le fond d'écran en xlib !!
Pixmap root_pixmap;
unsigned long *res;
server.root_win = window_get_root();
res = server_get_property (server.root_win, server.atom._XROOTPMAP_ID, XA_PIXMAP, 0);
if (res) {
root_pixmap = *((Drawable*) res);
XFree(res);
return root_pixmap;
}
else {
printf("get_root_pixmap incorrect\n");
// try _XSETROOT_ID
}
return 0;
}
*/
void get_monitors()
{
if (server.monitor) free(server.monitor);
server.nb_monitor = 0;
server.monitor = 0;
int nb_monitor;
if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &server.nb_monitor);
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
if (info) {
int i;
server.monitor = calloc(server.nb_monitor, sizeof(Monitor));
//printf("nb_monitors %d\n", nb_monitor);
server.nb_monitor = nb_monitor;
server.monitor = calloc(nb_monitor, sizeof(Monitor));
for (i = 0; i < server.nb_monitor; i++) {
server.monitor[i].x = info[i].x_org;
server.monitor[i].y = info[i].y_org;
@ -207,6 +184,9 @@ void get_monitors()
server.monitor[i].height = info[i].height;
}
XFree(info);
// ordered monitor according to coordinate
qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitor);
}
}

View file

@ -1,6 +1,6 @@
/**************************************************************************
* server :
* -
* server :
* -
*
* Check COPYING file for Copyright
*
@ -98,7 +98,6 @@ void server_refresh_main_pixmap ();
void server_catch_error (Display *d, XErrorEvent *ev);
void server_init_atoms ();
void get_monitors();
Pixmap get_root_pixmap();
#endif

View file

@ -173,7 +173,7 @@ void get_icon (Task *tsk)
data = server_get_property (tsk->win, server.atom._NET_WM_ICON, XA_CARDINAL, &num);
if (data) {
printf("get_icon plein\n");
//printf("get_icon plein\n");
// ARGB
int w, h;
long *tmp_data;
@ -187,14 +187,13 @@ void get_icon (Task *tsk)
XFree (data);
}
else {
printf("get_icon vide\n");
//XWMHints *hints;
//hints = XGetWMHints(server.dsp, tkwin);
//if (hints != NULL) {
// XFree(hints);
//}
// XChangeProperty (display, windowH, XInternAtom (display, "_NET_WM_ICON", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char*) data, dataSize);
return;
//printf("get_icon vide\n");
XWMHints *hints = XGetWMHints(server.dsp, tsk->win);
if (hints) {
if (hints->flags & IconPixmapHint) {
}
XFree(hints);
}
}
}

BIN
src/tint2

Binary file not shown.

View file

@ -24,9 +24,9 @@ border_color = #ffffff 70
# PANEL
#---------------------------------------------
panel_monitor = 1
panel_position = top center
panel_size = 900 30
panel_margin = 15 2
panel_position = bottom center
panel_size = 0 30
panel_margin = 15 2 15
panel_padding = 9 0
font_shadow = 0
panel_background_id = 1

View file

@ -7,7 +7,7 @@
#---------------------------------------------
rounded = 1
border_width = 0
background_color = #282828 40
background_color = #282828 60
border_color = #000000 0
rounded = 1
@ -34,7 +34,7 @@ panel_background_id = 1
#---------------------------------------------
# TASKBAR
#---------------------------------------------
taskbar_mode = multi_desktop
taskbar_mode = multi_monitor
taskbar_padding = 0 0 0
taskbar_background_id = 2
@ -66,7 +66,7 @@ time1_font = sans 7
time2_format = %A %d %B
time2_font = sans 7
clock_font_color = #ffffff 100
clock_padding = 4 0
clock_padding = 2 0
clock_background_id = 0
#---------------------------------------------

View file

@ -5,69 +5,67 @@
#---------------------------------------------
# BACKGROUND AND BORDER
#---------------------------------------------
rounded = 5
rounded = 10
border_width = 1
background_color = #ffffff 40
border_color = #ffffff 70
border_color = #ffffff 60
rounded = 4
border_width = 0
background_color = #ffffff 0
border_color = #d1d1d1 0
rounded = 4
rounded = 1
border_width = 0
background_color = #ffffff 30
border_color = #d1d1d1 14
border_color = #ffffff 15
#---------------------------------------------
# PANEL
#---------------------------------------------
panel_monitor = 1
panel_position = top center
panel_size = 1000 25
panel_margin = 0 7
panel_padding = 7 3 0
panel_position = bottom center
panel_size = 0 30
panel_margin = 0 0
panel_padding = 5 4
font_shadow = 0
panel_background_id = 1
panel_background_id = 0
#---------------------------------------------
# TASKBAR
#---------------------------------------------
taskbar_mode = single_desktop
taskbar_padding = 0 0 0
taskbar_background_id = 0
taskbar_mode = multi_desktop
taskbar_padding = 8 0 0
taskbar_background_id = 1
#---------------------------------------------
# TASKS
#---------------------------------------------
task_icon = 1
task_text = 1
task_width = 150
task_width = 160
task_centered = 1
task_padding = 2 1
task_font = myriad pro 8
task_font_color = #000000 70
task_font = Dejavu sans 8
task_font_color = #000000 60
task_active_font_color = #000000 100
task_background_id = 2
task_active_background_id = 3
task_background_id = 0
task_active_background_id = 2
#---------------------------------------------
# SYSTRAY
#---------------------------------------------
#systray_padding = 9 3
#systray_background_id = 0
#systray_icon_opacity = 50
#systray_background_id = 1
#---------------------------------------------
# CLOCK
#---------------------------------------------
time1_format = %H:%M
time1_font = sans bold 12
time1_format = %A %d %H:%M
time1_font = Dejavu sans 10
#time2_format = %A %d %B
#time2_font = sans bold 10
clock_font_color = #000000 70
clock_padding = 4 0
clock_background_id = 0
time2_font = sans 7
clock_font_color = #000000 80
clock_padding = 8 0
clock_background_id = 1
#---------------------------------------------
# MOUSE ACTION ON TASK

View file

@ -25,7 +25,7 @@ border_color = #ffffff 0
# PANEL
#---------------------------------------------
panel_monitor = 1
panel_position = top left
panel_position = bottom left
panel_size = 0 30
panel_margin = 0 0
panel_padding = 9 2 7