#include "window.h"
#include "task.h"
#include "panel.h"
+#include "tooltip.h"
int signal_pending;
int panel_mode;
int wm_menu;
+int panel_dock=0; // default not in the dock
int panel_position;
int panel_horizontal;
int panel_refresh;
int tick_urgent;
int max_tick_urgent;
+// panel's initial config
+Panel panel_config;
+// panels (one panel per monitor)
Panel *panel1 = 0;
int nb_panel;
+Imlib_Image default_icon;
void init_panel()
int i;
Panel *p;
+ // load default icon
+ char *path;
+ 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);
+ }
+
+ //if (panel1)
+ // free(panel1);
+ // alloc panels (one monitor or all monitors)
+ if (panel_config.monitor >= 0)
+ nb_panel = 1;
+ else
+ nb_panel = server.nb_monitor;
+ panel1 = malloc(nb_panel * sizeof(Panel));
+
for (i=0 ; i < nb_panel ; i++) {
p = &panel1[i];
+ memcpy(p, &panel_config, sizeof(Panel));
+ p->monitor = i;
p->area.parent = p;
p->area.panel = p;
p->area.on_screen = 1;
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
- XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 };
+ long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;
+ if (g_tooltip.enabled)
+ event_mask |= PointerMotionMask|LeaveWindowMask;
+ XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, event_mask, NoEventMask, False, 0, 0 };
if (p->main_win) XDestroyWindow(server.dsp, p->main_win);
p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att);
}
+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;
cleanup_systray();
cleanup_taskbar();
+ if (default_icon) {
+ imlib_context_set_image(default_icon);
+ imlib_free_image();
+ }
+
// font allocated once
if (panel1[0].g_task.font_desc) {
pango_font_description_free(panel1[0].g_task.font_desc);
if (panel1) free(panel1);
panel1 = 0;
+
+ if (g_tooltip.window) {
+ XDestroyWindow(server.dsp, g_tooltip.window);
+ g_tooltip.window = 0;
+ }
+ if (g_tooltip.font_desc) {
+ pango_font_description_free(g_tooltip.font_desc);
+ g_tooltip.font_desc = 0;
+ }
}
{
XStoreName (server.dsp, p->main_win, "tint2");
- // TODO: check if the name is really needed for a panel/taskbar ?
gsize len;
gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL);
if (name != NULL) {
state[3] = server.atom._NET_WM_STATE_BELOW;
XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *) state, 4);
- // Fixed position
+ // Fixed position and non-resizable window
XSizeHints size_hints;
- size_hints.flags = PPosition;
- XChangeProperty (server.dsp, p->main_win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4);
+ size_hints.flags = PPosition|PMinSize|PMaxSize;
+ size_hints.min_width = size_hints.max_width = p->area.width;
+ size_hints.min_height = size_hints.max_height = p->area.height;
+ XSetWMNormalHints(server.dsp, p->main_win, &size_hints);
// Unfocusable
XWMHints wmhints;
- wmhints.flags = InputHint;
- wmhints.input = False;
- XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
+ if (panel_dock) {
+ // TODO: Xdnd feature cannot be used in withdrawn state at the moment (at least GTK apps fail, qt seems to work)
+ wmhints.icon_window = wmhints.window_group = p->main_win;
+ wmhints.flags = StateHint | IconWindowHint;
+ wmhints.initial_state = WithdrawnState;
+ }
+ else {
+ wmhints.flags = InputHint;
+ wmhints.input = False;
+ }
+ XSetWMHints(server.dsp, p->main_win, &wmhints);
// Undecorated
long prop[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(server.dsp, p->main_win, server.atom._MOTIF_WM_HINTS, server.atom._MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) prop, 5);
+
+ // XdndAware - Register for Xdnd events
+ int version=5;
+ XChangeProperty(server.dsp, p->main_win, server.atom.XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&version, 1);
}