Skip to content

Commit

Permalink
cvsimport
Browse files Browse the repository at this point in the history
  • Loading branch information
leahneukirchen committed Jul 1, 2015
2 parents 4454948 + 8efaf33 commit 6716719
Show file tree
Hide file tree
Showing 11 changed files with 246 additions and 215 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -14,11 +14,11 @@ OBJS= calmwm.o screen.o xmalloc.o client.o menu.o \
kbfunc.o mousefunc.o strlcpy.o strlcat.o y.tab.o \
strtonum.o fgetln.o reallocarray.o

CPPFLAGS+= `pkg-config --cflags fontconfig x11 xft xinerama xrandr`
CPPFLAGS+= `pkg-config --cflags fontconfig x11 xft xrandr`

CFLAGS?= -Wall -O2 -g -D_GNU_SOURCE

LDFLAGS+= `pkg-config --libs fontconfig x11 xft xinerama xrandr`
LDFLAGS+= `pkg-config --libs fontconfig x11 xft xrandr`

MANPREFIX?= ${PREFIX}/share/man

Expand Down
6 changes: 3 additions & 3 deletions calmwm.h
Expand Up @@ -49,7 +49,6 @@ size_t strlcpy(char *, const char *, size_t);
#include <X11/Xproto.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <X11/extensions/Xinerama.h>
#include <X11/extensions/Xrandr.h>
#include <X11/keysym.h>

Expand Down Expand Up @@ -471,10 +470,11 @@ void search_match_path_any(struct menu_q *, struct menu_q *,
void search_match_text(struct menu_q *, struct menu_q *,
char *);
void search_print_client(struct menu *, int);
void search_print_cmd(struct menu *, int);

struct geom screen_apply_gap(struct screen_ctx *, struct geom);
struct screen_ctx *screen_find(Window);
struct geom screen_find_xinerama(struct screen_ctx *,
int, int, int);
struct geom screen_area(struct screen_ctx *, int, int, int);
void screen_init(int);
void screen_update_geometry(struct screen_ctx *);
void screen_updatestackingorder(struct screen_ctx *);
Expand Down
152 changes: 76 additions & 76 deletions client.c
Expand Up @@ -21,7 +21,6 @@
#include <sys/types.h>
#include "queue.h"

#include <assert.h>
#include <err.h>
#include <errno.h>
#include <limits.h>
Expand All @@ -43,21 +42,6 @@ static int client_inbound(struct client_ctx *, int, int);

struct client_ctx *curcc = NULL;

struct client_ctx *
client_find(Window win)
{
struct screen_ctx *sc;
struct client_ctx *cc;

TAILQ_FOREACH(sc, &Screenq, entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->win == win)
return(cc);
}
}
return(NULL);
}

struct client_ctx *
client_init(Window win, struct screen_ctx *sc)
{
Expand All @@ -71,7 +55,8 @@ client_init(Window win, struct screen_ctx *sc)
return(NULL);

if (sc == NULL) {
sc = screen_find(wattr.root);
if ((sc = screen_find(wattr.root)) == NULL)
return(NULL);
mapped = 1;
} else {
if (wattr.override_redirect || wattr.map_state != IsViewable)
Expand Down Expand Up @@ -143,6 +128,21 @@ client_init(Window win, struct screen_ctx *sc)
return(cc);
}

struct client_ctx *
client_find(Window win)
{
struct screen_ctx *sc;
struct client_ctx *cc;

TAILQ_FOREACH(sc, &Screenq, entry) {
TAILQ_FOREACH(cc, &sc->clientq, entry) {
if (cc->win == win)
return(cc);
}
}
return(NULL);
}

void
client_delete(struct client_ctx *cc)
{
Expand Down Expand Up @@ -265,7 +265,7 @@ void
client_toggle_fullscreen(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;

if ((cc->flags & CLIENT_FREEZE) &&
!(cc->flags & CLIENT_FULLSCREEN))
Expand All @@ -280,12 +280,12 @@ client_toggle_fullscreen(struct client_ctx *cc)

cc->fullgeom = cc->geom;

xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_NOGAP);

cc->bwidth = 0;
cc->geom = xine;
cc->geom = area;
cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);

resize:
Expand All @@ -297,7 +297,7 @@ void
client_toggle_maximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;

if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
Expand All @@ -323,14 +323,14 @@ client_toggle_maximize(struct client_ctx *cc)
* that's probably more fair than if just the origin of
* a window is poking over a boundary
*/
xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);

cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.w = area.w - (cc->bwidth * 2);
cc->geom.h = area.h - (cc->bwidth * 2);
cc->flags |= CLIENT_MAXIMIZED;

resize:
Expand All @@ -342,7 +342,7 @@ void
client_toggle_vmaximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;

if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
Expand All @@ -357,12 +357,12 @@ client_toggle_vmaximize(struct client_ctx *cc)
cc->savegeom.y = cc->geom.y;
cc->savegeom.h = cc->geom.h;

xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);

cc->geom.y = xine.y;
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.y = area.y;
cc->geom.h = area.h - (cc->bwidth * 2);
cc->flags |= CLIENT_VMAXIMIZED;

resize:
Expand All @@ -374,7 +374,7 @@ void
client_toggle_hmaximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;

if (cc->flags & (CLIENT_FREEZE|CLIENT_STICKY))
return;
Expand All @@ -389,12 +389,12 @@ client_toggle_hmaximize(struct client_ctx *cc)
cc->savegeom.x = cc->geom.x;
cc->savegeom.w = cc->geom.w;

xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);

cc->geom.x = xine.x;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.w = area.w - (cc->bwidth * 2);
cc->flags |= CLIENT_HMAXIMIZED;

