mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
*sigh* Revert the diff that wasn't meant to go in yet.
note to self: When you mean to type cvs commit search.c, don't forget the filename.
This commit is contained in:
parent
61601991b5
commit
60a88f54cc
2
Makefile
2
Makefile
@ -11,7 +11,7 @@ SRCS= calmwm.c screen.c xmalloc.c client.c grab.c menu.c \
|
|||||||
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR}
|
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR}
|
||||||
|
|
||||||
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lXau -lXdmcp -lXext \
|
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lXau -lXdmcp -lXext \
|
||||||
-lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr
|
-lfontconfig -lexpat -lfreetype -lz
|
||||||
|
|
||||||
MANDIR= ${X11BASE}/man/cat
|
MANDIR= ${X11BASE}/man/cat
|
||||||
MAN= cwm.1 cwmrc.5
|
MAN= cwm.1 cwmrc.5
|
||||||
|
18
calmwm.c
18
calmwm.c
@ -36,7 +36,6 @@ u_int Nscreens;
|
|||||||
struct client_ctx_q Clientq;
|
struct client_ctx_q Clientq;
|
||||||
|
|
||||||
int Doshape, Shape_ev;
|
int Doshape, Shape_ev;
|
||||||
int HasXinerama, HasRandr, Randr_ev;
|
|
||||||
int Starting;
|
int Starting;
|
||||||
struct conf Conf;
|
struct conf Conf;
|
||||||
|
|
||||||
@ -122,8 +121,6 @@ dpy_init(const char *dpyname)
|
|||||||
|
|
||||||
Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
|
Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
|
||||||
|
|
||||||
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
|
|
||||||
|
|
||||||
TAILQ_INIT(&Screenq);
|
TAILQ_INIT(&Screenq);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +133,7 @@ x_setup(void)
|
|||||||
|
|
||||||
Nscreens = ScreenCount(X_Dpy);
|
Nscreens = ScreenCount(X_Dpy);
|
||||||
for (i = 0; i < (int)Nscreens; i++) {
|
for (i = 0; i < (int)Nscreens; i++) {
|
||||||
XCALLOC(sc, struct screen_ctx);
|
XMALLOC(sc, struct screen_ctx);
|
||||||
x_setupscreen(sc, i);
|
x_setupscreen(sc, i);
|
||||||
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
TAILQ_INSERT_TAIL(&Screenq, sc, entry);
|
||||||
}
|
}
|
||||||
@ -164,7 +161,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
Window *wins, w0, w1;
|
Window *wins, w0, w1;
|
||||||
XWindowAttributes winattr;
|
XWindowAttributes winattr;
|
||||||
XSetWindowAttributes rootattr;
|
XSetWindowAttributes rootattr;
|
||||||
int fake;
|
|
||||||
u_int nwins, i;
|
u_int nwins, i;
|
||||||
|
|
||||||
Curscreen = sc;
|
Curscreen = sc;
|
||||||
@ -250,18 +246,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
|||||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||||
CWEventMask, &rootattr);
|
CWEventMask, &rootattr);
|
||||||
|
|
||||||
if (XineramaQueryExtension(X_Dpy, &fake, &fake) == 1 &&
|
|
||||||
((HasXinerama = XineramaIsActive(X_Dpy)) == 1))
|
|
||||||
HasXinerama = 1;
|
|
||||||
if (HasRandr)
|
|
||||||
XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
|
|
||||||
/*
|
|
||||||
* initial setup of xinerama screens, if we're using RandR then we'll
|
|
||||||
* redo this whenever the screen changes since a CTRC may have been
|
|
||||||
* added or removed
|
|
||||||
*/
|
|
||||||
screen_init_xinerama(sc);
|
|
||||||
|
|
||||||
XSync(X_Dpy, False);
|
XSync(X_Dpy, False);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
7
calmwm.h
7
calmwm.h
@ -62,9 +62,6 @@ struct screen_ctx {
|
|||||||
|
|
||||||
XftDraw *xftdraw;
|
XftDraw *xftdraw;
|
||||||
XftColor xftcolor;
|
XftColor xftcolor;
|
||||||
|
|
||||||
int xinerama_no;
|
|
||||||
XineramaScreenInfo *xinerama;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
||||||
@ -372,7 +369,6 @@ void xev_handle_keyrelease(struct xevent *, XEvent *);
|
|||||||
void xev_handle_expose(struct xevent *, XEvent *);
|
void xev_handle_expose(struct xevent *, XEvent *);
|
||||||
void xev_handle_clientmessage(struct xevent *, XEvent *);
|
void xev_handle_clientmessage(struct xevent *, XEvent *);
|
||||||
void xev_handle_shape(struct xevent *, XEvent *);
|
void xev_handle_shape(struct xevent *, XEvent *);
|
||||||
void xev_handle_randr(struct xevent *, XEvent *);
|
|
||||||
void xev_handle_mapping(struct xevent *, XEvent *);
|
void xev_handle_mapping(struct xevent *, XEvent *);
|
||||||
|
|
||||||
#define XEV_QUICK(a, b, c, d, e) do { \
|
#define XEV_QUICK(a, b, c, d, e) do { \
|
||||||
@ -421,7 +417,6 @@ char *xstrdup(const char *);
|
|||||||
struct screen_ctx *screen_fromroot(Window);
|
struct screen_ctx *screen_fromroot(Window);
|
||||||
struct screen_ctx *screen_current(void);
|
struct screen_ctx *screen_current(void);
|
||||||
void screen_updatestackingorder(void);
|
void screen_updatestackingorder(void);
|
||||||
void screen_init_xinerama(struct screen_ctx *);
|
|
||||||
|
|
||||||
void conf_setup(struct conf *, const char *);
|
void conf_setup(struct conf *, const char *);
|
||||||
void conf_client(struct client_ctx *);
|
void conf_client(struct client_ctx *);
|
||||||
@ -517,8 +512,6 @@ extern u_int Nscreens;
|
|||||||
extern struct client_ctx_q Clientq;
|
extern struct client_ctx_q Clientq;
|
||||||
|
|
||||||
extern int Doshape, Shape_ev;
|
extern int Doshape, Shape_ev;
|
||||||
extern int Doshape, Shape_ev;
|
|
||||||
extern int HasXinerama, HasRandr, Randr_ev;
|
|
||||||
extern struct conf Conf;
|
extern struct conf Conf;
|
||||||
|
|
||||||
#endif /* _CALMWM_H_ */
|
#endif /* _CALMWM_H_ */
|
||||||
|
139
client.c
139
client.c
@ -22,12 +22,6 @@
|
|||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
int _inwindowbounds(struct client_ctx *, int, int);
|
int _inwindowbounds(struct client_ctx *, int, int);
|
||||||
static void client_fullmaximize(struct client_ctx *);
|
|
||||||
static void client_xinerama_maximize(struct client_ctx *);
|
|
||||||
static void client_xinerama_vmax(struct client_ctx *);
|
|
||||||
static void client_full_vmax(struct client_ctx *);
|
|
||||||
XineramaScreenInfo *client_find_xinerama_screen(int , int ,
|
|
||||||
struct screen_ctx *);
|
|
||||||
|
|
||||||
static char emptystring[] = "";
|
static char emptystring[] = "";
|
||||||
|
|
||||||
@ -334,42 +328,16 @@ client_maximize(struct client_ctx *cc)
|
|||||||
} else {
|
} else {
|
||||||
if (!(cc->flags & CLIENT_VMAXIMIZED))
|
if (!(cc->flags & CLIENT_VMAXIMIZED))
|
||||||
cc->savegeom = cc->geom;
|
cc->savegeom = cc->geom;
|
||||||
if (HasXinerama)
|
cc->geom.x = Conf.gap_left;
|
||||||
client_xinerama_maximize(cc);
|
cc->geom.y = Conf.gap_top;
|
||||||
else
|
cc->geom.height = sc->ymax - (Conf.gap_top + Conf.gap_bottom);
|
||||||
client_fullmaximize(cc);
|
cc->geom.width = sc->xmax - (Conf.gap_left + Conf.gap_right);
|
||||||
|
cc->flags |= CLIENT_DOMAXIMIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
client_xinerama_maximize(struct client_ctx *cc)
|
|
||||||
{
|
|
||||||
XineramaScreenInfo *xine;
|
|
||||||
|
|
||||||
xine = client_find_xinerama_screen(cc->geom.x, cc->geom.y, CCTOSC(cc));
|
|
||||||
if (xine == NULL)
|
|
||||||
return;
|
|
||||||
cc->geom.x = xine->x_org + Conf.gap_left;
|
|
||||||
cc->geom.y = xine->y_org + Conf.gap_top;
|
|
||||||
cc->geom.height = xine->height - (Conf.gap_top + Conf.gap_bottom);
|
|
||||||
cc->geom.width = xine->width - (Conf.gap_left + Conf.gap_right);
|
|
||||||
cc->flags |= CLIENT_DOMAXIMIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
client_fullmaximize(struct client_ctx *cc)
|
|
||||||
{
|
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
|
||||||
|
|
||||||
cc->geom.x = Conf.gap_left;
|
|
||||||
cc->geom.y = Conf.gap_top;
|
|
||||||
cc->geom.height = sc->ymax - (Conf.gap_top + Conf.gap_bottom);
|
|
||||||
cc->geom.width = sc->xmax - (Conf.gap_left + Conf.gap_right);
|
|
||||||
cc->flags |= CLIENT_DOMAXIMIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
client_vertmaximize(struct client_ctx *cc)
|
client_vertmaximize(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
@ -380,40 +348,15 @@ client_vertmaximize(struct client_ctx *cc)
|
|||||||
} else {
|
} else {
|
||||||
if (!(cc->flags & CLIENT_MAXIMIZED))
|
if (!(cc->flags & CLIENT_MAXIMIZED))
|
||||||
cc->savegeom = cc->geom;
|
cc->savegeom = cc->geom;
|
||||||
if (HasXinerama)
|
cc->geom.y = cc->bwidth + Conf.gap_top;
|
||||||
client_xinerama_vmax(cc);
|
cc->geom.height = (sc->ymax - cc->bwidth * 2) -
|
||||||
else
|
(Conf.gap_top + Conf.gap_bottom);
|
||||||
client_full_vmax(cc);
|
cc->flags |= CLIENT_DOVMAXIMIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
client_resize(cc);
|
client_resize(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
client_xinerama_vmax(struct client_ctx *cc)
|
|
||||||
{
|
|
||||||
XineramaScreenInfo *xine;
|
|
||||||
|
|
||||||
xine = client_find_xinerama_screen(cc->geom.x, cc->geom.y, CCTOSC(cc));
|
|
||||||
if (xine == NULL)
|
|
||||||
return;
|
|
||||||
cc->geom.y = xine->y_org + cc->bwidth + Conf.gap_top;
|
|
||||||
cc->geom.height = xine->height - (cc->bwidth * 2) - (Conf.gap_top +
|
|
||||||
Conf.gap_bottom);
|
|
||||||
cc->flags |= CLIENT_DOVMAXIMIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
client_full_vmax(struct client_ctx *cc)
|
|
||||||
{
|
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
|
||||||
|
|
||||||
cc->geom.y = cc->bwidth + Conf.gap_top;
|
|
||||||
cc->geom.height = (sc->ymax - cc->bwidth * 2) -
|
|
||||||
(Conf.gap_top + Conf.gap_bottom);
|
|
||||||
cc->flags |= CLIENT_DOVMAXIMIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
client_resize(struct client_ctx *cc)
|
client_resize(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
@ -725,32 +668,11 @@ client_placecalc(struct client_ctx *cc)
|
|||||||
{
|
{
|
||||||
struct screen_ctx *sc = CCTOSC(cc);
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
int yslack, xslack, xmouse, ymouse;
|
int yslack, xslack, xmouse, ymouse;
|
||||||
int xorig, yorig, xmax, ymax;
|
|
||||||
XineramaScreenInfo *info;
|
|
||||||
|
|
||||||
|
yslack = sc->ymax - cc->geom.height - cc->bwidth;
|
||||||
|
xslack = sc->xmax - cc->geom.width - cc->bwidth;
|
||||||
|
|
||||||
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
|
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
|
||||||
if (HasXinerama) {
|
|
||||||
info = client_find_xinerama_screen(xmouse, ymouse, sc);
|
|
||||||
if (info == NULL)
|
|
||||||
goto noxine;
|
|
||||||
yslack = info->y_org + info->height - cc->geom.height -
|
|
||||||
cc->bwidth;
|
|
||||||
xslack = info->x_org + info->width - cc->geom.width -
|
|
||||||
cc->bwidth;
|
|
||||||
xorig = info->x_org;
|
|
||||||
yorig = info->y_org;
|
|
||||||
xmax = xorig + info->width;
|
|
||||||
ymax = yorig + info->height;
|
|
||||||
} else {
|
|
||||||
noxine:
|
|
||||||
yslack = sc->ymax - cc->geom.height - cc->bwidth;
|
|
||||||
xslack = sc->xmax - cc->geom.width - cc->bwidth;
|
|
||||||
xorig = yorig = 0;
|
|
||||||
xmax = sc->xmax;
|
|
||||||
ymax = sc->ymax;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xmouse = MAX(xmouse, cc->bwidth) - cc->geom.width / 2;
|
xmouse = MAX(xmouse, cc->bwidth) - cc->geom.width / 2;
|
||||||
ymouse = MAX(ymouse, cc->bwidth) - cc->geom.height / 2;
|
ymouse = MAX(ymouse, cc->bwidth) - cc->geom.height / 2;
|
||||||
@ -759,32 +681,32 @@ noxine:
|
|||||||
ymouse = MAX(ymouse, (int)cc->bwidth);
|
ymouse = MAX(ymouse, (int)cc->bwidth);
|
||||||
|
|
||||||
if (cc->size->flags & USPosition) {
|
if (cc->size->flags & USPosition) {
|
||||||
if (cc->size->x >= xorig)
|
if (cc->size->x >= 0)
|
||||||
cc->geom.x = MAX(MIN(cc->size->x, xslack), cc->bwidth);
|
cc->geom.x = MAX(MIN(cc->size->x, xslack), cc->bwidth);
|
||||||
else
|
else
|
||||||
cc->geom.x = xorig + cc->bwidth;
|
cc->geom.x = cc->bwidth;
|
||||||
if (cc->size->y >= yorig)
|
if (cc->size->y >= 0)
|
||||||
cc->geom.y = MAX(MIN(cc->size->y, yslack), cc->bwidth);
|
cc->geom.y = MAX(MIN(cc->size->y, yslack), cc->bwidth);
|
||||||
else
|
else
|
||||||
cc->geom.y = yorig + cc->bwidth;
|
cc->geom.y = cc->bwidth;
|
||||||
} else {
|
} else {
|
||||||
if (xslack >= xorig) {
|
if (xslack >= 0) {
|
||||||
cc->geom.x = MAX(MIN(xmouse, xslack),
|
cc->geom.x = MAX(MIN(xmouse, xslack),
|
||||||
xorig + Conf.gap_left + cc->bwidth);
|
Conf.gap_left + cc->bwidth);
|
||||||
if (cc->geom.x > (xslack - Conf.gap_right))
|
if (cc->geom.x > (xslack - Conf.gap_right))
|
||||||
cc->geom.x -= Conf.gap_right;
|
cc->geom.x -= Conf.gap_right;
|
||||||
} else {
|
} else {
|
||||||
cc->geom.x = xorig + cc->bwidth + Conf.gap_left;
|
cc->geom.x = cc->bwidth + Conf.gap_left;
|
||||||
cc->geom.width = xmax - Conf.gap_left;
|
cc->geom.width = sc->xmax - Conf.gap_left;
|
||||||
}
|
}
|
||||||
if (yslack >= yorig) {
|
if (yslack >= 0) {
|
||||||
cc->geom.y = MAX(MIN(ymouse, yslack),
|
cc->geom.y = MAX(MIN(ymouse, yslack),
|
||||||
yorig + Conf.gap_top + cc->bwidth);
|
Conf.gap_top + cc->bwidth);
|
||||||
if (cc->geom.y > (yslack - Conf.gap_bottom))
|
if (cc->geom.y > (yslack - Conf.gap_bottom))
|
||||||
cc->geom.y -= Conf.gap_bottom;
|
cc->geom.y -= Conf.gap_bottom;
|
||||||
} else {
|
} else {
|
||||||
cc->geom.y = yorig + cc->bwidth + Conf.gap_top;
|
cc->geom.y = cc->bwidth + Conf.gap_top;
|
||||||
cc->geom.height = ymax - Conf.gap_top;
|
cc->geom.height = sc->ymax - Conf.gap_top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -871,18 +793,3 @@ _inwindowbounds(struct client_ctx *cc, int x, int y)
|
|||||||
return (x < cc->geom.width && x >= 0 &&
|
return (x < cc->geom.width && x >= 0 &&
|
||||||
y < cc->geom.height && y >= 0);
|
y < cc->geom.height && y >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
XineramaScreenInfo *
|
|
||||||
client_find_xinerama_screen(int x, int y, struct screen_ctx *sc)
|
|
||||||
{
|
|
||||||
XineramaScreenInfo *info;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < sc->xinerama_no; i++) {
|
|
||||||
info = &sc->xinerama[i];
|
|
||||||
if (x > info->x_org && x < info->x_org + info->width &&
|
|
||||||
y > info->y_org && y < info->y_org + info->height)
|
|
||||||
return (info);
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
|
||||||
#include <X11/extensions/Xinerama.h>
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
|
25
screen.c
25
screen.c
@ -67,28 +67,3 @@ screen_updatestackingorder(void)
|
|||||||
|
|
||||||
XFree(wins);
|
XFree(wins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
screen_init_xinerama(struct screen_ctx *sc)
|
|
||||||
{
|
|
||||||
XineramaScreenInfo *info;
|
|
||||||
int no, fake;
|
|
||||||
|
|
||||||
if (HasXinerama == 0 || XineramaIsActive(X_Dpy) == 0) {
|
|
||||||
HasXinerama = 0;
|
|
||||||
sc->xinerama_no = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
info = XineramaQueryScreens(X_Dpy, &no);
|
|
||||||
if (info == NULL) {
|
|
||||||
/*is xinerama is actually off, instead of a malloc failure? */
|
|
||||||
if (sc->xinerama == NULL)
|
|
||||||
HasXinerama = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sc->xinerama != NULL)
|
|
||||||
XFree(sc->xinerama);
|
|
||||||
sc->xinerama = info;
|
|
||||||
sc->xinerama_no = no;
|
|
||||||
}
|
|
||||||
|
18
xevents.c
18
xevents.c
@ -375,22 +375,6 @@ xev_handle_shape(struct xevent *xev, XEvent *ee)
|
|||||||
client_do_shape(cc);
|
client_do_shape(cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xev_handle_randr(struct xevent *xev, XEvent *ee)
|
|
||||||
{
|
|
||||||
XRRScreenChangeNotifyEvent *rev = (XRRScreenChangeNotifyEvent *)ee;
|
|
||||||
struct client_ctx *cc;
|
|
||||||
struct screen_ctx *sc;
|
|
||||||
|
|
||||||
if ((cc = client_find(rev->window)) != NULL) {
|
|
||||||
XRRUpdateConfiguration(ee);
|
|
||||||
sc = CCTOSC(cc);
|
|
||||||
sc->xmax = rev->width;
|
|
||||||
sc->ymax = rev->height;
|
|
||||||
screen_init_xinerama(sc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when the keymap has changed.
|
* Called when the keymap has changed.
|
||||||
* Ungrab all keys, reload keymap and then regrab
|
* Ungrab all keys, reload keymap and then regrab
|
||||||
@ -541,8 +525,6 @@ xev_loop(void)
|
|||||||
default:
|
default:
|
||||||
if (e.type == Shape_ev)
|
if (e.type == Shape_ev)
|
||||||
xev_handle_shape(xev, &e);
|
xev_handle_shape(xev, &e);
|
||||||
else if (e.type == Randr_ev)
|
|
||||||
xev_handle_randr(xev, &e);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user