Esempio n. 1
0
File: panel.c Progetto: o9000/tint2
void cleanup_panel()
{
	if (!panels)
		return;

	cleanup_taskbar();

	for (int i = 0; i < num_panels; i++) {
		Panel *p = &panels[i];

		free_area(&p->area);
		if (p->temp_pmap)
			XFreePixmap(server.display, p->temp_pmap);
		p->temp_pmap = 0;
		if (p->hidden_pixmap)
			XFreePixmap(server.display, p->hidden_pixmap);
		p->hidden_pixmap = 0;
		if (p->main_win)
			XDestroyWindow(server.display, p->main_win);
		p->main_win = 0;
		stop_timeout(p->autohide_timeout);
		cleanup_freespace(p);
	}

	free(panel_items_order);
	panel_items_order = NULL;
	free(panel_window_name);
	panel_window_name = NULL;
	free(panels);
	panels = NULL;

	free_area(&panel_config.area);

	if (backgrounds)
		g_array_free(backgrounds, TRUE);
	backgrounds = NULL;
	if (gradients) {
		for (guint i = 0; i < gradients->len; i++)
			cleanup_gradient(&g_array_index(gradients, GradientClass, i));
		g_array_free(gradients, TRUE);
	}
	gradients = NULL;
	pango_font_description_free(panel_config.g_task.font_desc);
	panel_config.g_task.font_desc = NULL;
	pango_font_description_free(panel_config.taskbarname_font_desc);
	panel_config.taskbarname_font_desc = NULL;
}
Esempio n. 2
0
File: panel.c Progetto: asqz/tint2
void cleanup_panel()
{
	if (!panel1) return;

	cleanup_taskbar();

	int i;
	Panel *p;
	for (i=0 ; i < nb_panel ; i++) {
		p = &panel1[i];

		free_area(&p->area);
		if (p->temp_pmap) XFreePixmap(server.dsp, p->temp_pmap);
		if (p->hidden_pixmap) XFreePixmap(server.dsp, p->hidden_pixmap);
		if (p->main_win) XDestroyWindow(server.dsp, p->main_win);
	}

	if (panel1) free(panel1);
	if (backgrounds)
		g_array_free(backgrounds, 1);
	if (panel_config.g_task.font_desc) pango_font_description_free(panel_config.g_task.font_desc);
}
Esempio n. 3
0
void cleanup_panel()
{
	if (!panel1)
		return;

	cleanup_taskbar();

	int i;
	Panel *p;
	for (i = 0; i < nb_panel; i++) {
		p = &panel1[i];

		free_area(&p->area);
		if (p->temp_pmap)
			XFreePixmap(server.dsp, p->temp_pmap);
		p->temp_pmap = 0;
		if (p->hidden_pixmap)
			XFreePixmap(server.dsp, p->hidden_pixmap);
		p->hidden_pixmap = 0;
		if (p->main_win)
			XDestroyWindow(server.dsp, p->main_win);
		p->main_win = 0;
		stop_timeout(p->autohide_timeout);
	}

	free(panel_items_order);
	panel_items_order = NULL;
	free(panel_window_name);
	panel_window_name = NULL;
	free(panel1);
	panel1 = NULL;
	if (backgrounds)
		g_array_free(backgrounds, 1);
	backgrounds = NULL;
	pango_font_description_free(panel_config.g_task.font_desc);
	panel_config.g_task.font_desc = NULL;
}
Esempio n. 4
0
void event_property_notify(XEvent* e) {
    int i;
    Task* tsk;
    Window win = e->xproperty.window;
    Atom at = e->xproperty.atom;

    if (xsettings_client) xsettings_client_process_event(xsettings_client, e);
    if (win == server.root_win) {
        if (!server.got_root_win) {
            XSelectInput(server.dsp, server.root_win,
                         PropertyChangeMask | StructureNotifyMask);
            server.got_root_win = 1;
        }

        // Change name of desktops
        else if (at == server.atom._NET_DESKTOP_NAMES) {
            if (!taskbarname_enabled) return;
            GSList* l, *list = server_get_name_of_desktop();
            gchar* name;
            Taskbar* tskbar;
            for (i = 0; i < nb_panel; i++) {
                l = list;
                for (uint8_t j = 0; j < panel1[i].desktop_count; j++) {
                    if (l) {
                        name = g_strdup(l->data);
                        l = l->next;
                    } else
                        name = g_strdup_printf("%d", j + 1);
                    tskbar = &panel1[i].taskbar[j];
                    if (strcmp(name, tskbar->bar_name.name) != 0) {
                        g_free(tskbar->bar_name.name);
                        tskbar->bar_name.name = name;
                        tskbar->bar_name.area.resize = 1;
                    } else
                        g_free(name);
                }
            }
            for (l = list; l; l = l->next) g_free(l->data);
            g_slist_free(list);
            panel_refresh = 1;
        }
        // Change number of desktops
        else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
            if (!taskbar_enabled) return;
            server.nb_desktop = server_get_number_of_desktop();
            if (server.nb_desktop <= server.desktop) {
                server.desktop = server.nb_desktop - 1;
            }
            cleanup_taskbar();
            init_taskbar();
            for (i = 0; i < nb_panel; i++) {
                init_taskbar_panel(&panel1[i]);
                set_panel_items_order(&panel1[i]);
                visible_taskbar(&panel1[i]);
                panel1[i].area.resize = 1;
            }
            task_refresh_tasklist();
            active_task();
            panel_refresh = 1;
        }
        // Change desktop
        else if (at == server.atom._NET_CURRENT_DESKTOP) {
            if (!taskbar_enabled) return;
            int old_desktop = server.desktop;
            server.desktop = server_get_current_desktop();
            for (i = 0; i < nb_panel; i++) {
                Panel* panel = &panel1[i];
                set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL);
                set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE);
                // check ALLDESKTOP task => resize taskbar
                Taskbar* tskbar;
                Task* tsk;
                GSList* l;
                if (server.nb_desktop > old_desktop) {
                    tskbar = &panel->taskbar[old_desktop];
                    l = tskbar->area.list;
                    if (taskbarname_enabled) l = l->next;
                    for (; l; l = l->next) {
                        tsk = l->data;
                        if (tsk->desktop == ALLDESKTOP) {
                            tsk->area.on_screen = 0;
                            tskbar->area.resize = 1;
                            panel_refresh = 1;
                        }
                    }
                }
                tskbar = &panel->taskbar[server.desktop];
                l = tskbar->area.list;
                if (taskbarname_enabled) l = l->next;
                for (; l; l = l->next) {
                    tsk = l->data;
                    if (tsk->desktop == ALLDESKTOP) {
                        tsk->area.on_screen = 1;
                        tskbar->area.resize = 1;
                    }
                }
            }
        }
        // Window list
        else if (at == server.atom._NET_CLIENT_LIST) {
            task_refresh_tasklist();
            panel_refresh = 1;
        }
        // Change active
        else if (at == server.atom._NET_ACTIVE_WINDOW) {
            active_task();
            panel_refresh = 1;
        } else if (at == server.atom._XROOTPMAP_ID ||
                   at == server.atom._XROOTMAP_ID) {
            // change Wallpaper
            for (i = 0; i < nb_panel; i++) {
                set_panel_background(&panel1[i]);
            }
            panel_refresh = 1;
        }
    } else {
        tsk = task_get_task(win);
        if (!tsk) {
            if (at != server.atom._NET_WM_STATE)
                return;
            else {
                // 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;
                XGetWindowAttributes(server.dsp, win, &wa);
                if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) {
                    if ((tsk = add_task(win)))
                        panel_refresh = 1;
                    else
                        return;
                } else
                    return;
            }
        }

        // Window title changed
        if (at == server.atom._NET_WM_VISIBLE_NAME ||
                at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
            if (get_title(tsk)) {
                if (g_tooltip.mapped && (g_tooltip.area == (Area*)tsk)) {
                    tooltip_copy_text((Area*)tsk);
                    tooltip_update();
                }
                panel_refresh = 1;
            }
        }
        // Demand attention
        else if (at == server.atom._NET_WM_STATE) {
            if (window_is_urgent(win)) {
                add_urgent(tsk);
            }
            if (window_is_skip_taskbar(win)) {
                remove_task(tsk);
                panel_refresh = 1;
            }
        } else if (at == server.atom.WM_STATE) {
            // Iconic state
            int state = (task_active && tsk->win == task_active->win ? TASK_ACTIVE
                         : TASK_NORMAL);
            if (window_is_iconified(win)) state = TASK_ICONIFIED;
            set_task_state(tsk, state);
            panel_refresh = 1;
        }
        // Window icon changed
        else if (at == server.atom._NET_WM_ICON) {
            get_icon(tsk);
            panel_refresh = 1;
        }
        // Window desktop changed
        else if (at == server.atom._NET_WM_DESKTOP) {
            uint32_t desktop = window_get_desktop(win);
            // bug in windowmaker : send unecessary 'desktop changed' when focus
            // changed
            if (desktop != tsk->desktop) {
                remove_task(tsk);
                tsk = add_task(win);
                active_task();
                panel_refresh = 1;
            }
        } else if (at == server.atom.WM_HINTS) {
            XWMHints* wmhints = XGetWMHints(server.dsp, win);
            if (wmhints && wmhints->flags & XUrgencyHint) {
                add_urgent(tsk);
            }
            XFree(wmhints);
        }

        if (!server.got_root_win)
            server.root_win = RootWindow(server.dsp, server.screen);
    }
}