Systray/status: Adapt statuspos (with image/rectangle) with systray width

This commit is contained in:
Martin Duquesnoy 2010-07-23 04:15:33 +02:00
parent 1094861b49
commit cc10d56359
7 changed files with 31 additions and 17 deletions

View File

@ -616,7 +616,7 @@ client_map(Client *c)
{ {
CHECK(c); CHECK(c);
if(c->flags & FSSFlag) if(c->flags & FSSFlag || c->flags & DockFlag)
XMapWindow(dpy, c->win); XMapWindow(dpy, c->win);
else else
{ {

View File

@ -52,7 +52,7 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
/* To draw image everywhere we can draw text */ /* To draw image everywhere we can draw text */
#ifdef HAVE_IMLIB #ifdef HAVE_IMLIB
char *ostr = NULL; char *ostr = NULL;
int i, ni; int i, ni, sw = 0;
ImageAttr im[128]; ImageAttr im[128];
ostr = _strdup(str); ostr = _strdup(str);
@ -61,8 +61,11 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
{ {
ni = parse_image_block(im, str); ni = parse_image_block(im, str);
if(d == infobar[0 /* SYSTRAY_SCREEN */].bar->dr)
sw = systray_get_width();
for(i = 0; i < ni; ++i) for(i = 0; i < ni; ++i)
draw_image(d, im[i].x, im[i].y, im[i].w, im[i].h, im[i].name); draw_image(d, im[i].x - sw, im[i].y, im[i].w, im[i].h, im[i].name);
} }
#endif /* HAVE_IMLIB */ #endif /* HAVE_IMLIB */

View File

@ -436,6 +436,8 @@ ewmh_manage_window_type(Client *c)
/* Reparent it to ROOT win */ /* Reparent it to ROOT win */
XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y); XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y);
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
c->flags |= DockFlag;
} }
/* MANAGE _NET_WM_WINDOW_TYPE_DIALOG */ /* MANAGE _NET_WM_WINDOW_TYPE_DIALOG */
else if(atom[i] == net_atom[net_wm_window_type_dialog]) else if(atom[i] == net_atom[net_wm_window_type_dialog])

View File

