Infobar/Wmfs: Fix infobar_draw_statustext, remove useless screen_count()
This commit is contained in:
@@ -140,7 +140,7 @@ void
|
|||||||
clientmessageevent(XClientMessageEvent *ev)
|
clientmessageevent(XClientMessageEvent *ev)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
int i, mess_t = 0;
|
int s, i, mess_t = 0;
|
||||||
Atom rt;
|
Atom rt;
|
||||||
int rf;
|
int rf;
|
||||||
ulong ir, il;
|
ulong ir, il;
|
||||||
@@ -151,7 +151,9 @@ clientmessageevent(XClientMessageEvent *ev)
|
|||||||
if(ev->format != 32)
|
if(ev->format != 32)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = 0; i < net_last + screen_count(); ++i)
|
s = screen_count();
|
||||||
|
|
||||||
|
for(i = 0; i < net_last + s; ++i)
|
||||||
if(net_atom[i] == ev->message_type)
|
if(net_atom[i] == ev->message_type)
|
||||||
mess_t = i;
|
mess_t = i;
|
||||||
|
|
||||||
@@ -166,7 +168,7 @@ clientmessageevent(XClientMessageEvent *ev)
|
|||||||
/* Manage _WMFS_SET_SCREEN */
|
/* Manage _WMFS_SET_SCREEN */
|
||||||
if(mess_t == wmfs_set_screen
|
if(mess_t == wmfs_set_screen
|
||||||
&& ev->data.l[0] >= 0
|
&& ev->data.l[0] >= 0
|
||||||
&& ev->data.l[0] <= screen_count())
|
&& ev->data.l[0] <= s)
|
||||||
screen_set_sel((int)(ev->data.l[0]));
|
screen_set_sel((int)(ev->data.l[0]));
|
||||||
|
|
||||||
/* Manage _NET_ACTIVE_WINDOW */
|
/* Manage _NET_ACTIVE_WINDOW */
|
||||||
|
|||||||
25
src/ewmh.c
25
src/ewmh.c
@@ -42,12 +42,13 @@
|
|||||||
void
|
void
|
||||||
ewmh_init_hints(void)
|
ewmh_init_hints(void)
|
||||||
{
|
{
|
||||||
int i = 1, j, showing_desk = 0;
|
int i = 1, s, j, showing_desk = 0;
|
||||||
char root_name[] = WMFS_VERSION;
|
char root_name[] = WMFS_VERSION;
|
||||||
char class[] = "wmfs", st[64];
|
char class[] = "wmfs", st[64];
|
||||||
long pid = (long)getpid();
|
long pid = (long)getpid();
|
||||||
|
|
||||||
net_atom = emalloc(net_last + screen_count(), sizeof(Atom));
|
s = screen_count();
|
||||||
|
net_atom = emalloc(net_last + s, sizeof(Atom));
|
||||||
|
|
||||||
/* EWMH hints */
|
/* EWMH hints */
|
||||||
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
|
net_atom[net_supported] = ATOM("_NET_SUPPORTED");
|
||||||
@@ -93,14 +94,14 @@ ewmh_init_hints(void)
|
|||||||
net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
|
net_atom[wmfs_cmd] = ATOM("_WMFS_CMD");
|
||||||
|
|
||||||
/* Multi atom _WMFS_STATUSTEXT_<screennum> */
|
/* Multi atom _WMFS_STATUSTEXT_<screennum> */
|
||||||
for(j = 0; j < screen_count(); ++j)
|
for(j = 0; j < s; ++j)
|
||||||
{
|
{
|
||||||
sprintf(st, "_WMFS_STATUSTEXT_%d", j);
|
sprintf(st, "_WMFS_STATUSTEXT_%d", j);
|
||||||
net_atom[wmfs_statustext + j] = ATOM(st);
|
net_atom[wmfs_statustext + j] = ATOM(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
XChangeProperty(dpy, ROOT, net_atom[net_supported], XA_ATOM, 32,
|
XChangeProperty(dpy, ROOT, net_atom[net_supported], XA_ATOM, 32,
|
||||||
PropModeReplace, (uchar*)net_atom, net_last + screen_count());
|
PropModeReplace, (uchar*)net_atom, net_last + s);
|
||||||
|
|
||||||
XChangeProperty(dpy, ROOT, net_atom[wmfs_running], XA_CARDINAL, 32,
|
XChangeProperty(dpy, ROOT, net_atom[wmfs_running], XA_CARDINAL, 32,
|
||||||
PropModeReplace, (uchar*)&i, 1);
|
PropModeReplace, (uchar*)&i, 1);
|
||||||
@@ -213,15 +214,17 @@ void
|
|||||||
ewmh_get_desktop_names(void)
|
ewmh_get_desktop_names(void)
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
int s, i, len = 0, pos = 0;
|
int S, s, i, len = 0, pos = 0;
|
||||||
|
|
||||||
for(s = 0 ; s < screen_count(); ++s)
|
S = screen_count();
|
||||||
|
|
||||||
|
for(s = 0 ; s < S; ++s)
|
||||||
for(i = 1; i < conf.ntag[s] + 1; ++i)
|
for(i = 1; i < conf.ntag[s] + 1; ++i)
|
||||||
len += strlen(tags[s][i].name);
|
len += strlen(tags[s][i].name);
|
||||||
|
|
||||||
str = emalloc(len + i + 1, sizeof(char*));
|
str = emalloc(len + i + 1, sizeof(char*));
|
||||||
|
|
||||||
for(s = 0; s < screen_count(); ++s)
|
for(s = 0; s < S; ++s)
|
||||||
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
|
for(i = 1; i < conf.ntag[s] + 1; ++i, ++pos)
|
||||||
{
|
{
|
||||||
strncpy(str + pos, tags[s][i].name, strlen(tags[s][i].name));
|
strncpy(str + pos, tags[s][i].name, strlen(tags[s][i].name));
|
||||||
@@ -264,14 +267,16 @@ void
|
|||||||
ewmh_set_workarea(void)
|
ewmh_set_workarea(void)
|
||||||
{
|
{
|
||||||
long *data;
|
long *data;
|
||||||
int i, j, tag_c = 0, pos = 0;
|
int i, s, j, tag_c = 0, pos = 0;
|
||||||
|
|
||||||
for(i = 0; i < screen_count(); ++i)
|
s = screen_count();
|
||||||
|
|
||||||
|
for(i = 0; i < s; ++i)
|
||||||
tag_c += conf.ntag[i];
|
tag_c += conf.ntag[i];
|
||||||
|
|
||||||
data = emalloc(tag_c * 4, sizeof(long));
|
data = emalloc(tag_c * 4, sizeof(long));
|
||||||
|
|
||||||
for(i = 0; i < screen_count(); ++i)
|
for(i = 0; i < s; ++i)
|
||||||
for(j = 0; j < conf.ntag[i]; ++j)
|
for(j = 0; j < conf.ntag[i]; ++j)
|
||||||
{
|
{
|
||||||
data[pos++] = spgeo[i].x;
|
data[pos++] = spgeo[i].x;
|
||||||
|
|||||||
@@ -37,12 +37,14 @@
|
|||||||
void
|
void
|
||||||
infobar_init(void)
|
infobar_init(void)
|
||||||
{
|
{
|
||||||
int sc, i, j;
|
int s, sc, i, j;
|
||||||
|
|
||||||
|
s = screen_count();
|
||||||
|
|
||||||
if(!infobar)
|
if(!infobar)
|
||||||
infobar = emalloc(screen_count(), sizeof(InfoBar));
|
infobar = emalloc(s, sizeof(InfoBar));
|
||||||
|
|
||||||
for(sc = 0; sc < screen_count(); ++sc)
|
for(sc = 0; sc < s; ++sc)
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
infobar[sc].geo.height = INFOBARH;
|
infobar[sc].geo.height = INFOBARH;
|
||||||
@@ -97,7 +99,7 @@ infobar_init(void)
|
|||||||
barwin_refresh(infobar[sc].bar);
|
barwin_refresh(infobar[sc].bar);
|
||||||
|
|
||||||
/* Default statustext is set here */
|
/* Default statustext is set here */
|
||||||
for(i = 0; i < screen_count(); ++i)
|
for(i = 0; i < s; ++i)
|
||||||
infobar[i].statustext = _strdup(WMFS_VERSION);
|
infobar[i].statustext = _strdup(WMFS_VERSION);
|
||||||
infobar_draw(sc);
|
infobar_draw(sc);
|
||||||
}
|
}
|
||||||
@@ -187,7 +189,7 @@ infobar_draw_statustext(int sc, char *str)
|
|||||||
lastst = infobar[sc].statustext;
|
lastst = infobar[sc].statustext;
|
||||||
|
|
||||||
infobar[sc].statustext = _strdup(str);
|
infobar[sc].statustext = _strdup(str);
|
||||||
strcpy(strwc, &str[sizeof(strwc)]);
|
strcpy(strwc, str);
|
||||||
|
|
||||||
/* Count how many color block there is and make a string without color block (\#....\)*/
|
/* Count how many color block there is and make a string without color block (\#....\)*/
|
||||||
for(i = j = c = 0;
|
for(i = j = c = 0;
|
||||||
@@ -220,16 +222,15 @@ infobar_draw_statustext(int sc, char *str)
|
|||||||
{
|
{
|
||||||
/* Store current color in col[] */
|
/* Store current color in col[] */
|
||||||
for(j = 0, ++i; str[i] != '\\'; col[j++] = str[i++]);
|
for(j = 0, ++i; str[i] != '\\'; col[j++] = str[i++]);
|
||||||
strcpy(buf, &buf[k]);
|
|
||||||
|
|
||||||
/* 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),
|
draw_rectangle(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
|
||||||
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(buf),
|
0, INFOBARH - (sgeo[sc].width - SHADH) - textw(&buf[k]),
|
||||||
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),
|
draw_text(infobar[sc].bar->dr, (sgeo[sc].width - SHADH) - textw(&buf[k]),
|
||||||
FHINFOBAR, col, 0, buf);
|
FHINFOBAR, col, 0, &buf[k]);
|
||||||
|
|
||||||
strcpy(buf, strwc);
|
strcpy(buf, strwc);
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
@@ -166,11 +166,12 @@ void
|
|||||||
screen_init_geo(void)
|
screen_init_geo(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int s = screen_count();
|
||||||
|
|
||||||
sgeo = emalloc(screen_count(), sizeof(XRectangle));
|
sgeo = emalloc(s, sizeof(XRectangle));
|
||||||
spgeo = emalloc(screen_count(), sizeof(XRectangle));
|
spgeo = emalloc(s, sizeof(XRectangle));
|
||||||
|
|
||||||
for(i = 0; i < screen_count(); ++i)
|
for(i = 0; i < s; ++i)
|
||||||
sgeo[i] = screen_get_geo(i);
|
sgeo[i] = screen_get_geo(i);
|
||||||
|
|
||||||
spgeo[0].x = 0;
|
spgeo[0].x = 0;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wmfs.h"
|
#include "wmfs.h"
|
||||||
|
|||||||
@@ -210,11 +210,13 @@ scan(void)
|
|||||||
XWindowAttributes wa;
|
XWindowAttributes wa;
|
||||||
Window usl, usl2, *w = NULL;
|
Window usl, usl2, *w = NULL;
|
||||||
Atom rt;
|
Atom rt;
|
||||||
int rf, tag = -1, screen = -1, free = -1;
|
int s, rf, tag = -1, screen = -1, free = -1;
|
||||||
ulong ir, il;
|
ulong ir, il;
|
||||||
uchar *ret;
|
uchar *ret;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
s = screen_count();
|
||||||
|
|
||||||
if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
|
if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n))
|
||||||
for(i = n - 1; i != -1; --i)
|
for(i = n - 1; i != -1; --i)
|
||||||
if(XGetWindowAttributes(dpy, w[i], &wa)
|
if(XGetWindowAttributes(dpy, w[i], &wa)
|
||||||
@@ -246,7 +248,7 @@ scan(void)
|
|||||||
|
|
||||||
if(tag != -1)
|
if(tag != -1)
|
||||||
c->tag = tag;
|
c->tag = tag;
|
||||||
if(screen != -1 && screen <= screen_count() - 1)
|
if(screen != -1 && screen <= s - 1)
|
||||||
c->screen = screen;
|
c->screen = screen;
|
||||||
if(free != -1)
|
if(free != -1)
|
||||||
c->flags |= (free) ? FreeFlag : 0;
|
c->flags |= (free) ? FreeFlag : 0;
|
||||||
@@ -262,7 +264,7 @@ scan(void)
|
|||||||
tags[c->screen][c->tag].request_update = True;
|
tags[c->screen][c->tag].request_update = True;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < screen_count(); ++i)
|
for(i = 0; i < s; ++i)
|
||||||
arrange(i, True);
|
arrange(i, True);
|
||||||
|
|
||||||
XFree(w);
|
XFree(w);
|
||||||
|
|||||||
Reference in New Issue
Block a user