ewmh: Replace array by pointer in ewmh_set_workarea (thanks drmax)

This commit is contained in:
Martin Duquesnoy 2008-12-15 03:16:14 +01:00
parent a0c857602f
commit 4594561647
4 changed files with 19 additions and 6 deletions

View File

@ -434,7 +434,8 @@ client_manage(Window w, XWindowAttributes *wa)
void
client_moveresize(Client *c, XRectangle geo, bool r)
{
CHECK(c);
if(!c || c->state_dock)
return;
/* Resize hints {{{ */
if(r)

View File

@ -47,6 +47,7 @@ ewmh_init_hints(void)
net_atom[net_number_of_desktops] = ATOM("_NET_NUMBER_OF_DESKTOPS");
net_atom[net_current_desktop] = ATOM("_NET_CURRENT_DESKTOP");
net_atom[net_desktop_names] = ATOM("_NET_DESKTOP_NAMES");
net_atom[net_desktop_names_string] = ATOM("_NET_DESKTOP_NAMES_STRING");
net_atom[net_desktop_geometry] = ATOM("_NET_DESKTOP_GEOMETRY");
net_atom[net_workarea] = ATOM("_NET_WORKAREA");
net_atom[net_active_window] = ATOM("_NET_ACTIVE_WINDOW");
@ -153,6 +154,9 @@ ewmh_get_desktop_names(void)
XChangeProperty(dpy, ROOT, net_atom[net_desktop_names], net_atom[utf8_string], 8,
PropModeReplace, (uchar*)str, pos);
XChangeProperty(dpy, ROOT, net_atom[net_desktop_names_string], XA_STRING, 8,
PropModeReplace, (uchar*)str, pos);
free(str);
return;
@ -177,12 +181,14 @@ ewmh_set_desktop_geometry(void)
void
ewmh_set_workarea(void)
{
long data[4 * 1024] = { 0 }; /* Array [] because dynamic alloc seems doesn't work */
long *data;
int i, j, tag_c = 0, pos = 0;
for(i = 0; i < screen_count(); ++i)
tag_c += conf.ntag[i];
data = emalloc(tag_c * 4, sizeof(long));
for(i = 0; i < screen_count(); ++i)
for(j = 0; j < conf.ntag[i]; ++j)
{
@ -193,8 +199,9 @@ ewmh_set_workarea(void)
}
XChangeProperty(dpy, ROOT, net_atom[net_workarea], XA_CARDINAL, 32,
PropModeReplace, (uchar*)&data, 4 * tag_c);
PropModeReplace, (uchar*)data, 4 * tag_c);
free(data);
return;
}
@ -264,6 +271,7 @@ ewmh_manage_window_type(Client *c)
XUnmapSubwindows(dpy, c->frame);
XUnmapWindow(dpy, c->frame);
XRaiseWindow(dpy, c->win);
c->state_dock = True;
}
/* MANAGE _NET_WM_WINDOW_TYPE_DIALOG */
else if(atom[i] == net_atom[net_wm_window_type_dialog])

View File

@ -46,7 +46,8 @@ mouse_move(Client *c)
XRectangle geo = c->geo;
XEvent ev;
if(c->max || c->tile || c->lmax || c->state_fullscreen)
if(c->max || c->tile || c->lmax
|| c->state_fullscreen || c->state_dock)
return;
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync,
@ -91,7 +92,8 @@ mouse_resize(Client *c)
XRectangle geo = c->geo;
XEvent ev;
if(c->max || c->lmax || c->tile || c->state_fullscreen)
if(c->max || c->lmax || c->tile
|| c->state_fullscreen || c->state_dock)
return;
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync,

View File

@ -57,6 +57,7 @@ enum
net_number_of_desktops,
net_current_desktop,
net_desktop_names,
net_desktop_names_string,
net_desktop_geometry,
net_workarea,
net_active_window,
@ -132,7 +133,8 @@ struct Client
} colors;
/* Client Layout Information */
Bool max, tile, free, hide;
Bool hint, lmax, unmapped, state_fullscreen;
Bool hint, lmax, unmapped;
Bool state_dock, state_fullscreen;
/* Struct in chains */
Client *next;
Client *prev;