@ -141,7 +141,11 @@ statustext_normal(int sc, char *str)
char strwc[MAXSTATUS] = { 0 }; char strwc[MAXSTATUS] = { 0 };
char buf[MAXSTATUS] = { 0 }; char buf[MAXSTATUS] = { 0 };
char col[8] = { 0 }; char col[8] = { 0 };
int n, i, j, k; int n, i, j, k, sw = 0;
/* if(sc == SYSTRAY_SCREEN) */
if(!sc)
sw = systray_get_width();
for(i = j = n = 0; i < strlen(str); ++i, ++j) for(i = j = n = 0; i < strlen(str); ++i, ++j)
if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\') if(str[i] == '\\' && str[i + 1] == '#' && str[i + 8] == '\\')
@ -154,7 +158,7 @@ statustext_normal(int sc, char *str)
strwc[j] = str[i]; strwc[j] = str[i];
/* Draw normal text without any blocks */ /* Draw normal text without any blocks */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(strwc), draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - (textw(strwc) + sw++),
FHINFOBAR, infobar[sc].bar->fg, 0, strwc); FHINFOBAR, infobar[sc].bar->fg, 0, strwc);
if(n) if(n)
@ -169,11 +173,11 @@ statustext_normal(int sc, char *str)
/* Draw a rectangle with the bar color to draw the text properly */ /* Draw a rectangle with the bar color to draw the text properly */
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]), draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(&buf[k]), 0, INFOBARH - (sgeo[sc].width - SHADH) - (textw(&buf[k]) + sw),
INFOBARH, conf.colors.bar); INFOBARH, conf.colors.bar);
/* Draw text with its color */ /* Draw text with its color */
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]), draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - (textw(&buf[k]) + sw),
FHINFOBAR, col, 0, &buf[k]); FHINFOBAR, col, 0, &buf[k]);
strcpy(buf, strwc); strcpy(buf, strwc);
@ -192,7 +196,7 @@ void
statustext_handle(int sc, char *str) statustext_handle(int sc, char *str)
{ {
char *lastst; char *lastst;
int i, nr, ng, ns, len; int i, nr, ng, ns, len, sw = 0;
StatusRec r[128]; StatusRec r[128];
StatusGraph g[128]; StatusGraph g[128];
StatusText s[128]; StatusText s[128];
@ -201,6 +205,11 @@ statustext_handle(int sc, char *str)
if(!str) if(!str)
return; return;
/* if(sc == SYSTRAY_SCREEN) */
if(!sc)
sw = systray_get_width();
barwin_refresh_color(infobar[sc].bar); barwin_refresh_color(infobar[sc].bar);
/* save last status text address (for free at the end) */ /* save last status text address (for free at the end) */
@ -219,15 +228,15 @@ statustext_handle(int sc, char *str)
/* Draw rectangles with stored properties. */ /* Draw rectangles with stored properties. */
for(i = 0; i < nr; ++i) for(i = 0; i < nr; ++i)
draw_rectangle(infobar[sc].bar->dr, r[i].x, r[i].y, r[i].w, r[i].h, r[i].color); draw_rectangle(infobar[sc].bar->dr, r[i].x - sw, r[i].y, r[i].w, r[i].h, r[i].color);
/* Draw graphs with stored properties. */ /* Draw graphs with stored properties. */
for(i = 0; i < ng; ++i) for(i = 0; i < ng; ++i)
draw_graph(infobar[sc].bar->dr, g[i].x, g[i].y, g[i].w, g[i].h, g[i].color, g[i].data); draw_graph(infobar[sc].bar->dr, g[i].x - sw, g[i].y, g[i].w, g[i].h, g[i].color, g[i].data);
/* Draw located text with stored properties. */ /* Draw located text with stored properties. */
for(i = 0; i < ns; ++i) for(i = 0; i < ns; ++i)
draw_text(infobar[sc].bar->dr, s[i].x, s[i].y, s[i].color, 0, s[i].text); draw_text(infobar[sc].bar->dr, s[i].x - sw, s[i].y, s[i].color, 0, s[i].text);
barwin_refresh(infobar[sc].bar); barwin_refresh(infobar[sc].bar);

View File

@ -52,6 +52,7 @@
#define AboveFlag (1 << 9) #define AboveFlag (1 << 9)
#define UrgentFlag (1 << 10) #define UrgentFlag (1 << 10)
#define FLayFlag (1 << 11) #define FLayFlag (1 << 11)
#define DockFlag (1 << 12)
#define TagFlag(t) (1 << (t)) #define TagFlag(t) (1 << (t))

View File

@ -32,7 +32,8 @@
#include "wmfs.h" #include "wmfs.h"
#define TRAY_DWIDTH 18 #define TRAY_SPACING (3)
#define TRAY_DWIDTH (infobar[0].bar->geo.height + TRAY_SPACING)
Bool Bool
systray_acquire(void) systray_acquire(void)
@ -208,7 +209,7 @@ systray_get_width(void)
Systray *i; Systray *i;
for(i = trayicons; i; i = i->next) for(i = trayicons; i; i = i->next)
w += i->geo.width + 2; w += i->geo.width + TRAY_SPACING + 1;
return w; return w;
} }
@ -218,7 +219,7 @@ systray_update(void)
{ {
Systray *i; Systray *i;
XWindowAttributes xa; XWindowAttributes xa;
int x = 0; int x = 1;
if(!trayicons) if(!trayicons)
{ {
@ -241,7 +242,7 @@ systray_update(void)
XMoveResizeWindow(dpy, i->win, (i->geo.x = x), 0, i->geo.width, i->geo.height); XMoveResizeWindow(dpy, i->win, (i->geo.x = x), 0, i->geo.width, i->geo.height);
x += i->geo.width + 2; x += i->geo.width + TRAY_SPACING;
} }
XMoveResizeWindow(dpy, traywin, infobar[0].bar->geo.width - x, 0, x, infobar[0].bar->geo.height); XMoveResizeWindow(dpy, traywin, infobar[0].bar->geo.width - x, 0, x, infobar[0].bar->geo.height);

View File

@ -54,8 +54,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xmd.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/cursorfont.h> #include <X11/cursorfont.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>