issue 135 and xrandr management (more to come)

git-svn-id: http://tint2.googlecode.com/svn/trunk@202 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2009-09-27 16:57:19 +00:00
parent e015d5b19c
commit 145ce16757
7 changed files with 138 additions and 103 deletions

View file

@ -79,7 +79,8 @@ void init_config()
cleanup_panel();
// get monitor and desktop config
get_monitors_and_desktops();
get_monitors();
get_desktops();
// append full transparency background
list_back = g_slist_append(0, calloc(1, sizeof(Area)));
@ -90,7 +91,7 @@ void init_config()
systray.sort = 1;
// window manager's menu default value == false
wm_menu = 0;
wm_menu = wm_menu_open = 0;
max_tick_urgent = 7;
}
@ -742,7 +743,7 @@ int parse_line (const char *line)
void config_finish ()
{
if (panel_config->monitor > (server.nb_monitor-1)) {
// server.nb_monitor minimum value is 1 (see get_monitors_and_desktops())
// server.nb_monitor minimum value is 1 (see get_monitors())
// and panel_config->monitor is higher
fprintf(stderr, "warning : monitor not found. tint2 default to monitor 1.\n");
panel_config->monitor = 0;

View file

@ -43,7 +43,7 @@ int mouse_tilt_left;
int mouse_tilt_right;
int panel_mode;
int wm_menu;
int wm_menu, wm_menu_open;
int panel_dock=0; // default not in the dock
int panel_position;
int panel_horizontal;
@ -106,59 +106,7 @@ void init_panel()
p->pourcentx = 1;
}
// detect panel size
if (panel_horizontal) {
if (p->pourcentx)
p->area.width = (float)server.monitor[p->monitor].width * p->initial_width / 100;
else
p->area.width = p->initial_width;
if (p->pourcenty)
p->area.height = (float)server.monitor[p->monitor].height * p->initial_height / 100;
else
p->area.height = p->initial_height;
if (p->area.pix.border.rounded > p->area.height/2)
p->area.pix.border.rounded = p->area.height/2;
}
else {
if (p->pourcentx)
p->area.height = (float)server.monitor[p->monitor].height * p->initial_width / 100;
else
p->area.height = p->initial_width;
if (p->pourcenty)
p->area.width = (float)server.monitor[p->monitor].width * p->initial_height / 100;
else
p->area.width = p->initial_height;
if (p->area.pix.border.rounded > p->area.width/2)
p->area.pix.border.rounded = p->area.width/2;
}
/* panel position determined here */
if (panel_position & LEFT) {
p->posx = server.monitor[p->monitor].x + p->marginx;
}
else {
if (panel_position & RIGHT) {
p->posx = server.monitor[p->monitor].x + server.monitor[p->monitor].width - p->area.width - p->marginx;
}
else {
if (panel_horizontal)
p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2);
else
p->posx = server.monitor[p->monitor].x + p->marginx;
}
}
if (panel_position & TOP) {
p->posy = server.monitor[p->monitor].y + p->marginy;
}
else {
if (panel_position & BOTTOM) {
p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy;
}
else {
p->posy = server.monitor[p->monitor].y + ((server.monitor[p->monitor].height - p->area.height) / 2);
}
}
// printf("panel : posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height);
init_panel_size_and_position(p);
// Catch some events
long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;
@ -177,6 +125,64 @@ void init_panel()
}
void init_panel_size_and_position(Panel *panel)
{
// detect panel size
if (panel_horizontal) {
if (panel->pourcentx)
panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_width / 100;
else
panel->area.width = panel->initial_width;
if (panel->pourcenty)
panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_height / 100;
else
panel->area.height = panel->initial_height;
if (panel->area.pix.border.rounded > panel->area.height/2)
panel->area.pix.border.rounded = panel->area.height/2;
}
else {
if (panel->pourcentx)
panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_width / 100;
else
panel->area.height = panel->initial_width;
if (panel->pourcenty)
panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_height / 100;
else
panel->area.width = panel->initial_height;
if (panel->area.pix.border.rounded > panel->area.width/2)
panel->area.pix.border.rounded = panel->area.width/2;
}
// panel position determined here
if (panel_position & LEFT) {
panel->posx = server.monitor[panel->monitor].x + panel->marginx;
}
else {
if (panel_position & RIGHT) {
panel->posx = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width - panel->area.width - panel->marginx;
}
else {
if (panel_horizontal)
panel->posx = server.monitor[panel->monitor].x + ((server.monitor[panel->monitor].width - panel->area.width) / 2);
else
panel->posx = server.monitor[panel->monitor].x + panel->marginx;
}
}
if (panel_position & TOP) {
panel->posy = server.monitor[panel->monitor].y + panel->marginy;
}
else {
if (panel_position & BOTTOM) {
panel->posy = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height - panel->area.height - panel->marginy;
}
else {
panel->posy = server.monitor[panel->monitor].y + ((server.monitor[panel->monitor].height - panel->area.height) / 2);
}
}
// printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height);
}
void cleanup_panel()
{
if (!panel1) return;

View file

@ -38,7 +38,7 @@ extern int mouse_tilt_right;
//panel mode
enum { SINGLE_DESKTOP=0, MULTI_DESKTOP };
extern int panel_mode;
extern int wm_menu;
extern int wm_menu, wm_menu_open;
extern int panel_dock;
//panel position
@ -106,6 +106,7 @@ extern int nb_panel;
void init_panel();
void init_panel_size_and_position(Panel *panel);
void cleanup_panel();
void resize_panel(void *obj);

View file

@ -219,15 +219,13 @@ int compareMonitor(const void *monitor1, const void *monitor2)
}
void get_monitors_and_desktops()
void get_monitors()
{
int i;
if (server.monitor) free(server.monitor);
server.nb_monitor = 0;
server.monitor = 0;
int nb_monitor;
int i, nb_monitor;
if (XineramaIsActive(server.dsp)) {
XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);
@ -274,6 +272,12 @@ next:
server.monitor[0].width = DisplayWidth (server.dsp, server.screen);
server.monitor[0].height = DisplayHeight (server.dsp, server.screen);
}
}
void get_desktops()
{
int i;
// detect number of desktops
// wait 15s to leave some time for window manager startup

View file

@ -115,7 +115,8 @@ void server_init_atoms ();
void get_root_pixmap();
// detect monitors and desktops
void get_monitors_and_desktops();
void get_monitors();
void get_desktops();
#endif

View file

@ -270,6 +270,7 @@ void event_button_press (XEvent *e)
if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) {
// forward the click to the desktop window (thanks conky)
wm_menu_open = 1;
XUngrabPointer(server.dsp, e->xbutton.time);
e->xbutton.window = server.root_win;
// icewm doesn't open under the mouse.
@ -291,11 +292,12 @@ void event_button_release (XEvent *e)
Panel *panel = get_panel(e->xany.window);
if (!panel) return;
if (wm_menu && click_padding(panel, e->xbutton.x, e->xbutton.y)) {
// forward the click to the desktop window (thanks conky)
e->xbutton.window = server.root_win;
XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e);
return;
if (wm_menu && wm_menu_open) {
// forward the click to the desktop window (thanks conky)
wm_menu_open = 0;
e->xbutton.window = server.root_win;
XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e);
return;
}
int action = TOGGLE_ICONIFY;
@ -613,43 +615,60 @@ void event_expose (XEvent *e)
void event_configure_notify (Window win)
{
// change in root window (xrandr)
if (win == server.root_win) {
printf("ConfigureNotify on root\n");
//XMoveWindow(dpy, fen, pos_x, pos_y);
//XResizeWindow(dpy, fen, largeur, hauteur);
int i, old_monitor = server.nb_monitor;
get_monitors();
if (old_monitor != server.nb_monitor) {
}
for (i=0 ; i < nb_panel ; i++) {
Panel *panel = &panel1[i];
init_panel_size_and_position(panel);
XMoveResizeWindow(server.dsp, panel->main_win, panel->posx, panel->posy, panel->area.width, panel->area.height);
set_panel_background(panel);
// force the resize of childs
GSList *l0;
panel->area.resize = 1;
for (l0 = panel->area.list; l0 ; l0 = l0->next)
((Area*)l0->data)->resize = 1;
}
panel_refresh = 1;
//printf("ConfigureNotify on root width=%d, height=%d\n", server.monitor[0].width, server.monitor[0].height);
return;
}
else {
// check 'win' move in systray
TrayWindow *traywin;
GSList *l;
for (l = systray.list_icons; l ; l = l->next) {
traywin = (TrayWindow*)l->data;
if (traywin->id == win) {
//printf("move tray %d\n", traywin->x);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
panel_refresh = 1;
return;
}
}
// check 'win' move in another monitor
if (nb_panel == 1) return;
if (server.nb_monitor == 1) return;
Task *tsk = task_get_task (win);
if (!tsk) return;
Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) {
remove_task (tsk);
add_task (win);
if (win == window_get_active ()) {
Task *tsk = task_get_task (win);
tsk->area.is_active = 1;
task_active = tsk;
}
// 'win' is a trayer icon
TrayWindow *traywin;
GSList *l;
for (l = systray.list_icons; l ; l = l->next) {
traywin = (TrayWindow*)l->data;
if (traywin->id == win) {
//printf("move tray %d\n", traywin->x);
XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height);
panel_refresh = 1;
return;
}
}
// 'win' move in another monitor
if (nb_panel == 1) return;
Task *tsk = task_get_task (win);
if (!tsk) return;
Panel *p = tsk->area.panel;
if (p->monitor != window_get_monitor (win)) {
remove_task (tsk);
add_task (win);
if (win == window_get_active ()) {
Task *tsk = task_get_task (win);
tsk->area.is_active = 1;
task_active = tsk;
}
panel_refresh = 1;
}
}

View file

@ -72,13 +72,16 @@ void size (Area *a)
if (a->resize) {
a->resize = 0;
for (l = a->list; l ; l = l->next)
size(l->data);
// force the resize of childs
for (l = a->list; l ; l = l->next) {
Area *area = (Area*)l->data;
area->resize = 1;
size(area);
}
// resize can generate a redraw
if (a->_resize) {
if (a->_resize)
a->_resize(a);
}
}
}