+void set_panel_properties(Panel *p)
+{
+ XStoreName (server.dsp, p->main_win, "tint2");
+
+ gsize len;
+ gchar *name = g_locale_to_utf8("tint2", -1, NULL, &len, NULL);
+ if (name != NULL) {
+ XChangeProperty(server.dsp, p->main_win, server.atom._NET_WM_NAME, server.atom.UTF8_STRING, 8, PropModeReplace, (unsigned char *) name, (int) len);
+ g_free(name);
+ }
+
+ // Dock
+ long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
+ XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *) &val, 1);
+
+ // Sticky and below other window
+ val = 0xFFFFFFFF;
+ XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1);
+ Atom state[4];
+ state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
+ state[1] = server.atom._NET_WM_STATE_SKIP_TASKBAR;
+ state[2] = server.atom._NET_WM_STATE_STICKY;
+ 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);
+
+ // Unfocusable
+ XWMHints wmhints;
+ 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);
+
+ // Reserved space
+ long struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ if (panel_horizontal) {
+ if (panel_position & TOP) {
+ struts[2] = p->area.height + p->marginy;
+ struts[8] = p->posx;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[9] = p->posx + p->area.width - 1;
+ }
+ else {
+ struts[3] = p->area.height + p->marginy;
+ struts[10] = p->posx;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[11] = p->posx + p->area.width - 1;
+ }
+ }
+ else {
+ if (panel_position & LEFT) {
+ struts[0] = p->area.width + p->marginx;
+ struts[4] = p->posy;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[5] = p->posy + p->area.height - 1;
+ }
+ else {
+ struts[1] = p->area.width + p->marginx;
+ struts[6] = p->posy;
+ // p->area.width - 1 allowed full screen on monitor 2
+ struts[7] = p->posy + p->area.height - 1;
+ }
+ }
+ // Old specification : fluxbox need _NET_WM_STRUT.
+ XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 4);
+ XChangeProperty (server.dsp, p->main_win, server.atom._NET_WM_STRUT_PARTIAL, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &struts, 12);
+
+ // Fixed position and non-resizable window
+ // Allow panel move and resize when tint2 reload config file
+ XSizeHints size_hints;
+ 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);
+}
+
+
+void set_panel_background(Panel *p)
+{
+ get_root_pixmap();
+
+ if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
+ p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
+
+ // copy background (server.root_pmap) in panel.area.pix.pmap
+ Window dummy;
+ int x, y;
+ XTranslateCoordinates(server.dsp, p->main_win, server.root_win, 0, 0, &x, &y, &dummy);
+ XSetTSOrigin(server.dsp, server.gc, -x, -y) ;
+ XFillRectangle(server.dsp, p->area.pix.pmap, server.gc, 0, 0, p->area.width, p->area.height);
+
+ // draw background panel
+ cairo_surface_t *cs;
+ cairo_t *c;
+ cs = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
+ c = cairo_create (cs);
+
+ draw_background(&p->area, c, 0);
+
+ cairo_destroy (c);
+ cairo_surface_destroy (cs);
+
+ // redraw panel's object
+ GSList *l0;
+ Area *a;
+ for (l0 = p->area.list; l0 ; l0 = l0->next) {
+ a = l0->data;
+ set_redraw(a);
+ }
+}
+
+
+Panel *get_panel(Window win)
+{
+ int i;
+ for (i=0 ; i < nb_panel ; i++) {
+ if (panel1[i].main_win == win) {
+ return &panel1[i];
+ }
+ }
+ return 0;
+}
+
+
+Taskbar *click_taskbar (Panel *panel, int x, int y)
+{
+ Taskbar *tskbar;
+ int i;
+
+ if (panel_horizontal) {
+ for (i=0; i < panel->nb_desktop ; i++) {
+ tskbar = &panel->taskbar[i];
+ if (tskbar->area.on_screen && x >= tskbar->area.posx && x <= (tskbar->area.posx + tskbar->area.width))
+ return tskbar;
+ }
+ }
+ else {
+ for (i=0; i < panel->nb_desktop ; i++) {
+ tskbar = &panel->taskbar[i];
+ if (tskbar->area.on_screen && y >= tskbar->area.posy && y <= (tskbar->area.posy + tskbar->area.height))
+ return tskbar;
+ }
+ }
+ return NULL;
+}
+
+
+Task *click_task (Panel *panel, int x, int y)
+{
+ GSList *l0;
+ Taskbar *tskbar;
+
+ if ( (tskbar = click_taskbar(panel, x, y)) ) {
+ if (panel_horizontal) {
+ Task *tsk;
+ for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
+ tsk = l0->data;
+ if (tsk->area.on_screen && x >= tsk->area.posx && x <= (tsk->area.posx + tsk->area.width)) {
+ return tsk;
+ }
+ }
+ }
+ else {
+ Task *tsk;
+ for (l0 = tskbar->area.list; l0 ; l0 = l0->next) {
+ tsk = l0->data;
+ if (tsk->area.on_screen && y >= tsk->area.posy && y <= (tsk->area.posy + tsk->area.height)) {
+ return tsk;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+
+int click_padding(Panel *panel, int x, int y)
+{
+ if (panel_horizontal) {
+ if (x < panel->area.paddingxlr || x > panel->area.width-panel->area.paddingxlr)
+ return 1;
+ }
+ else {
+ if (y < panel->area.paddingxlr || y > panel->area.height-panel->area.paddingxlr)
+ return 1;
+ }
+ return 0;
+}
+
+
+int click_clock(Panel *panel, int x, int y)
+{
+ Clock clk = panel->clock;
+ if (panel_horizontal) {
+ if (clk.area.on_screen && x >= clk.area.posx && x <= (clk.area.posx + clk.area.width))
+ return TRUE;
+ } else {
+ if (clk.area.on_screen && y >= clk.area.posy && y <= (clk.area.posy + clk.area.height))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+Area* click_area(Panel *panel, int x, int y)
+{
+ Area* result = &panel->area;
+ Area* new_result = result;
+ do {
+ result = new_result;
+ GSList* it = result->list;
+ while (it) {
+ Area* a = it->data;
+ if (panel_horizontal) {
+ if (a->on_screen && x >= a->posx && x <= (a->posx + a->width)) {
+ new_result = a;
+ break;
+ }
+ } else {
+ if (a->on_screen && y >= a->posy && y <= (a->posy + a->height)) {
+ new_result = a;
+ break;
+ }
+ }
+ it = it->next;
+ }
+ } while (new_result != result);
+ return result;
+}