Fix some things, render, code, typo
This commit is contained in:
parent
22c0e81df6
commit
d856ec1012
56
src/bar.c
56
src/bar.c
@ -52,7 +52,7 @@ bar_create(Window parent,
|
||||
|
||||
bw = emalloc(1, sizeof(BarWindow));
|
||||
|
||||
at.override_redirect = 1;
|
||||
at.override_redirect = True;
|
||||
at.background_pixmap = ParentRelative;
|
||||
if(entermask)
|
||||
at.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
@ -91,8 +91,9 @@ bar_create(Window parent,
|
||||
void
|
||||
bar_delete(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XSelectInput(dpy, bw->win, NoEventMask);
|
||||
XDestroySubwindows(dpy, bw->win);
|
||||
XDestroyWindow(dpy, bw->win);
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
free(bw);
|
||||
@ -100,6 +101,19 @@ bar_delete(BarWindow *bw)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Delete the BarWindow sub windows
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_delete_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XDestroySubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Map a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
@ -109,13 +123,27 @@ bar_map(BarWindow *bw)
|
||||
CHECK(!bw->mapped);
|
||||
|
||||
XMapWindow(dpy, bw->win);
|
||||
XMapSubwindows(dpy, bw->win);
|
||||
|
||||
bw->mapped = True;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** Map the subwindows of a BarWindow
|
||||
* Use for the BarWindow special border...
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_map_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XMapSubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Unmap a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
@ -124,7 +152,6 @@ bar_unmap(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw->mapped);
|
||||
|
||||
XUnmapSubwindows(dpy, bw->win);
|
||||
XUnmapWindow(dpy, bw->win);
|
||||
|
||||
bw->mapped = False;
|
||||
@ -132,6 +159,19 @@ bar_unmap(BarWindow *bw)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Unmap the BarWindow sub windows
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_unmap_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XUnmapSubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Move a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
* \param x X position
|
||||
@ -140,6 +180,8 @@ bar_unmap(BarWindow *bw)
|
||||
void
|
||||
bar_move(BarWindow *bw, int x, int y)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
bw->geo.x = x;
|
||||
bw->geo.y = y;
|
||||
|
||||
@ -156,6 +198,8 @@ bar_move(BarWindow *bw, int x, int y)
|
||||
void
|
||||
bar_resize(BarWindow *bw, uint w, uint h)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
bw->geo.width = w;
|
||||
bw->geo.height = h;
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
@ -180,6 +224,8 @@ bar_resize(BarWindow *bw, uint w, uint h)
|
||||
void
|
||||
bar_refresh_color(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
draw_rectangle(bw->dr, 0, 0, bw->geo.width, bw->geo.height, bw->color);
|
||||
|
||||
XSetWindowBackground(dpy, bw->border.left , bw->border.light);
|
||||
@ -201,6 +247,8 @@ bar_refresh_color(BarWindow *bw)
|
||||
void
|
||||
bar_refresh(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->geo.width, bw->geo.height, 0, 0);
|
||||
|
||||
return;
|
||||
|
||||
37
src/client.c
37
src/client.c
@ -223,6 +223,9 @@ client_focus(Client *c)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if(!TBARH)
|
||||
return NULL;
|
||||
|
||||
for(c = clients; c && c->titlebar->win != w; c = c->next);
|
||||
|
||||
return c;
|
||||
@ -313,7 +316,11 @@ client_map(Client *c)
|
||||
|
||||
XMapWindow(dpy, c->frame);
|
||||
XMapSubwindows(dpy, c->frame);
|
||||
bar_map(c->titlebar);
|
||||
if(TBARH)
|
||||
{
|
||||
bar_map(c->titlebar);
|
||||
bar_map_subwin(c->titlebar);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -340,7 +347,6 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
frame_create(c);
|
||||
XSelectInput(dpy, c->win, PropertyChangeMask | StructureNotifyMask);
|
||||
mouse_grabbuttons(c, False);
|
||||
client_size_hints(c);
|
||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
if(t) c->tag = t->tag;
|
||||
@ -348,6 +354,7 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
efree(t);
|
||||
|
||||
client_attach(c);
|
||||
client_size_hints(c);
|
||||
client_map(c);
|
||||
client_get_name(c);
|
||||
client_raise(c);
|
||||
@ -373,9 +380,9 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
||||
if(r)
|
||||
{
|
||||
/* minimum possible */
|
||||
if (geo.width < 1)
|
||||
if(geo.width < 1)
|
||||
geo.width = 1;
|
||||
if (geo.height < 1)
|
||||
if(geo.height < 1)
|
||||
geo.height = 1;
|
||||
|
||||
/* base */
|
||||
@ -383,12 +390,12 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
||||
geo.height -= c->baseh;
|
||||
|
||||
/* aspect */
|
||||
if (c->minay > 0 && c->maxay > 0
|
||||
if(c->minay > 0 && c->maxay > 0
|
||||
&& c->minax > 0 && c->maxax > 0)
|
||||
{
|
||||
if (geo.width * c->maxay > geo.height * c->maxax)
|
||||
if(geo.width * c->maxay > geo.height * c->maxax)
|
||||
geo.width = geo.height * c->maxax / c->maxay;
|
||||
else if (geo.width * c->minay < geo.height * c->minax)
|
||||
else if(geo.width * c->minay < geo.height * c->minax)
|
||||
geo.height = geo.width * c->minay / c->minax;
|
||||
}
|
||||
|
||||
@ -423,7 +430,7 @@ client_moveresize(Client *c, XRectangle geo, bool r)
|
||||
{
|
||||
c->geo = geo;
|
||||
frame_moveresize(c, geo);
|
||||
XResizeWindow(dpy, c->win, geo.width, geo.height);
|
||||
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, geo.width, geo.height);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
@ -550,6 +557,7 @@ client_unmanage(Client *c)
|
||||
int i;
|
||||
Client *cc;
|
||||
|
||||
XGrabServer(dpy);
|
||||
XSetErrorHandler(errorhandlerdummy);
|
||||
|
||||
/* Unset all focus stuff {{{ */
|
||||
@ -564,10 +572,15 @@ client_unmanage(Client *c)
|
||||
setwinstate(c->win, WithdrawnState);
|
||||
XDestroySubwindows(dpy, c->frame);
|
||||
XDestroyWindow(dpy, c->frame);
|
||||
bar_delete(c->titlebar);
|
||||
if(TBARH)
|
||||
{
|
||||
bar_delete_subwin(c->titlebar);
|
||||
bar_delete(c->titlebar);
|
||||
}
|
||||
XFree(c->title);
|
||||
efree(c);
|
||||
XSync(dpy, False);
|
||||
XUngrabServer(dpy);
|
||||
arrange();
|
||||
|
||||
return;
|
||||
@ -583,7 +596,11 @@ client_unmap(Client *c)
|
||||
|
||||
XUnmapWindow(dpy, c->frame);
|
||||
XUnmapSubwindows(dpy, c->frame);
|
||||
bar_unmap(c->titlebar);
|
||||
if(TBARH)
|
||||
{
|
||||
bar_unmap_subwin(c->titlebar);
|
||||
bar_unmap(c->titlebar);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
26
src/event.c
26
src/event.c
@ -121,25 +121,20 @@ configurerequest(XConfigureRequestEvent *ev)
|
||||
geo.width = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
geo.height = ev->height;
|
||||
|
||||
if((ev->value_mask & (CWX | CWY))
|
||||
&& !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
client_configure(c);
|
||||
if(geo.x != c->geo.x
|
||||
|| geo.y != c->geo.y
|
||||
|| geo.width != c->geo.width
|
||||
|| geo.height != c->geo.height)
|
||||
{
|
||||
/*
|
||||
* Adjust the client's future geo to
|
||||
* set the correct position of the frame
|
||||
*/
|
||||
geo.x += BORDH;
|
||||
geo.y += TBARH;
|
||||
/* Resize */
|
||||
if((geo.x < MAXW && geo.x > geo.width)
|
||||
&& geo.y < MAXH && geo.y > geo.height)
|
||||
if((geo.x < MAXW && geo.x > 0 - geo.width)
|
||||
&& (geo.y < MAXH && geo.y > 0 - geo.height))
|
||||
client_moveresize(c, geo, True);
|
||||
}
|
||||
else
|
||||
client_configure(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -150,8 +145,10 @@ configurerequest(XConfigureRequestEvent *ev)
|
||||
wc.border_width = ev->border_width;
|
||||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
}
|
||||
}
|
||||
|
||||
XSync(dpy, False);
|
||||
|
||||
return;
|
||||
@ -164,6 +161,7 @@ void
|
||||
destroynotify(XDestroyWindowEvent *ev)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if((c = client_gb_win(ev->window)))
|
||||
client_unmanage(c);
|
||||
|
||||
@ -203,14 +201,14 @@ expose(XExposeEvent *ev)
|
||||
|
||||
if(ev->count == 0
|
||||
&& (ev->window == infobar->bar->win))
|
||||
infobar_draw();
|
||||
bar_refresh(infobar->bar);
|
||||
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
if(ev->window == infobar->tags[i]->win)
|
||||
infobar_draw_taglist();
|
||||
bar_refresh(infobar->tags[i]);
|
||||
|
||||
if(ev->window == infobar->layout_button->win)
|
||||
infobar_draw_layout();
|
||||
bar_refresh(infobar->layout_button);
|
||||
|
||||
if((c = client_gb_titlebar(ev->window)))
|
||||
frame_update(c);
|
||||
|
||||
@ -158,7 +158,7 @@ frame_update(Client *c)
|
||||
XClearWindow(dpy, c->right);
|
||||
XClearWindow(dpy, c->bottom);
|
||||
|
||||
if((TBARH + BORDH + 1) > font->height)
|
||||
if(TBARH && (TBARH + BORDH + 1) > font->height)
|
||||
{
|
||||
draw_text(c->titlebar->dr,
|
||||
(c->frame_geo.width / 2) - (textw(c->title) / 2),
|
||||
|
||||
@ -53,7 +53,7 @@ infobar_init(void)
|
||||
infobar->tags[i] = bar_create(infobar->bar->win, j, 0, textw(tags[i].name) + PAD,
|
||||
infobar->geo.height, conf.colors.bar, False);
|
||||
j += textw(tags[i].name) + PAD;
|
||||
XMapSubwindows(dpy, infobar->tags[i]->win);
|
||||
bar_map_subwin(infobar->tags[i]);
|
||||
}
|
||||
|
||||
/* Create layout switch & layout type switch barwindow */
|
||||
@ -61,11 +61,12 @@ infobar_init(void)
|
||||
textw(tags[seltag].layout.symbol) + PAD,
|
||||
infobar->geo.height, conf.colors.layout_bg, False);
|
||||
|
||||
/* Map all */
|
||||
/* Map/Refresh all */
|
||||
bar_map(infobar->bar);
|
||||
bar_map_subwin(infobar->bar);
|
||||
bar_map_subwin(infobar->layout_button);
|
||||
bar_refresh_color(infobar->bar);
|
||||
bar_refresh(infobar->bar);
|
||||
XMapSubwindows(dpy, infobar->layout_button->win);
|
||||
|
||||
strcpy(infobar->statustext, "WMFS-" WMFS_VERSION);
|
||||
infobar_draw();
|
||||
@ -135,12 +136,15 @@ infobar_destroy(void)
|
||||
int i;
|
||||
|
||||
bar_delete(infobar->bar);
|
||||
bar_delete_subwin(infobar->bar);
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
{
|
||||
XFreePixmap(dpy, infobar->tags[i]->dr);
|
||||
XDestroySubwindows(dpy, infobar->tags[i]->win);
|
||||
bar_delete_subwin(infobar->tags[i]);
|
||||
bar_delete(infobar->tags[i]);
|
||||
}
|
||||
XDestroySubwindows(dpy, infobar->layout_button->win);
|
||||
bar_delete(infobar->layout_button);
|
||||
bar_delete_subwin(infobar->layout_button);
|
||||
efree(infobar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
45
src/init.c
45
src/init.c
@ -38,18 +38,16 @@ void
|
||||
init(void)
|
||||
{
|
||||
/* First init */
|
||||
XSetErrorHandler(errorhandlerdummy);
|
||||
gc = DefaultGC(dpy, screen);
|
||||
screen = DefaultScreen(dpy);
|
||||
init_font();
|
||||
init_cursor();
|
||||
init_key();
|
||||
init_atom();
|
||||
init_root();
|
||||
init_atom();
|
||||
infobar_init();
|
||||
init_geometry();
|
||||
grabkeys();
|
||||
XSetErrorHandler(errorhandler);
|
||||
|
||||
/* Warning about font */
|
||||
if(TBARH + BORDH < font->height)
|
||||
@ -106,6 +104,26 @@ init_key(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Init root Window
|
||||
*/
|
||||
void
|
||||
init_root(void)
|
||||
{
|
||||
XSetWindowAttributes at;
|
||||
|
||||
root = RootWindow(dpy, screen);
|
||||
|
||||
at.event_mask = KeyMask | ButtonPressMask | ButtonReleaseMask |
|
||||
SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
EnterWindowMask | LeaveWindowMask | StructureNotifyMask ;
|
||||
at.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &at);
|
||||
if(conf.root.background_command)
|
||||
uicb_spawn(conf.root.background_command);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Init atoms
|
||||
*/
|
||||
void
|
||||
@ -117,31 +135,12 @@ init_atom(void)
|
||||
wm_atom[WMName] = XInternAtom(dpy, "WM_NAME", False);
|
||||
net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
|
||||
net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||
|
||||
XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *) net_atom, NetLast);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Init root Window
|
||||
*/
|
||||
void
|
||||
init_root(void)
|
||||
{
|
||||
XSetWindowAttributes at;
|
||||
|
||||
root = RootWindow (dpy, screen);
|
||||
|
||||
at.event_mask = KeyMask | ButtonPressMask | ButtonReleaseMask |
|
||||
SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
EnterWindowMask | LeaveWindowMask | StructureNotifyMask ;
|
||||
at.cursor = cursor[CurNormal];
|
||||
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &at);
|
||||
if(conf.root.background_command)
|
||||
uicb_spawn(conf.root.background_command);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Init screen geometry
|
||||
*/
|
||||
void
|
||||
|
||||
@ -186,7 +186,7 @@ uicb_set_mwfact(uicb_t cmd)
|
||||
return;
|
||||
|
||||
tags[seltag].mwfact += c;
|
||||
arrange();
|
||||
tags[seltag].layout.func();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -207,7 +207,7 @@ uicb_set_nmaster(uicb_t cmd)
|
||||
return;
|
||||
|
||||
tags[seltag].nmaster += n;
|
||||
arrange();
|
||||
tags[seltag].layout.func();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -456,7 +456,7 @@ uicb_tile_switch(uicb_t cmd)
|
||||
client_detach(c);
|
||||
client_attach(c);
|
||||
client_focus(c);
|
||||
arrange();
|
||||
tags[seltag].layout.func();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -474,8 +474,7 @@ uicb_togglefree(uicb_t cmd)
|
||||
sel->max = False;
|
||||
sel->lmax = False;
|
||||
client_moveresize(sel, sel->ogeo, True);
|
||||
|
||||
arrange();
|
||||
tags[seltag].layout.func();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,8 +163,7 @@ mouse_resize(Client *c)
|
||||
mwf = tags[seltag].mwfact;
|
||||
|
||||
tags[seltag].mwfact = (mwf < 0.05) ? 0.05 : ((mwf > 0.95) ? 0.95 : mwf);
|
||||
|
||||
arrange();
|
||||
tags[seltag].layout.func();
|
||||
}
|
||||
|
||||
if(!c->tile)
|
||||
|
||||
@ -55,11 +55,10 @@ typedef enum { CloseButton = 0, MaxButton = 1, FreeButton = 2, LastButton } Butt
|
||||
|
||||
/*
|
||||
* BarWindow Structure
|
||||
* (titlebar, topbar..)
|
||||
* (titlebar, infobar..)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Frame window */
|
||||
Window win;
|
||||
Drawable dr;
|
||||
struct
|
||||
@ -143,7 +142,6 @@ typedef struct
|
||||
void (*func)(void);
|
||||
} Layout;
|
||||
|
||||
|
||||
/* Tag Structure */
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@ -73,7 +73,6 @@ quit(void)
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
infobar_destroy();
|
||||
efree(infobar);
|
||||
efree(keys);
|
||||
efree(conf.titlebar.mouse);
|
||||
efree(conf.client.mouse);
|
||||
|
||||
@ -89,8 +89,11 @@
|
||||
/* bar.c */
|
||||
BarWindow *bar_create(Window parent, int x, int y, uint w, uint h, uint color, Bool entermask);
|
||||
void bar_delete(BarWindow *bw);
|
||||
void bar_delete_subwin(BarWindow *bw);
|
||||
void bar_map(BarWindow *bw);
|
||||
void bar_map_subwin(BarWindow *bw);
|
||||
void bar_unmap(BarWindow *bw);
|
||||
void bar_unmap_subwin(BarWindow *bw);
|
||||
void bar_move(BarWindow *bw, int x, int y);
|
||||
void bar_resize(BarWindow *bw, uint w, uint h);
|
||||
void bar_refresh_color(BarWindow *bw);
|
||||
@ -206,10 +209,10 @@ void uicb_set_nmaster(uicb_t);
|
||||
|
||||
/* init.c */
|
||||
void init(void);
|
||||
void init_root(void);
|
||||
void init_atom(void);
|
||||
void init_font(void);
|
||||
void init_cursor(void);
|
||||
void init_root(void);
|
||||
void init_key(void);
|
||||
void init_geometry(void);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user