Fix missing redraw

This commit is contained in:
o9000 2015-11-22 16:33:58 +01:00
parent 29b3c590cd
commit 333ed7a207
4 changed files with 52 additions and 13 deletions

View file

@ -48,8 +48,10 @@ Task *add_task(Window win)
{
if (!win)
return NULL;
if (window_is_hidden(win))
if (window_is_hidden(win)) {
// fprintf(stderr, "%s %d: win = %ld not adding task: window hidden\n", __FUNCTION__, __LINE__, win);
return NULL;
}
XSelectInput(server.dsp, win, PropertyChangeMask | StructureNotifyMask);
XFlush(server.dsp);
@ -83,7 +85,8 @@ Task *add_task(Window win)
get_title(&task_template);
get_icon(&task_template);
// printf("new task %s win %u: desktop %d, monitor %d\n", new_task.title, win, new_task.desktop, monitor);
// fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, win, task_template.title ? task_template.title : "??");
// fprintf(stderr, "new task %s win %u: desktop %d, monitor %d\n", new_task.title, win, new_task.desktop, monitor);
GPtrArray *task_group = g_ptr_array_new();
for (int j = 0; j < panels[monitor].num_desktops; j++) {
@ -103,7 +106,7 @@ Task *add_task(Window win)
task_instance->win_h = task_template.win_h;
task_instance->current_state = -1; // to update the current state later in set_task_state...
if (task_instance->desktop == ALL_DESKTOPS && server.desktop != j) {
// hide ALL_DESKTOPS task on non-current desktop
// fprintf(stderr, "%s %d: win = %ld hiding task: another desktop\n", __FUNCTION__, __LINE__, win);
task_instance->area.on_screen = FALSE;
}
task_instance->title = task_template.title;
@ -120,7 +123,6 @@ Task *add_task(Window win)
add_area(&task_instance->area, &taskbar->area);
g_ptr_array_add(task_group, task_instance);
// printf("add_task panel %d, desktop %d, task %s\n", i, j, task_instance->title);
}
Window *key = calloc(1, sizeof(Window));
*key = task_template.win;
@ -147,6 +149,8 @@ void remove_task(Task *task)
if (!task)
return;
// fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, task->win, task->title ? task->title : "??");
if (taskbar_mode == MULTI_DESKTOP) {
Panel *panel = task->area.panel;
panel->area.resize_needed = 1;

View file

@ -308,6 +308,7 @@ void task_refresh_tasklist()
{
if (!taskbar_enabled)
return;
// fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__);
int num_results;
Window *win = server_get_property(server.root_win, server.atom._NET_CLIENT_LIST, XA_WINDOW, &num_results);

View file

@ -719,6 +719,7 @@ void update_desktop_names()
void update_task_desktop(Task *task)
{
// fprintf(stderr, "%s %d:\n", __FUNCTION__, __LINE__);
Window win = task->win;
remove_task(task);
task = add_task(win);
@ -728,6 +729,8 @@ void update_task_desktop(Task *task)
void event_property_notify(XEvent *e)
{
gboolean debug = FALSE;
int i;
Window win = e->xproperty.window;
Atom at = e->xproperty.atom;
@ -742,6 +745,8 @@ void event_property_notify(XEvent *e)
// Change name of desktops
else if (at == server.atom._NET_DESKTOP_NAMES) {
if (debug)
fprintf(stderr, "%s %d: win = root, atom = _NET_DESKTOP_NAMES\n", __FUNCTION__, __LINE__);
update_desktop_names();
}
// Change desktops
@ -750,6 +755,8 @@ void event_property_notify(XEvent *e)
at == server.atom._NET_DESKTOP_VIEWPORT ||
at == server.atom._NET_WORKAREA ||
at == server.atom._NET_CURRENT_DESKTOP) {
if (debug)
fprintf(stderr, "%s %d: win = root, atom = ?? desktops changed\n", __FUNCTION__, __LINE__);
if (!taskbar_enabled)
return;
int old_num_desktops = server.num_desktops;
@ -835,14 +842,20 @@ void event_property_notify(XEvent *e)
}
// Window list
else if (at == server.atom._NET_CLIENT_LIST) {
if (debug)
fprintf(stderr, "%s %d: win = root, atom = _NET_CLIENT_LIST\n", __FUNCTION__, __LINE__);
task_refresh_tasklist();
panel_refresh = TRUE;
}
// Change active
else if (at == server.atom._NET_ACTIVE_WINDOW) {
if (debug)
fprintf(stderr, "%s %d: win = root, atom = _NET_ACTIVE_WINDOW\n", __FUNCTION__, __LINE__);
reset_active_task();
panel_refresh = TRUE;
} else if (at == server.atom._XROOTPMAP_ID || at == server.atom._XROOTMAP_ID) {
if (debug)
fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__);
// change Wallpaper
for (i = 0; i < num_panels; i++) {
set_panel_background(&panels[i]);
@ -851,11 +864,15 @@ void event_property_notify(XEvent *e)
}
} else {
Task *task = task_get_task(win);
// printf("change win = %u, task = %p\n", win, task);
if (debug) {
char *atom_name = XGetAtomName(server.dsp, at);
fprintf(stderr, "%s %d: win = %ld, task = %s, atom = %s\n", __FUNCTION__, __LINE__, win, task ? (task->title ? task->title : "??") : "null", atom_name);
XFree(atom_name);
}
if (!task) {
if (at != server.atom._NET_WM_STATE)
return;
else {
if (debug)
fprintf(stderr, "%s %d\n", __FUNCTION__, __LINE__);
if (at == server.atom._NET_WM_STATE) {
// xfce4 sends _NET_WM_STATE after minimized to tray, so we need to check if window is mapped
// if it is mapped and not set as skip_taskbar, we must add it to our task list
XWindowAttributes wa;
@ -863,11 +880,9 @@ void event_property_notify(XEvent *e)
if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) {
if ((task = add_task(win)))
panel_refresh = TRUE;
else
return;
} else
return;
}
}
return;
}
// printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), task->title);
@ -885,6 +900,16 @@ void event_property_notify(XEvent *e)
}
// Demand attention
else if (at == server.atom._NET_WM_STATE) {
if (debug) {
int count;
Atom *atom_state = server_get_property(win, server.atom._NET_WM_STATE, XA_ATOM, &count);
for (int j = 0; j < count; j++) {
char *atom_state_name = XGetAtomName(server.dsp, atom_state[j]);
fprintf(stderr, "%s %d: _NET_WM_STATE = %s\n", __FUNCTION__, __LINE__, atom_state_name);
XFree(atom_state_name);
}
XFree(atom_state);
}
if (window_is_urgent(win)) {
add_urgent(task);
}
@ -940,6 +965,11 @@ void event_configure_notify(XEvent *e)
{
Window win = e->xconfigure.window;
if (0) {
Task *task = task_get_task(win);
fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, win, task ? (task->title ? task->title : "??") : "null");
}
// change in root window (xrandr)
if (win == server.root_win) {
signal_pending = SIGUSR1;

View file

@ -328,6 +328,7 @@ void schedule_redraw(Area *a)
for (GList *l = a->children; l; l = l->next)
schedule_redraw((Area *)l->data);
panel_refresh = TRUE;
}
void hide(Area *a)
@ -447,7 +448,8 @@ void remove_area(Area *a)
if (parent) {
parent->children = g_list_remove(parent->children, area);
parent->resize_needed = 1;
parent->resize_needed = TRUE;
panel_refresh = TRUE;
schedule_redraw(parent);
}
@ -463,7 +465,9 @@ void add_area(Area *a, Area *parent)
a->parent = parent;
if (parent) {
parent->children = g_list_append(parent->children, a);
parent->resize_needed = TRUE;
schedule_redraw(parent);
panel_refresh = TRUE;
}
}