2008-10-02 18:47:02 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Tint2 panel
|
2009-01-17 14:07:56 +00:00
|
|
|
*
|
2008-10-02 18:47:02 +00:00
|
|
|
* Copyright (C) 2007 Pål Staurland (staura@gmail.com)
|
|
|
|
* Modified (C) 2008 thierry lorthiois (lorthiois@bbsoft.fr)
|
2009-01-17 14:07:56 +00:00
|
|
|
*
|
2008-10-02 18:47:02 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-11-15 16:55:50 +00:00
|
|
|
#include <stdint.h>
|
2008-10-02 18:47:02 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xlocale.h>
|
|
|
|
#include <Imlib2.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include "server.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "taskbar.h"
|
2009-02-10 23:16:10 +00:00
|
|
|
#include "systraybar.h"
|
2008-10-02 18:47:02 +00:00
|
|
|
#include "panel.h"
|
2009-09-14 21:28:17 +00:00
|
|
|
#include "tooltip.h"
|
2009-11-15 16:55:50 +00:00
|
|
|
#include "timer.h"
|
2008-10-02 18:47:02 +00:00
|
|
|
|
|
|
|
void signal_handler(int sig)
|
|
|
|
{
|
|
|
|
// signal handler is light as it should be
|
2009-02-07 23:28:13 +00:00
|
|
|
signal_pending = sig;
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-29 16:19:01 +00:00
|
|
|
void init (int argc, char *argv[])
|
2008-10-02 18:47:02 +00:00
|
|
|
{
|
2009-11-10 21:11:31 +00:00
|
|
|
int i;
|
2009-08-29 16:19:01 +00:00
|
|
|
|
|
|
|
// read options
|
2009-11-10 21:11:31 +00:00
|
|
|
for (i = 1; i < argc; ++i) {
|
|
|
|
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
|
|
|
|
printf("Usage: tint2 [-c] <config_file>\n");
|
2009-09-08 21:29:32 +00:00
|
|
|
exit(0);
|
2009-11-10 21:11:31 +00:00
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
|
|
|
|
printf("tint2 version 0.7.svn\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-c")) {
|
|
|
|
i++;
|
|
|
|
if (i < argc)
|
|
|
|
config_path = strdup(argv[i]);
|
|
|
|
}
|
|
|
|
if (!strcmp(argv[i], "-s")) {
|
|
|
|
i++;
|
|
|
|
if (i < argc)
|
|
|
|
snapshot_path = strdup(argv[i]);
|
2009-09-08 21:29:32 +00:00
|
|
|
}
|
2009-08-29 16:19:01 +00:00
|
|
|
}
|
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
// Set signal handler
|
2009-11-15 16:55:50 +00:00
|
|
|
struct sigaction sa = { .sa_handler = signal_handler };
|
|
|
|
sigaction(SIGUSR1, &sa, 0);
|
|
|
|
sigaction(SIGINT, &sa, 0);
|
|
|
|
sigaction(SIGTERM, &sa, 0);
|
|
|
|
sigaction(SIGHUP, &sa, 0);
|
2009-08-09 15:57:18 +00:00
|
|
|
signal(SIGCHLD, SIG_IGN); // don't have to wait() after fork()
|
2009-11-15 16:55:50 +00:00
|
|
|
// block all signals, such that no race conditions occur before pselect in our main loop
|
|
|
|
sigset_t block_mask;
|
|
|
|
sigaddset(&block_mask, SIGINT);
|
|
|
|
sigaddset(&block_mask, SIGTERM);
|
|
|
|
sigaddset(&block_mask, SIGHUP);
|
|
|
|
sigaddset(&block_mask, SIGUSR1);
|
|
|
|
sigprocmask(SIG_BLOCK, &block_mask, 0);
|
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// set global data
|
|
|
|
memset(&server, 0, sizeof(Server_global));
|
|
|
|
memset(&systray, 0, sizeof(Systraybar));
|
|
|
|
|
|
|
|
server.dsp = XOpenDisplay (NULL);
|
|
|
|
if (!server.dsp) {
|
|
|
|
fprintf(stderr, "tint2 exit : could not open display.\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
server_init_atoms ();
|
|
|
|
server.screen = DefaultScreen (server.dsp);
|
2008-10-30 15:39:24 +00:00
|
|
|
server.root_win = RootWindow(server.dsp, server.screen);
|
2009-09-07 21:41:21 +00:00
|
|
|
server.depth = DefaultDepth (server.dsp, server.screen);
|
|
|
|
server.visual = DefaultVisual (server.dsp, server.screen);
|
|
|
|
server.desktop = server_get_current_desktop ();
|
2009-02-03 20:40:46 +00:00
|
|
|
XGCValues gcv;
|
2009-11-10 21:11:31 +00:00
|
|
|
server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
XSetErrorHandler ((XErrorHandler) server_catch_error);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
imlib_context_set_display (server.dsp);
|
|
|
|
imlib_context_set_visual (server.visual);
|
|
|
|
imlib_context_set_colormap (DefaultColormap (server.dsp, server.screen));
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
/* Catch events */
|
|
|
|
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
setlocale (LC_ALL, "");
|
2009-10-17 19:52:44 +00:00
|
|
|
|
|
|
|
// load default icon
|
2009-11-15 16:55:50 +00:00
|
|
|
gchar *path;
|
2009-10-17 19:52:44 +00:00
|
|
|
const gchar * const *data_dirs;
|
|
|
|
data_dirs = g_get_system_data_dirs ();
|
|
|
|
for (i = 0; data_dirs[i] != NULL; i++) {
|
|
|
|
path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
|
|
|
|
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
|
|
|
default_icon = imlib_load_image(path);
|
|
|
|
g_free(path);
|
|
|
|
}
|
2009-10-23 20:23:11 +00:00
|
|
|
|
|
|
|
// get monitor and desktop config
|
|
|
|
get_monitors();
|
|
|
|
get_desktops();
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-07 23:28:13 +00:00
|
|
|
void cleanup()
|
|
|
|
{
|
2009-10-17 19:52:44 +00:00
|
|
|
cleanup_systray();
|
2009-10-30 17:18:44 +00:00
|
|
|
stop_net();
|
2009-03-01 19:18:35 +00:00
|
|
|
cleanup_panel();
|
2009-10-30 17:18:44 +00:00
|
|
|
cleanup_tooltip();
|
|
|
|
cleanup_clock();
|
|
|
|
#ifdef ENABLE_BATTERY
|
|
|
|
cleanup_battery();
|
|
|
|
#endif
|
2009-02-07 23:28:13 +00:00
|
|
|
|
2009-10-17 19:52:44 +00:00
|
|
|
if (default_icon) {
|
|
|
|
imlib_context_set_image(default_icon);
|
|
|
|
imlib_free_image();
|
|
|
|
}
|
2009-08-29 16:19:01 +00:00
|
|
|
if (config_path) g_free(config_path);
|
2009-11-10 21:11:31 +00:00
|
|
|
if (snapshot_path) g_free(snapshot_path);
|
2009-02-07 23:28:13 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
if (server.monitor) free(server.monitor);
|
|
|
|
XFreeGC(server.dsp, server.gc);
|
|
|
|
XCloseDisplay(server.dsp);
|
2009-02-07 23:28:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-10 21:11:31 +00:00
|
|
|
void get_snapshot(const char *path)
|
|
|
|
{
|
|
|
|
Panel *panel = &panel1[0];
|
|
|
|
|
|
|
|
if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
|
|
|
|
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
|
|
|
|
|
|
|
|
refresh(&panel->area);
|
|
|
|
|
|
|
|
Imlib_Image img = NULL;
|
|
|
|
imlib_context_set_drawable(panel->temp_pmap);
|
|
|
|
img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 0);
|
|
|
|
|
|
|
|
imlib_context_set_image(img);
|
|
|
|
imlib_save_image(path);
|
2009-11-11 13:46:56 +00:00
|
|
|
imlib_free_image();
|
2009-11-10 21:11:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
void window_action (Task *tsk, int action)
|
|
|
|
{
|
2009-09-07 21:41:21 +00:00
|
|
|
if (!tsk) return;
|
2009-08-29 15:14:55 +00:00
|
|
|
int desk;
|
2009-08-09 15:57:18 +00:00
|
|
|
switch (action) {
|
|
|
|
case CLOSE:
|
|
|
|
set_close (tsk->win);
|
|
|
|
break;
|
|
|
|
case TOGGLE:
|
|
|
|
set_active(tsk->win);
|
|
|
|
break;
|
|
|
|
case ICONIFY:
|
|
|
|
XIconifyWindow (server.dsp, tsk->win, server.screen);
|
|
|
|
break;
|
|
|
|
case TOGGLE_ICONIFY:
|
2009-11-11 17:12:24 +00:00
|
|
|
if (task_active && tsk->win == task_active->win)
|
|
|
|
XIconifyWindow (server.dsp, tsk->win, server.screen);
|
|
|
|
else
|
|
|
|
set_active (tsk->win);
|
2009-08-09 15:57:18 +00:00
|
|
|
break;
|
|
|
|
case SHADE:
|
|
|
|
window_toggle_shade (tsk->win);
|
|
|
|
break;
|
|
|
|
case MAXIMIZE_RESTORE:
|
|
|
|
window_maximize_restore (tsk->win);
|
|
|
|
break;
|
|
|
|
case MAXIMIZE:
|
|
|
|
window_maximize_restore (tsk->win);
|
|
|
|
break;
|
|
|
|
case RESTORE:
|
|
|
|
window_maximize_restore (tsk->win);
|
|
|
|
break;
|
2009-08-29 15:14:55 +00:00
|
|
|
case DESKTOP_LEFT:
|
2009-08-29 15:26:47 +00:00
|
|
|
if ( tsk->desktop == 0 ) break;
|
2009-08-29 15:14:55 +00:00
|
|
|
desk = tsk->desktop - 1;
|
|
|
|
windows_set_desktop(tsk->win, desk);
|
|
|
|
if (desk == server.desktop)
|
|
|
|
set_active(tsk->win);
|
|
|
|
break;
|
|
|
|
case DESKTOP_RIGHT:
|
2009-08-29 15:26:47 +00:00
|
|
|
if (tsk->desktop == server.nb_desktop ) break;
|
2009-08-29 15:14:55 +00:00
|
|
|
desk = tsk->desktop + 1;
|
|
|
|
windows_set_desktop(tsk->win, desk);
|
|
|
|
if (desk == server.desktop)
|
|
|
|
set_active(tsk->win);
|
2009-11-18 05:13:38 +00:00
|
|
|
break;
|
|
|
|
case NEXT_TASK:
|
|
|
|
if (task_active) {
|
|
|
|
Task *tsk1;
|
|
|
|
tsk1 = next_task(task_active);
|
|
|
|
set_active(tsk1->win);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PREV_TASK:
|
|
|
|
if (task_active) {
|
|
|
|
Task *tsk1;
|
|
|
|
tsk1 = prev_task(task_active);
|
|
|
|
set_active(tsk1->win);
|
|
|
|
}
|
2009-08-09 15:57:18 +00:00
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-07 23:28:13 +00:00
|
|
|
void event_button_press (XEvent *e)
|
2009-01-17 14:07:56 +00:00
|
|
|
{
|
2009-09-07 21:41:21 +00:00
|
|
|
Panel *panel = get_panel(e->xany.window);
|
2009-02-07 23:28:13 +00:00
|
|
|
if (!panel) return;
|
2009-10-26 21:21:54 +00:00
|
|
|
|
2009-09-27 07:44:41 +00:00
|
|
|
task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);
|
2009-08-28 23:14:53 +00:00
|
|
|
|
2009-09-08 21:29:32 +00:00
|
|
|
if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) {
|
2009-08-28 23:14:53 +00:00
|
|
|
// forward the click to the desktop window (thanks conky)
|
|
|
|
XUngrabPointer(server.dsp, e->xbutton.time);
|
|
|
|
e->xbutton.window = server.root_win;
|
|
|
|
// icewm doesn't open under the mouse.
|
|
|
|
// and xfce doesn't open at all.
|
2009-10-23 22:20:42 +00:00
|
|
|
e->xbutton.x = e->xbutton.x_root;
|
|
|
|
e->xbutton.y = e->xbutton.y_root;
|
2009-08-28 23:14:53 +00:00
|
|
|
//printf("**** %d, %d\n", e->xbutton.x, e->xbutton.y);
|
2009-10-23 22:20:42 +00:00
|
|
|
//XSetInputFocus(server.dsp, e->xbutton.window, RevertToParent, e->xbutton.time);
|
2009-08-28 23:14:53 +00:00
|
|
|
XSendEvent(server.dsp, e->xbutton.window, False, ButtonPressMask, e);
|
|
|
|
return;
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2009-08-29 15:14:55 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
XLowerWindow (server.dsp, panel->main_win);
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-07 23:28:13 +00:00
|
|
|
void event_button_release (XEvent *e)
|
2008-10-02 18:47:02 +00:00
|
|
|
{
|
2009-09-07 21:41:21 +00:00
|
|
|
Panel *panel = get_panel(e->xany.window);
|
2009-02-07 23:28:13 +00:00
|
|
|
if (!panel) return;
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
int action = TOGGLE_ICONIFY;
|
|
|
|
switch (e->xbutton.button) {
|
|
|
|
case 2:
|
|
|
|
action = mouse_middle;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
action = mouse_right;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
action = mouse_scroll_up;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
action = mouse_scroll_down;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
action = mouse_tilt_left;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
action = mouse_tilt_right;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-28 23:14:53 +00:00
|
|
|
|
2009-09-08 21:29:32 +00:00
|
|
|
if ( click_clock(panel, e->xbutton.x, e->xbutton.y)) {
|
2009-08-28 23:14:53 +00:00
|
|
|
clock_action(e->xbutton.button);
|
|
|
|
XLowerWindow (server.dsp, panel->main_win);
|
|
|
|
task_drag = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Taskbar *tskbar;
|
2009-09-08 21:29:32 +00:00
|
|
|
if ( !(tskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y)) ) {
|
2009-08-28 23:14:53 +00:00
|
|
|
// TODO: check better solution to keep window below
|
|
|
|
XLowerWindow (server.dsp, panel->main_win);
|
|
|
|
task_drag = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// drag and drop task
|
|
|
|
if (task_drag) {
|
|
|
|
if (tskbar != task_drag->area.parent && action == TOGGLE_ICONIFY) {
|
|
|
|
if (task_drag->desktop != ALLDESKTOP && panel_mode == MULTI_DESKTOP) {
|
|
|
|
windows_set_desktop(task_drag->win, tskbar->desktop);
|
|
|
|
if (tskbar->desktop == server.desktop)
|
|
|
|
set_active(task_drag->win);
|
|
|
|
task_drag = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else task_drag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// switch desktop
|
|
|
|
if (panel_mode == MULTI_DESKTOP) {
|
|
|
|
if (tskbar->desktop != server.desktop && action != CLOSE && action != DESKTOP_LEFT && action != DESKTOP_RIGHT)
|
|
|
|
set_desktop (tskbar->desktop);
|
2009-06-30 19:55:12 +00:00
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// action on task
|
2009-09-08 21:29:32 +00:00
|
|
|
window_action( click_task(panel, e->xbutton.x, e->xbutton.y), action);
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// to keep window below
|
|
|
|
XLowerWindow (server.dsp, panel->main_win);
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-25 20:04:43 +00:00
|
|
|
void event_property_notify (XEvent *e)
|
2009-01-17 14:07:56 +00:00
|
|
|
{
|
2009-09-07 21:41:21 +00:00
|
|
|
int i, j;
|
|
|
|
Task *tsk;
|
|
|
|
Window win = e->xproperty.window;
|
|
|
|
Atom at = e->xproperty.atom;
|
|
|
|
|
|
|
|
if (win == server.root_win) {
|
|
|
|
if (!server.got_root_win) {
|
|
|
|
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask);
|
|
|
|
server.got_root_win = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change number of desktops
|
|
|
|
else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
|
|
|
|
server.nb_desktop = server_get_number_of_desktop ();
|
|
|
|
cleanup_taskbar();
|
2009-02-07 23:28:13 +00:00
|
|
|
init_taskbar();
|
|
|
|
visible_object();
|
2009-02-10 23:16:10 +00:00
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
2009-02-13 21:54:42 +00:00
|
|
|
panel1[i].area.resize = 1;
|
2009-02-10 23:16:10 +00:00
|
|
|
}
|
2009-02-07 23:28:13 +00:00
|
|
|
task_refresh_tasklist();
|
|
|
|
panel_refresh = 1;
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
|
|
|
// Change desktop
|
|
|
|
else if (at == server.atom._NET_CURRENT_DESKTOP) {
|
2009-09-26 11:04:02 +00:00
|
|
|
int old_desktop = server.desktop;
|
2009-09-07 21:41:21 +00:00
|
|
|
server.desktop = server_get_current_desktop ();
|
2009-09-25 21:40:06 +00:00
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
2009-09-07 21:41:21 +00:00
|
|
|
Panel *panel = &panel1[i];
|
2009-09-25 21:40:06 +00:00
|
|
|
if (panel_mode == MULTI_DESKTOP && panel->g_taskbar.use_active) {
|
2009-09-26 11:04:02 +00:00
|
|
|
// redraw both taskbar
|
|
|
|
panel->taskbar[old_desktop].area.is_active = 0;
|
2009-10-31 11:58:45 +00:00
|
|
|
panel->taskbar[old_desktop].area.resize = 1;
|
2009-09-26 11:04:02 +00:00
|
|
|
panel->taskbar[server.desktop].area.is_active = 1;
|
2009-10-31 11:58:45 +00:00
|
|
|
panel->taskbar[server.desktop].area.resize = 1;
|
2009-09-25 21:40:06 +00:00
|
|
|
panel_refresh = 1;
|
2009-09-26 11:04:02 +00:00
|
|
|
}
|
|
|
|
// check ALLDESKTOP task => resize taskbar
|
|
|
|
Taskbar *tskbar;
|
|
|
|
Task *tsk;
|
|
|
|
GSList *l;
|
|
|
|
tskbar = &panel->taskbar[old_desktop];
|
|
|
|
for (l = tskbar->area.list; 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];
|
|
|
|
for (l = tskbar->area.list; l ; l = l->next) {
|
|
|
|
tsk = l->data;
|
|
|
|
if (tsk->desktop == ALLDESKTOP) {
|
|
|
|
tsk->area.on_screen = 1;
|
|
|
|
tskbar->area.resize = 1;
|
2009-08-30 15:40:02 +00:00
|
|
|
}
|
2009-09-25 21:40:06 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
if (panel_mode != MULTI_DESKTOP) {
|
2009-02-07 23:28:13 +00:00
|
|
|
visible_object();
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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) {
|
2009-10-23 21:28:44 +00:00
|
|
|
active_task();
|
2009-09-07 21:41:21 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
|
|
|
else if (at == server.atom._XROOTPMAP_ID) {
|
2009-06-13 19:39:41 +00:00
|
|
|
// change Wallpaper
|
2009-02-07 23:28:13 +00:00
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
|
|
|
set_panel_background(&panel1[i]);
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tsk = task_get_task (win);
|
|
|
|
if (!tsk) {
|
2009-11-11 17:12:24 +00:00
|
|
|
if (at != server.atom._NET_WM_STATE)
|
2009-09-07 21:41:21 +00:00
|
|
|
return;
|
2009-11-11 18:25:55 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-11-11 17:12:24 +00:00
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
|
|
|
//printf("atom root_win = %s, %s\n", XGetAtomName(server.dsp, at), tsk->title);
|
|
|
|
|
|
|
|
// Window title changed
|
|
|
|
if (at == server.atom._NET_WM_VISIBLE_NAME || at == server.atom._NET_WM_NAME || at == server.atom.WM_NAME) {
|
2009-02-07 23:28:13 +00:00
|
|
|
Task *tsk2;
|
|
|
|
GSList *l0;
|
|
|
|
get_title(tsk);
|
|
|
|
// changed other tsk->title
|
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
|
|
|
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
|
|
|
|
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
|
|
|
|
tsk2 = l0->data;
|
|
|
|
if (tsk->win == tsk2->win && tsk != tsk2) {
|
|
|
|
tsk2->title = tsk->title;
|
|
|
|
tsk2->area.redraw = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
2009-02-25 20:04:43 +00:00
|
|
|
// Demand attention
|
2009-09-07 21:41:21 +00:00
|
|
|
else if (at == server.atom._NET_WM_STATE) {
|
|
|
|
if (window_is_urgent (win)) {
|
2009-11-11 20:09:34 +00:00
|
|
|
add_urgent(tsk);
|
2009-02-25 20:04:43 +00:00
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
if (window_is_skip_taskbar(win)) {
|
|
|
|
remove_task( tsk );
|
2009-09-08 18:58:34 +00:00
|
|
|
panel_refresh = 1;
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2009-02-25 20:04:43 +00:00
|
|
|
}
|
2009-10-17 07:03:44 +00:00
|
|
|
// We do not check for the iconified state, since it only unsets our active window
|
|
|
|
// but in openbox a shaded window is considered iconified. So we would loose the active window
|
|
|
|
// property on unshading it again (commented 01.10.2009)
|
2009-09-27 08:06:31 +00:00
|
|
|
// else if (at == server.atom.WM_STATE) {
|
|
|
|
// // Iconic state
|
|
|
|
// // TODO : try to delete following code
|
|
|
|
// if (window_is_iconified (win)) {
|
|
|
|
// if (task_active) {
|
|
|
|
// if (task_active->win == tsk->win) {
|
|
|
|
// Task *tsk2;
|
|
|
|
// GSList *l0;
|
|
|
|
// for (i=0 ; i < nb_panel ; i++) {
|
|
|
|
// for (j=0 ; j < panel1[i].nb_desktop ; j++) {
|
|
|
|
// for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
|
|
|
|
// tsk2 = l0->data;
|
|
|
|
// tsk2->area.is_active = 0;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// task_active = 0;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2009-09-07 21:41:21 +00:00
|
|
|
// Window icon changed
|
|
|
|
else if (at == server.atom._NET_WM_ICON) {
|
|
|
|
get_icon(tsk);
|
2009-02-07 23:28:13 +00:00
|
|
|
Task *tsk2;
|
|
|
|
GSList *l0;
|
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
|
|
|
for (j=0 ; j < panel1[i].nb_desktop ; j++) {
|
|
|
|
for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
|
|
|
|
tsk2 = l0->data;
|
|
|
|
if (tsk->win == tsk2->win && tsk != tsk2) {
|
|
|
|
tsk2->icon_width = tsk->icon_width;
|
|
|
|
tsk2->icon_height = tsk->icon_height;
|
2009-09-19 20:56:15 +00:00
|
|
|
tsk2->icon = tsk->icon;
|
|
|
|
tsk2->icon_active = tsk->icon_active;
|
2009-02-07 23:28:13 +00:00
|
|
|
tsk2->area.redraw = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
|
|
|
// Window desktop changed
|
|
|
|
else if (at == server.atom._NET_WM_DESKTOP) {
|
2009-06-06 21:03:00 +00:00
|
|
|
int desktop = window_get_desktop (win);
|
2009-06-29 19:50:29 +00:00
|
|
|
int active = tsk->area.is_active;
|
2009-06-06 21:03:00 +00:00
|
|
|
//printf(" Window desktop changed %d, %d\n", tsk->desktop, desktop);
|
|
|
|
// bug in windowmaker : send unecessary 'desktop changed' when focus changed
|
|
|
|
if (desktop != tsk->desktop) {
|
|
|
|
remove_task (tsk);
|
2009-06-29 19:50:29 +00:00
|
|
|
tsk = add_task (win);
|
|
|
|
if (tsk && active) {
|
|
|
|
tsk->area.is_active = 1;
|
|
|
|
task_active = tsk;
|
|
|
|
}
|
2009-06-06 21:03:00 +00:00
|
|
|
panel_refresh = 1;
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2009-09-15 20:11:13 +00:00
|
|
|
else if (at == server.atom.WM_HINTS) {
|
|
|
|
XWMHints* wmhints = XGetWMHints(server.dsp, win);
|
2009-09-16 11:00:23 +00:00
|
|
|
if (wmhints && wmhints->flags & XUrgencyHint) {
|
2009-11-11 20:09:34 +00:00
|
|
|
add_urgent(tsk);
|
2009-09-15 20:11:13 +00:00
|
|
|
}
|
|
|
|
XFree(wmhints);
|
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
if (!server.got_root_win) server.root_win = RootWindow (server.dsp, server.screen);
|
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-28 23:04:53 +00:00
|
|
|
void event_expose (XEvent *e)
|
|
|
|
{
|
2009-11-16 10:06:45 +00:00
|
|
|
Panel *panel;
|
|
|
|
panel = get_panel(e->xany.window);
|
|
|
|
if (!panel) return;
|
|
|
|
// TODO : one panel_refresh per panel ?
|
|
|
|
panel_refresh = 1;
|
2009-02-28 23:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
void event_configure_notify (Window win)
|
2009-01-17 14:07:56 +00:00
|
|
|
{
|
2009-09-27 16:57:19 +00:00
|
|
|
// change in root window (xrandr)
|
2009-09-27 13:33:31 +00:00
|
|
|
if (win == server.root_win) {
|
2009-09-27 16:57:19 +00:00
|
|
|
get_monitors();
|
2009-10-30 20:54:29 +00:00
|
|
|
init_config();
|
|
|
|
config_read_file (config_path);
|
2009-10-18 17:54:09 +00:00
|
|
|
init_panel();
|
2009-10-30 20:54:29 +00:00
|
|
|
cleanup_config();
|
2009-09-27 16:57:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// '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);
|
2009-09-27 13:33:31 +00:00
|
|
|
panel_refresh = 1;
|
2009-09-27 16:57:19 +00:00
|
|
|
return;
|
2009-02-13 21:54:42 +00:00
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2009-09-27 16:57:19 +00:00
|
|
|
|
|
|
|
// '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;
|
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-08 21:29:32 +00:00
|
|
|
void dnd_message(XClientMessageEvent *e)
|
|
|
|
{
|
|
|
|
Panel *panel = get_panel(e->window);
|
|
|
|
int x, y, mapX, mapY;
|
|
|
|
Window child;
|
|
|
|
x = (e->data.l[2] >> 16) & 0xFFFF;
|
|
|
|
y = e->data.l[2] & 0xFFFF;
|
|
|
|
XTranslateCoordinates(server.dsp, server.root_win, e->window, x, y, &mapX, &mapY, &child);
|
|
|
|
Task* task = click_task(panel, mapX, mapY);
|
|
|
|
if (task) {
|
|
|
|
if (task->desktop != server.desktop )
|
|
|
|
set_desktop (task->desktop);
|
|
|
|
window_action(task, TOGGLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// send XdndStatus event to get more XdndPosition events
|
|
|
|
XClientMessageEvent se;
|
|
|
|
se.type = ClientMessage;
|
|
|
|
se.window = e->data.l[0];
|
|
|
|
se.message_type = server.atom.XdndStatus;
|
|
|
|
se.format = 32;
|
|
|
|
se.data.l[0] = e->window; // XID of the target window
|
|
|
|
se.data.l[1] = 0; // bit 0: accept drop bit 1: send XdndPosition events if inside rectangle
|
|
|
|
se.data.l[2] = 0; // Rectangle x,y for which no more XdndPosition events
|
|
|
|
se.data.l[3] = (1 << 16) | 1; // Rectangle w,h for which no more XdndPosition events
|
|
|
|
se.data.l[4] = None; // None = drop will not be accepted
|
|
|
|
XSendEvent(server.dsp, e->data.l[0], False, NoEventMask, (XEvent*)&se);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-02 18:47:02 +00:00
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
2009-09-07 21:41:21 +00:00
|
|
|
XEvent e;
|
2009-11-16 09:27:44 +00:00
|
|
|
fd_set fdset;
|
2009-09-07 21:41:21 +00:00
|
|
|
int x11_fd, i;
|
|
|
|
Panel *panel;
|
2009-02-27 22:18:30 +00:00
|
|
|
GSList *it;
|
2009-11-15 16:55:50 +00:00
|
|
|
GSList* timer_iter;
|
|
|
|
struct timer* timer;
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
init (argc, argv);
|
2009-10-17 19:52:44 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
i = 0;
|
2009-02-07 23:28:13 +00:00
|
|
|
init_config();
|
2009-09-07 21:41:21 +00:00
|
|
|
if (config_path)
|
|
|
|
i = config_read_file (config_path);
|
2009-08-29 16:19:01 +00:00
|
|
|
else
|
|
|
|
i = config_read ();
|
|
|
|
if (!i) {
|
|
|
|
fprintf(stderr, "usage: tint2 [-c] <config_file>\n");
|
|
|
|
cleanup();
|
|
|
|
exit(1);
|
2009-06-20 14:41:06 +00:00
|
|
|
}
|
2009-10-30 17:18:44 +00:00
|
|
|
init_panel();
|
|
|
|
cleanup_config();
|
2009-11-10 21:11:31 +00:00
|
|
|
if (snapshot_path) {
|
|
|
|
get_snapshot(snapshot_path);
|
2009-08-29 16:19:01 +00:00
|
|
|
cleanup();
|
|
|
|
exit(0);
|
|
|
|
}
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
x11_fd = ConnectionNumber(server.dsp);
|
|
|
|
XSync(server.dsp, False);
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-11-15 16:55:50 +00:00
|
|
|
sigset_t empty_mask;
|
|
|
|
sigemptyset(&empty_mask);
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
while (1) {
|
2009-11-16 10:06:45 +00:00
|
|
|
if (panel_refresh) {
|
|
|
|
panel_refresh = 0;
|
|
|
|
|
|
|
|
if (refresh_systray) {
|
|
|
|
panel = (Panel*)systray.area.panel;
|
|
|
|
XSetWindowBackgroundPixmap (server.dsp, panel->main_win, None);
|
|
|
|
}
|
|
|
|
for (i=0 ; i < nb_panel ; i++) {
|
|
|
|
panel = &panel1[i];
|
|
|
|
|
|
|
|
if (panel->temp_pmap) XFreePixmap(server.dsp, panel->temp_pmap);
|
|
|
|
panel->temp_pmap = XCreatePixmap(server.dsp, server.root_win, panel->area.width, panel->area.height, server.depth);
|
|
|
|
|
|
|
|
refresh(&panel->area);
|
|
|
|
XCopyArea(server.dsp, panel->temp_pmap, panel->main_win, server.gc, 0, 0, panel->area.width, panel->area.height, 0, 0);
|
|
|
|
}
|
|
|
|
XFlush (server.dsp);
|
|
|
|
|
|
|
|
if (refresh_systray) {
|
|
|
|
refresh_systray = 0;
|
|
|
|
panel = (Panel*)systray.area.panel;
|
|
|
|
// tint2 doen't draw systray icons. it just redraw background.
|
|
|
|
XSetWindowBackgroundPixmap (server.dsp, panel->main_win, panel->temp_pmap);
|
|
|
|
// force icon's refresh
|
|
|
|
refresh_systray_icon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// thanks to AngryLlama for the timer
|
2009-11-15 16:55:50 +00:00
|
|
|
// Create a File Description Set containing x11_fd, and every timer_fd
|
2009-11-16 09:27:44 +00:00
|
|
|
FD_ZERO (&fdset);
|
|
|
|
FD_SET (x11_fd, &fdset);
|
2009-11-15 16:55:50 +00:00
|
|
|
int max_fd = x11_fd;
|
|
|
|
timer_iter = timer_list;
|
|
|
|
while (timer_iter) {
|
|
|
|
timer = timer_iter->data;
|
|
|
|
max_fd = timer->id > max_fd ? timer->id : max_fd;
|
2009-11-16 09:27:44 +00:00
|
|
|
FD_SET(timer->id, &fdset);
|
2009-11-15 16:55:50 +00:00
|
|
|
timer_iter = timer_iter->next;
|
|
|
|
}
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
// Wait for X Event or a Timer
|
2009-11-16 09:27:44 +00:00
|
|
|
if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
|
2009-09-07 21:41:21 +00:00
|
|
|
while (XPending (server.dsp)) {
|
|
|
|
XNextEvent(server.dsp, &e);
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
switch (e.type) {
|
|
|
|
case ButtonPress:
|
2009-09-14 21:28:17 +00:00
|
|
|
tooltip_hide();
|
2009-09-07 21:41:21 +00:00
|
|
|
event_button_press (&e);
|
|
|
|
break;
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
case ButtonRelease:
|
|
|
|
event_button_release(&e);
|
|
|
|
break;
|
2009-01-17 14:07:56 +00:00
|
|
|
|
2009-09-14 21:28:17 +00:00
|
|
|
case MotionNotify: {
|
2009-10-30 20:54:29 +00:00
|
|
|
if (!g_tooltip.enabled) break;
|
2009-09-14 21:28:17 +00:00
|
|
|
Panel* panel = get_panel(e.xmotion.window);
|
2009-11-16 17:17:53 +00:00
|
|
|
Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
|
|
|
|
if (area->_get_tooltip_text) {
|
|
|
|
tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root);
|
|
|
|
}
|
2009-09-14 21:28:17 +00:00
|
|
|
else
|
|
|
|
tooltip_trigger_hide();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LeaveNotify:
|
|
|
|
tooltip_trigger_hide();
|
|
|
|
break;
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
case Expose:
|
|
|
|
event_expose(&e);
|
|
|
|
break;
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-11-16 10:06:45 +00:00
|
|
|
case MapNotify:
|
|
|
|
if (e.xany.window == g_tooltip.window)
|
|
|
|
tooltip_update();
|
|
|
|
break;
|
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
case PropertyNotify:
|
|
|
|
event_property_notify(&e);
|
|
|
|
break;
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-09-07 21:41:21 +00:00
|
|
|
case ConfigureNotify:
|
2009-09-27 13:33:31 +00:00
|
|
|
event_configure_notify (e.xconfigure.window);
|
2009-09-07 21:41:21 +00:00
|
|
|
break;
|
2009-02-10 23:16:10 +00:00
|
|
|
|
2009-06-13 19:39:41 +00:00
|
|
|
case ReparentNotify:
|
2009-10-31 11:58:45 +00:00
|
|
|
if (!systray_enabled)
|
2009-06-29 18:39:44 +00:00
|
|
|
break;
|
|
|
|
panel = (Panel*)systray.area.panel;
|
|
|
|
if (e.xany.window == panel->main_win) // reparented to us
|
2009-06-13 19:39:41 +00:00
|
|
|
break;
|
2009-06-29 18:39:44 +00:00
|
|
|
// FIXME: 'reparent to us' badly detected => disabled
|
|
|
|
break;
|
2009-02-10 23:16:10 +00:00
|
|
|
case UnmapNotify:
|
|
|
|
case DestroyNotify:
|
2009-11-16 10:06:45 +00:00
|
|
|
if (e.xany.window == g_tooltip.window || !systray.area.on_screen)
|
2009-06-13 19:39:41 +00:00
|
|
|
break;
|
2009-02-27 22:18:30 +00:00
|
|
|
for (it = systray.list_icons; it; it = g_slist_next(it)) {
|
2009-02-10 23:16:10 +00:00
|
|
|
if (((TrayWindow*)it->data)->id == e.xany.window) {
|
2009-03-01 19:18:35 +00:00
|
|
|
remove_icon((TrayWindow*)it->data);
|
2009-02-10 23:16:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-27 22:18:30 +00:00
|
|
|
}
|
2009-02-10 23:16:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ClientMessage:
|
2009-03-07 10:05:15 +00:00
|
|
|
if (!systray.area.on_screen) break;
|
2009-02-25 20:04:43 +00:00
|
|
|
if (e.xclient.message_type == server.atom._NET_SYSTEM_TRAY_OPCODE && e.xclient.format == 32 && e.xclient.window == net_sel_win) {
|
2009-02-10 23:16:10 +00:00
|
|
|
net_message(&e.xclient);
|
2009-02-25 20:04:43 +00:00
|
|
|
}
|
2009-09-08 21:29:32 +00:00
|
|
|
else if (e.xclient.message_type == server.atom.XdndPosition) {
|
|
|
|
dnd_message(&e.xclient);
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-11-15 16:55:50 +00:00
|
|
|
|
2009-11-16 07:27:28 +00:00
|
|
|
// we need to iterate over the whole timer list, since fd_set can only be checked with the
|
|
|
|
// brute force method FD_ISSET for every possible timer
|
2009-11-15 16:55:50 +00:00
|
|
|
timer_iter = timer_list;
|
|
|
|
while (timer_iter) {
|
|
|
|
timer = timer_iter->data;
|
2009-11-16 09:27:44 +00:00
|
|
|
if (FD_ISSET(timer->id, &fdset)) {
|
2009-11-15 16:55:50 +00:00
|
|
|
uint64_t dummy;
|
|
|
|
read(timer->id, &dummy, sizeof(uint64_t));
|
|
|
|
timer->_callback();
|
|
|
|
}
|
|
|
|
timer_iter = timer_iter->next;
|
|
|
|
}
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
|
2009-02-07 23:28:13 +00:00
|
|
|
switch (signal_pending) {
|
2009-11-15 16:55:50 +00:00
|
|
|
case SIGUSR1: // reload config file
|
|
|
|
signal_pending = 0;
|
|
|
|
init_config();
|
|
|
|
config_read_file (config_path);
|
|
|
|
init_panel();
|
|
|
|
cleanup_config();
|
|
|
|
break;
|
|
|
|
case SIGINT:
|
|
|
|
case SIGTERM:
|
|
|
|
case SIGHUP:
|
|
|
|
cleanup ();
|
|
|
|
return 0;
|
2009-09-07 21:41:21 +00:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 18:47:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|