]>
Dogcows Code - chaz/tint2/blob - src/taskbar/taskbar.c
1 /**************************************************************************
5 * Copyright (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 **************************************************************************/
21 #include <X11/Xutil.h>
22 #include <X11/Xatom.h>
36 Task
*task_get_task (Window win
)
42 for (l0
= panel
.area
.list
; l0
; l0
= l0
->next
) {
45 for (l1
= tskbar
->area
.list
; l1
; l1
= l1
->next
) {
47 if (win
== tsk
->win
) return tsk
;
51 // nb = panel.nb_desktop * panel.nb_monitor;
52 //printf("task_get_task return 0\n");
57 void task_refresh_tasklist ()
59 Window
*win
, active_win
;
60 int num_results
, i
, j
;
62 win
= server_get_property (server
.root_win
, server
.atom
._NET_CLIENT_LIST
, XA_WINDOW
, &num_results
);
66 /* Remove any old and set active win */
67 active_win
= window_get_active ();
72 for (l0
= panel
.area
.list
; l0
; l0
= l0
->next
) {
75 for (l1
= tskbar
->area
.list
; l1
; l1
= l1
->next
) {
78 if (tsk
->win
== active_win
) panel
.task_active
= tsk
;
80 for (j
= 0; j
< num_results
; j
++) {
81 if (tsk
->win
== win
[j
]) break;
83 if (tsk
->win
!= win
[j
]) remove_task (tsk
);
88 for (i
= 0; i
< num_results
; i
++) {
89 if (!task_get_task (win
[i
])) add_task (win
[i
]);
96 int resize_tasks (Taskbar
*taskbar
)
98 int ret
, task_count
, pixel_width
, modulo_width
=0;
103 // new task width for 'desktop'
104 task_count
= g_slist_length(taskbar
->area
.list
);
105 if (!task_count
) pixel_width
= g_task
.maximum_width
;
107 taskbar_width
= taskbar
->area
.width
- (2 * g_taskbar
.border
.width
) - ((task_count
+1) * g_taskbar
.paddingx
);
109 pixel_width
= taskbar_width
/ task_count
;
110 if (pixel_width
> g_task
.maximum_width
) pixel_width
= g_task
.maximum_width
;
111 else modulo_width
= taskbar_width
% task_count
;
114 if ((taskbar
->task_width
== pixel_width
) && (taskbar
->task_modulo
== modulo_width
)) {
119 taskbar
->task_width
= pixel_width
;
120 taskbar
->task_modulo
= modulo_width
;
121 taskbar
->text_width
= pixel_width
- g_task
.text_posx
- g_task
.area
.border
.width
- g_task
.area
.paddingx
;
124 // change pos_x and width for all tasks
125 x
= taskbar
->area
.posx
+ taskbar
->area
.border
.width
+ taskbar
->area
.paddingx
;
126 for (l
= taskbar
->area
.list
; l
; l
= l
->next
) {
129 tsk
->area_active
.posx
= x
;
130 tsk
->area
.width
= pixel_width
;
131 tsk
->area_active
.width
= pixel_width
;
134 tsk
->area_active
.width
++;
138 x
+= tsk
->area
.width
+ g_taskbar
.paddingx
;
This page took 0.039964 seconds and 4 git commands to generate.