resize:
Expand Down Expand Up @@ -635,8 +635,8 @@ client_setname(struct client_ctx *cc)

/* Now, do some garbage collection. */
if (cc->nameqlen > CLIENT_MAXNAMEQLEN) {
wn = TAILQ_FIRST(&cc->nameq);
assert(wn != NULL);
if ((wn = TAILQ_FIRST(&cc->nameq)) == NULL)
errx(1, "client_setname: window name queue empty");
TAILQ_REMOVE(&cc->nameq, wn, entry);
free(wn->name);
free(wn);
Expand Down Expand Up @@ -740,33 +740,33 @@ client_placecalc(struct client_ctx *cc)
cc->geom.x = MIN(cc->geom.x, xslack);
cc->geom.y = MIN(cc->geom.y, yslack);
} else {
struct geom xine;
struct geom area;
int xmouse, ymouse;

xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
xine = screen_find_xinerama(sc, xmouse, ymouse, CWM_GAP);
xine.w += xine.x;
xine.h += xine.y;
xmouse = MAX(xmouse, xine.x) - cc->geom.w / 2;
ymouse = MAX(ymouse, xine.y) - cc->geom.h / 2;
area = screen_area(sc, xmouse, ymouse, CWM_GAP);
area.w += area.x;
area.h += area.y;
xmouse = MAX(xmouse, area.x) - cc->geom.w / 2;
ymouse = MAX(ymouse, area.y) - cc->geom.h / 2;

xmouse = MAX(xmouse, xine.x);
ymouse = MAX(ymouse, xine.y);
xmouse = MAX(xmouse, area.x);
ymouse = MAX(ymouse, area.y);

xslack = xine.w - cc->geom.w - cc->bwidth * 2;
yslack = xine.h - cc->geom.h - cc->bwidth * 2;
xslack = area.w - cc->geom.w - cc->bwidth * 2;
yslack = area.h - cc->geom.h - cc->bwidth * 2;

if (xslack >= xine.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), xine.x);
if (xslack >= area.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
} else {
cc->geom.x = xine.x;
cc->geom.w = xine.w;
cc->geom.x = area.x;
cc->geom.w = area.w;
}
if (yslack >= xine.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), xine.y);
if (yslack >= area.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
} else {
cc->geom.y = xine.y;
cc->geom.h = xine.h;
cc->geom.y = area.y;
cc->geom.h = area.h;
}
}
}
Expand Down Expand Up @@ -949,7 +949,7 @@ client_htile(struct client_ctx *cc)
struct client_ctx *ci;
struct group_ctx *gc = cc->group;
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int i, n, mh, x, h, w;

if (!gc)
Expand All @@ -965,36 +965,36 @@ client_htile(struct client_ctx *cc)
if (n == 0)
return;

xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);

if (cc->flags & CLIENT_VMAXIMIZED ||
cc->geom.h + (cc->bwidth * 2) >= xine.h)
cc->geom.h + (cc->bwidth * 2) >= area.h)
return;

cc->flags &= ~CLIENT_HMAXIMIZED;
cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.w = xine.w - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.w = area.w - (cc->bwidth * 2);
client_resize(cc, 1);
client_ptrwarp(cc);

mh = cc->geom.h + (cc->bwidth * 2);
x = xine.x;
w = xine.w / n;
h = xine.h - mh;
x = area.x;
w = area.w / n;
h = area.h - mh;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc))
continue;
ci->bwidth = Conf.bwidth;
ci->geom.y = xine.y + mh;
ci->geom.y = area.y + mh;
ci->geom.x = x;
ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n)
ci->geom.w = xine.x + xine.w -
ci->geom.w = area.x + area.w -
ci->geom.x - (ci->bwidth * 2);
x += w;
client_resize(ci, 1);
Expand All @@ -1008,7 +1008,7 @@ client_vtile(struct client_ctx *cc)
struct client_ctx *ci;
struct group_ctx *gc = cc->group;
struct screen_ctx *sc = cc->sc;
struct geom xine;
struct geom area;
int i, n, mw, y, h, w;

if (!gc)
Expand All @@ -1024,36 +1024,36 @@ client_vtile(struct client_ctx *cc)
if (n == 0)
return;

xine = screen_find_xinerama(sc,
area = screen_area(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);

if (cc->flags & CLIENT_HMAXIMIZED ||
cc->geom.w + (cc->bwidth * 2) >= xine.w)
cc->geom.w + (cc->bwidth * 2) >= area.w)
return;

cc->flags &= ~CLIENT_VMAXIMIZED;
cc->geom.x = xine.x;
cc->geom.y = xine.y;
cc->geom.h = xine.h - (cc->bwidth * 2);
cc->geom.x = area.x;
cc->geom.y = area.y;
cc->geom.h = area.h - (cc->bwidth * 2);
client_resize(cc, 1);
client_ptrwarp(cc);

mw = cc->geom.w + (cc->bwidth * 2);
y = xine.y;
h = xine.h / n;
w = xine.w - mw;
y = area.y;
h = area.h / n;
w = area.w - mw;
TAILQ_FOREACH(ci, &gc->clientq, group_entry) {
if (ci->flags & CLIENT_HIDDEN ||
ci->flags & CLIENT_IGNORE || (ci == cc))
continue;
ci->bwidth = Conf.bwidth;
ci->geom.y = y;
ci->geom.x = xine.x + mw;
ci->geom.x = area.x + mw;
ci->geom.h = h - (ci->bwidth * 2);
ci->geom.w = w - (ci->bwidth * 2);
if (i + 1 == n)
ci->geom.h = xine.y + xine.h -
ci->geom.h = area.y + area.h -
ci->geom.y - (ci->bwidth * 2);
y += h;
client_resize(ci, 1);
Expand Down

0 comments on commit 6716719

Please sign in to comment.