Border resizing by dragging.
Thanks to Axel Belinfante.
This commit is contained in:
parent
d99b2f34e6
commit
1cb3fa8093
10 changed files with 268 additions and 45 deletions
|
|
@ -49,6 +49,7 @@ draw_border(Client *c, int active)
|
||||||
pixel = c->screen->inactiveborder;
|
pixel = c->screen->inactiveborder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug) fprintf(stderr, "draw_border 0x%p pixel %ld active %d hold %d\n", c, pixel, active, c->hold);
|
||||||
XSetWindowBackground(dpy, c->parent, pixel);
|
XSetWindowBackground(dpy, c->parent, pixel);
|
||||||
XClearWindow(dpy, c->parent);
|
XClearWindow(dpy, c->parent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
colorpixel(Display *dpy, int depth, unsigned long rgb)
|
colorpixel(Display *dpy, int depth, unsigned long rgb, unsigned long def)
|
||||||
{
|
{
|
||||||
int r, g, b;
|
int r, g, b;
|
||||||
|
|
||||||
|
|
@ -23,9 +23,7 @@ colorpixel(Display *dpy, int depth, unsigned long rgb)
|
||||||
case 8:
|
case 8:
|
||||||
default:
|
default:
|
||||||
/* not going to waste color map entries */
|
/* not going to waste color map entries */
|
||||||
if(rgb == 0xFFFFFF)
|
return def;
|
||||||
return WhitePixel(dpy, DefaultScreen(dpy));
|
|
||||||
return BlackPixel(dpy, DefaultScreen(dpy));
|
|
||||||
case 15:
|
case 15:
|
||||||
r >>= 3;
|
r >>= 3;
|
||||||
g >>= 3;
|
g >>= 3;
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,15 @@ ScreenInfo *s;
|
||||||
s->root_pixmap = XCreatePixmapFromBitmapData(dpy,
|
s->root_pixmap = XCreatePixmapFromBitmapData(dpy,
|
||||||
s->root, grey_bits, grey_width, grey_height,
|
s->root, grey_bits, grey_width, grey_height,
|
||||||
s->black, s->white, DefaultDepth(dpy, s->num));
|
s->black, s->white, DefaultDepth(dpy, s->num));
|
||||||
|
|
||||||
|
s->bordcurs[BorderN] = XCreateFontCursor(dpy, 138);
|
||||||
|
s->bordcurs[BorderS] = XCreateFontCursor(dpy, 16);
|
||||||
|
s->bordcurs[BorderW] = XCreateFontCursor(dpy, 70);
|
||||||
|
s->bordcurs[BorderE] = XCreateFontCursor(dpy, 96);
|
||||||
|
s->bordcurs[BorderNW] = XCreateFontCursor(dpy, 134);
|
||||||
|
s->bordcurs[BorderSW] = XCreateFontCursor(dpy, 12);
|
||||||
|
s->bordcurs[BorderNE] = XCreateFontCursor(dpy, 136);
|
||||||
|
s->bordcurs[BorderSE] = XCreateFontCursor(dpy, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/* Copyright (c) 1994-1996 David Hogan, see README for licence details */
|
/* Copyright (c) 1994-1996 David Hogan, see README for licence details */
|
||||||
|
|
||||||
#define BORDER _border
|
#define BORDER _border
|
||||||
|
#define CORNER _corner
|
||||||
#define INSET _inset
|
#define INSET _inset
|
||||||
#define MAXHIDDEN 32
|
#define MAXHIDDEN 32
|
||||||
#define B3FIXED 5
|
#define B3FIXED 5
|
||||||
|
|
@ -20,6 +21,7 @@
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
typedef struct Menu Menu;
|
typedef struct Menu Menu;
|
||||||
typedef struct ScreenInfo ScreenInfo;
|
typedef struct ScreenInfo ScreenInfo;
|
||||||
|
typedef enum BorderLocation BorderLocation;
|
||||||
|
|
||||||
struct Client {
|
struct Client {
|
||||||
Window window;
|
Window window;
|
||||||
|
|
@ -72,6 +74,19 @@ struct Menu {
|
||||||
int lasthit;
|
int lasthit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum BorderLocation {
|
||||||
|
BorderN,
|
||||||
|
BorderNE,
|
||||||
|
BorderE,
|
||||||
|
BorderSE,
|
||||||
|
BorderS,
|
||||||
|
BorderSW,
|
||||||
|
BorderW,
|
||||||
|
BorderNW,
|
||||||
|
BorderUnknown,
|
||||||
|
NBorder,
|
||||||
|
};
|
||||||
|
|
||||||
struct ScreenInfo {
|
struct ScreenInfo {
|
||||||
int num;
|
int num;
|
||||||
int depth;
|
int depth;
|
||||||
|
|
@ -102,6 +117,7 @@ struct ScreenInfo {
|
||||||
Cursor sweep0;
|
Cursor sweep0;
|
||||||
Cursor boxcurs;
|
Cursor boxcurs;
|
||||||
Cursor arrow;
|
Cursor arrow;
|
||||||
|
Cursor bordcurs[NBorder];
|
||||||
Pixmap root_pixmap;
|
Pixmap root_pixmap;
|
||||||
char display[256]; /* arbitrary limit */
|
char display[256]; /* arbitrary limit */
|
||||||
};
|
};
|
||||||
|
|
@ -119,6 +135,7 @@ extern char *termprog;
|
||||||
extern char *shell;
|
extern char *shell;
|
||||||
extern char *version[];
|
extern char *version[];
|
||||||
extern int _border;
|
extern int _border;
|
||||||
|
extern int _corner;
|
||||||
extern int _inset;
|
extern int _inset;
|
||||||
extern int curtime;
|
extern int curtime;
|
||||||
extern int debug;
|
extern int debug;
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,9 @@ mainloop(int shape_event)
|
||||||
case EnterNotify:
|
case EnterNotify:
|
||||||
enter(&ev.xcrossing);
|
enter(&ev.xcrossing);
|
||||||
break;
|
break;
|
||||||
|
case LeaveNotify:
|
||||||
|
leave(&ev.xcrossing);
|
||||||
|
break;
|
||||||
case ReparentNotify:
|
case ReparentNotify:
|
||||||
reparent(&ev.xreparent);
|
reparent(&ev.xreparent);
|
||||||
break;
|
break;
|
||||||
|
|
@ -85,6 +88,8 @@ mainloop(int shape_event)
|
||||||
focusin(&ev.xfocus);
|
focusin(&ev.xfocus);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
motionnotify(&ev.xmotion);
|
||||||
|
break;
|
||||||
case Expose:
|
case Expose:
|
||||||
case NoExpose:
|
case NoExpose:
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
|
@ -449,6 +454,16 @@ enter(XCrossingEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
leave(XCrossingEvent *e)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
|
||||||
|
c = getclient(e->window, 0);
|
||||||
|
XUndefineCursor(dpy, c->parent);
|
||||||
|
/* XDefineCursor(dpy, c->parent, c->screen->arrow); */
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focusin(XFocusChangeEvent *e)
|
focusin(XFocusChangeEvent *e)
|
||||||
{
|
{
|
||||||
|
|
@ -465,3 +480,82 @@ focusin(XFocusChangeEvent *e)
|
||||||
active(c);
|
active(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BorderLocation
|
||||||
|
borderlocation(Client *c, int x, int y)
|
||||||
|
{
|
||||||
|
if (x <= BORDER) {
|
||||||
|
if (y <= CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "topleft\n");
|
||||||
|
return BorderNW;
|
||||||
|
}
|
||||||
|
if (y >= (c->dy + 2*BORDER) - CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "botleft\n");
|
||||||
|
return BorderSW;
|
||||||
|
}
|
||||||
|
if (y > CORNER &&
|
||||||
|
y < (c->dy + 2*BORDER) - CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "left\n");
|
||||||
|
return BorderW;
|
||||||
|
}
|
||||||
|
} else if (x <= CORNER) {
|
||||||
|
if (y <= BORDER) {
|
||||||
|
if (debug) fprintf(stderr, "topleft\n");
|
||||||
|
return BorderNW;
|
||||||
|
}
|
||||||
|
if (y >= (c->dy + BORDER)) {
|
||||||
|
if (debug) fprintf(stderr, "botleft\n");
|
||||||
|
return BorderSW;
|
||||||
|
}
|
||||||
|
} else if (x >= (c->dx + BORDER)) {
|
||||||
|
if (y <= CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "topright\n");
|
||||||
|
return BorderNE;
|
||||||
|
}
|
||||||
|
if (y >= (c->dy + 2*BORDER) - CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "botright\n");
|
||||||
|
return BorderSE;
|
||||||
|
}
|
||||||
|
if (y > CORNER &&
|
||||||
|
y < (c->dy + 2*BORDER) - CORNER) {
|
||||||
|
if (debug) fprintf(stderr, "right\n");
|
||||||
|
return BorderE;
|
||||||
|
}
|
||||||
|
} else if (x >= (c->dx + 2*BORDER) - CORNER) {
|
||||||
|
if (y <= BORDER) {
|
||||||
|
if (debug) fprintf(stderr, "topright\n");
|
||||||
|
return BorderNE;
|
||||||
|
}
|
||||||
|
if (y >= (c->dy + BORDER)) {
|
||||||
|
if (debug) fprintf(stderr, "botright\n");
|
||||||
|
return BorderSE;
|
||||||
|
}
|
||||||
|
} else if (x > CORNER &&
|
||||||
|
x < (c->dx + 2*BORDER) - CORNER) {
|
||||||
|
if (y <= BORDER) {
|
||||||
|
if (debug) fprintf(stderr, "top\n");
|
||||||
|
return BorderN;
|
||||||
|
}
|
||||||
|
if (y >= (c->dy + BORDER)) {
|
||||||
|
if (debug) fprintf(stderr, "bot\n");
|
||||||
|
return BorderS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BorderUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
motionnotify(XMotionEvent *e)
|
||||||
|
{
|
||||||
|
Client *c;
|
||||||
|
BorderLocation bl;
|
||||||
|
|
||||||
|
c = getclient(e->window, 0);
|
||||||
|
if (c) {
|
||||||
|
bl = borderlocation(c, e->x, e->y);
|
||||||
|
if (bl == BorderUnknown)
|
||||||
|
XUndefineCursor(dpy, c->parent);
|
||||||
|
else
|
||||||
|
XDefineCursor(dpy, c->parent, c->screen->bordcurs[bl]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* color.c */
|
/* color.c */
|
||||||
unsigned long colorpixel(Display*, int, unsigned long);
|
unsigned long colorpixel(Display*, int, unsigned long, unsigned long);
|
||||||
|
|
||||||
/* main.c */
|
/* main.c */
|
||||||
void usage();
|
void usage();
|
||||||
|
|
@ -36,8 +36,11 @@ void cmap();
|
||||||
void property();
|
void property();
|
||||||
void shapenotify();
|
void shapenotify();
|
||||||
void enter();
|
void enter();
|
||||||
|
void leave();
|
||||||
void focusin();
|
void focusin();
|
||||||
void reparent();
|
void reparent();
|
||||||
|
void motionnotify();
|
||||||
|
BorderLocation borderlocation();
|
||||||
|
|
||||||
/* manage.c */
|
/* manage.c */
|
||||||
int manage();
|
int manage();
|
||||||
|
|
@ -85,6 +88,7 @@ int menuhit();
|
||||||
Client *selectwin();
|
Client *selectwin();
|
||||||
int sweep();
|
int sweep();
|
||||||
int drag();
|
int drag();
|
||||||
|
int pull();
|
||||||
void getmouse();
|
void getmouse();
|
||||||
void setmouse();
|
void setmouse();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ selectwin(int release, int *shift, ScreenInfo *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sweepcalc(Client *c, int x, int y)
|
sweepcalc(Client *c, int x, int y, BorderLocation bl)
|
||||||
{
|
{
|
||||||
int dx, dy, sx, sy;
|
int dx, dy, sx, sy;
|
||||||
|
|
||||||
|
|
@ -267,12 +267,55 @@ sweepcalc(Client *c, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dragcalc(Client *c, int x, int y)
|
dragcalc(Client *c, int x, int y, BorderLocation bl)
|
||||||
{
|
{
|
||||||
c->x += x;
|
c->x += x;
|
||||||
c->y += y;
|
c->y += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pullcalc(Client *c, int x, int y, BorderLocation bl)
|
||||||
|
{
|
||||||
|
switch(bl) {
|
||||||
|
case BorderN:
|
||||||
|
c->y += y;
|
||||||
|
c->dy -= y;
|
||||||
|
break;
|
||||||
|
case BorderS:
|
||||||
|
c->dy += y;
|
||||||
|
break;
|
||||||
|
case BorderE:
|
||||||
|
c->dx += x;
|
||||||
|
break;
|
||||||
|
case BorderW:
|
||||||
|
c->x += x;
|
||||||
|
c->dx -= x;
|
||||||
|
break;
|
||||||
|
case BorderNW:
|
||||||
|
c->x += x;
|
||||||
|
c->dx -= x;
|
||||||
|
c->y += y;
|
||||||
|
c->dy -= y;
|
||||||
|
break;
|
||||||
|
case BorderNE:
|
||||||
|
c->dx += x;
|
||||||
|
c->y += y;
|
||||||
|
c->dy -= y;
|
||||||
|
break;
|
||||||
|
case BorderSE:
|
||||||
|
c->dx += x;
|
||||||
|
c->dy += y;
|
||||||
|
break;
|
||||||
|
case BorderSW:
|
||||||
|
c->x += x;
|
||||||
|
c->dx -= x;
|
||||||
|
c->dy += y;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xcopy(int fwd, Display *dpy, Drawable src, Drawable dst, GC gc, int x, int y, int dx, int dy, int x1, int y1)
|
xcopy(int fwd, Display *dpy, Drawable src, Drawable dst, GC gc, int x, int y, int dx, int dy, int x1, int y1)
|
||||||
{
|
{
|
||||||
|
|
@ -350,7 +393,7 @@ misleep(int msec)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sweepdrag(Client *c, XButtonEvent *e0, void (*recalc)(Client*, int, int))
|
sweepdrag(Client *c, int but, XButtonEvent *e0, BorderLocation bl, void (*recalc)(Client*, int, int, BorderLocation))
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int idle;
|
int idle;
|
||||||
|
|
@ -366,7 +409,9 @@ sweepdrag(Client *c, XButtonEvent *e0, void (*recalc)(Client*, int, int))
|
||||||
c->y -= BORDER;
|
c->y -= BORDER;
|
||||||
c->dx += 2*BORDER;
|
c->dx += 2*BORDER;
|
||||||
c->dy += 2*BORDER;
|
c->dy += 2*BORDER;
|
||||||
if (e0)
|
if (bl)
|
||||||
|
getmouse(&cx, &cy, c->screen);
|
||||||
|
else if (e0)
|
||||||
getmouse(&c->x, &c->y, c->screen);
|
getmouse(&c->x, &c->y, c->screen);
|
||||||
else
|
else
|
||||||
getmouse(&cx, &cy, c->screen);
|
getmouse(&cx, &cy, c->screen);
|
||||||
|
|
@ -386,9 +431,9 @@ sweepdrag(Client *c, XButtonEvent *e0, void (*recalc)(Client*, int, int))
|
||||||
idle = 0;
|
idle = 0;
|
||||||
}
|
}
|
||||||
if(e0)
|
if(e0)
|
||||||
recalc(c, rx, ry);
|
recalc(c, rx, ry, bl);
|
||||||
else
|
else
|
||||||
recalc(c, rx-cx, ry-cy);
|
recalc(c, rx-cx, ry-cy, bl);
|
||||||
cx = rx;
|
cx = rx;
|
||||||
cy = ry;
|
cy = ry;
|
||||||
drawbound(c, 1);
|
drawbound(c, 1);
|
||||||
|
|
@ -404,7 +449,7 @@ sweepdrag(Client *c, XButtonEvent *e0, void (*recalc)(Client*, int, int))
|
||||||
drawbound(c, 0);
|
drawbound(c, 0);
|
||||||
ungrab(e);
|
ungrab(e);
|
||||||
XUngrabServer(dpy);
|
XUngrabServer(dpy);
|
||||||
if (e->button != Button3 && c->init)
|
if (e->button != but && c->init)
|
||||||
goto bad;
|
goto bad;
|
||||||
if (c->dx < 0) {
|
if (c->dx < 0) {
|
||||||
c->x += c->dx;
|
c->x += c->dx;
|
||||||
|
|
@ -424,6 +469,7 @@ sweepdrag(Client *c, XButtonEvent *e0, void (*recalc)(Client*, int, int))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bad:
|
bad:
|
||||||
|
if (debug) fprintf(stderr, "sweepdrag bad\n");
|
||||||
c->x = ox;
|
c->x = ox;
|
||||||
c->y = oy;
|
c->y = oy;
|
||||||
c->dx = odx;
|
c->dx = odx;
|
||||||
|
|
@ -433,7 +479,7 @@ bad:
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sweep(Client *c)
|
sweep(Client *c, int but, XButtonEvent *ignored)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
int status;
|
int status;
|
||||||
|
|
@ -449,16 +495,34 @@ sweep(Client *c)
|
||||||
|
|
||||||
XMaskEvent(dpy, ButtonMask, &ev);
|
XMaskEvent(dpy, ButtonMask, &ev);
|
||||||
e = &ev.xbutton;
|
e = &ev.xbutton;
|
||||||
if (e->button != Button3) {
|
if (e->button != but) {
|
||||||
ungrab(e);
|
ungrab(e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
XChangeActivePointerGrab(dpy, ButtonMask, s->boxcurs, e->time);
|
XChangeActivePointerGrab(dpy, ButtonMask, s->boxcurs, e->time);
|
||||||
return sweepdrag(c, e, sweepcalc);
|
return sweepdrag(c, but, e, 0, sweepcalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
drag(Client *c)
|
pull(Client *c, int but, XButtonEvent *e)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
ScreenInfo *s;
|
||||||
|
BorderLocation bl;
|
||||||
|
|
||||||
|
bl = borderlocation(c, e->x, e->y);
|
||||||
|
s = c->screen;
|
||||||
|
status = grab(s->root, s->root, ButtonMask, s->bordcurs[bl], 0);
|
||||||
|
if (status != GrabSuccess) {
|
||||||
|
graberror("pull", status); /* */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sweepdrag(c, but, 0, bl, pullcalc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
drag(Client *c, int but)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
ScreenInfo *s;
|
ScreenInfo *s;
|
||||||
|
|
@ -469,7 +533,7 @@ drag(Client *c)
|
||||||
graberror("drag", status); /* */
|
graberror("drag", status); /* */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return sweepdrag(c, 0, dragcalc);
|
return sweepdrag(c, but, 0, 0, dragcalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ char *termprog;
|
||||||
char *shell;
|
char *shell;
|
||||||
Bool shape;
|
Bool shape;
|
||||||
int _border = 4;
|
int _border = 4;
|
||||||
|
int _corner = 25;
|
||||||
int _inset = 1;
|
int _inset = 1;
|
||||||
int curtime;
|
int curtime;
|
||||||
int debug;
|
int debug;
|
||||||
|
|
@ -236,13 +237,13 @@ initscreen(ScreenInfo *s, int i, int background)
|
||||||
else
|
else
|
||||||
s->display[0] = '\0';
|
s->display[0] = '\0';
|
||||||
|
|
||||||
s->activeholdborder = colorpixel(dpy, s->depth, 0x000099);
|
|
||||||
s->inactiveholdborder = colorpixel(dpy, s->depth, 0x005DBB);
|
|
||||||
s->activeborder = colorpixel(dpy, s->depth ,0x55AAAA);
|
|
||||||
s->inactiveborder = colorpixel(dpy, s->depth, 0x9EEEEE);
|
|
||||||
s->red = colorpixel(dpy, s->depth, 0xDD0000);
|
|
||||||
s->black = BlackPixel(dpy, i);
|
s->black = BlackPixel(dpy, i);
|
||||||
s->white = WhitePixel(dpy, i);
|
s->white = WhitePixel(dpy, i);
|
||||||
|
s->activeholdborder = colorpixel(dpy, s->depth, 0x000099, s->white);
|
||||||
|
s->inactiveholdborder = colorpixel(dpy, s->depth, 0x005DBB, s->black);
|
||||||
|
s->activeborder = colorpixel(dpy, s->depth ,0x55AAAA, s->black);
|
||||||
|
s->inactiveborder = colorpixel(dpy, s->depth, 0x9EEEEE, s->white);
|
||||||
|
s->red = colorpixel(dpy, s->depth, 0xDD0000, s->white);
|
||||||
s->width = WidthOfScreen(ScreenOfDisplay(dpy, i));
|
s->width = WidthOfScreen(ScreenOfDisplay(dpy, i));
|
||||||
s->height = HeightOfScreen(ScreenOfDisplay(dpy, i));
|
s->height = HeightOfScreen(ScreenOfDisplay(dpy, i));
|
||||||
s->bkup[0] = XCreatePixmap(dpy, s->root, 2*s->width, BORDER, DefaultDepth(dpy, i));
|
s->bkup[0] = XCreatePixmap(dpy, s->root, 2*s->width, BORDER, DefaultDepth(dpy, i));
|
||||||
|
|
@ -267,21 +268,21 @@ initscreen(ScreenInfo *s, int i, int background)
|
||||||
gv.foreground = s->red;
|
gv.foreground = s->red;
|
||||||
s->gcred = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcred = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
gv.foreground = colorpixel(dpy, s->depth, 0xEEEEEE);
|
gv.foreground = colorpixel(dpy, s->depth, 0xEEEEEE, s->black);
|
||||||
s->gcsweep = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcsweep = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
gv.foreground = colorpixel(dpy, s->depth, 0xE9FFE9);
|
gv.foreground = colorpixel(dpy, s->depth, 0xE9FFE9, s->white);
|
||||||
s->gcmenubg = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcmenubg = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
gv.foreground = colorpixel(dpy, s->depth, 0x448844);
|
gv.foreground = colorpixel(dpy, s->depth, 0x448844, s->black);
|
||||||
s->gcmenubgs = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcmenubgs = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
gv.foreground = s->black;
|
gv.foreground = s->black;
|
||||||
gv.background = colorpixel(dpy, s->depth, 0xE9FFE9);
|
gv.background = colorpixel(dpy, s->depth, 0xE9FFE9, s->white);
|
||||||
s->gcmenufg = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcmenufg = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
gv.foreground = colorpixel(dpy, s->depth, 0xE9FFE9);
|
gv.foreground = colorpixel(dpy, s->depth, 0xE9FFE9, s->white);
|
||||||
gv.background = colorpixel(dpy, s->depth, 0x448844);
|
gv.background = colorpixel(dpy, s->depth, 0x448844, s->black);
|
||||||
s->gcmenufgs = XCreateGC(dpy, s->root, mask, &gv);
|
s->gcmenufgs = XCreateGC(dpy, s->root, mask, &gv);
|
||||||
|
|
||||||
initcurs(s);
|
initcurs(s);
|
||||||
|
|
@ -299,9 +300,21 @@ initscreen(ScreenInfo *s, int i, int background)
|
||||||
XClearWindow(dpy, s->root);
|
XClearWindow(dpy, s->root);
|
||||||
} else
|
} else
|
||||||
system("xsetroot -solid grey30");
|
system("xsetroot -solid grey30");
|
||||||
|
s->menuwin = XCreateSimpleWindow(dpy, s->root, 0, 0, 1, 1, 2, colorpixel(dpy, s->depth, 0x88CC88, s->black), colorpixel(dpy, s->depth, 0xE9FFE9, s->white));
|
||||||
s->menuwin = XCreateSimpleWindow(dpy, s->root, 0, 0, 1, 1, 2, colorpixel(dpy, s->depth, 0x88CC88), colorpixel(dpy, s->depth, 0xE9FFE9));
|
// s->sweepwin = XCreateWindow(dpy, s->root, 0, 0, 1, 1, 4, s->red, colorpixel(dpy, s->depth, 0xEEEEEE, s->black));
|
||||||
s->sweepwin = XCreateSimpleWindow(dpy, s->root, 0, 0, 1, 1, 4, s->red, colorpixel(dpy, s->depth, 0xEEEEEE));
|
{
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
attrs.background_pixel = colorpixel(dpy, s->depth, 0xEEEEEE, s->black);
|
||||||
|
attrs.border_pixel = s->red;
|
||||||
|
attrs.save_under = True;
|
||||||
|
s->sweepwin = XCreateWindow(dpy, s->root, 0, 0, 1, 1, 4,
|
||||||
|
CopyFromParent,
|
||||||
|
CopyFromParent,
|
||||||
|
CopyFromParent,
|
||||||
|
CWBackPixel | CWBorderPixel | CWSaveUnder,
|
||||||
|
&attrs
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenInfo*
|
ScreenInfo*
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ manage(Client *c, int mapped)
|
||||||
nwin %= 10;
|
nwin %= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->is9term && !(fixsize ? drag(c) : sweep(c))) {
|
if (c->is9term && !(fixsize ? drag(c, Button3) : sweep(c, Button3))) {
|
||||||
XKillClient(dpy, c->window);
|
XKillClient(dpy, c->window);
|
||||||
rmclient(c);
|
rmclient(c);
|
||||||
if (current && current->screen == c->screen)
|
if (current && current->screen == c->screen)
|
||||||
|
|
@ -121,13 +121,17 @@ manage(Client *c, int mapped)
|
||||||
c->parent = XCreateSimpleWindow(dpy, c->screen->root,
|
c->parent = XCreateSimpleWindow(dpy, c->screen->root,
|
||||||
c->x - BORDER, c->y - BORDER,
|
c->x - BORDER, c->y - BORDER,
|
||||||
c->dx + 2*BORDER, c->dy + 2*BORDER,
|
c->dx + 2*BORDER, c->dy + 2*BORDER,
|
||||||
0, c->screen->black, c->screen->white);
|
0,
|
||||||
XSelectInput(dpy, c->parent, SubstructureRedirectMask | SubstructureNotifyMask);
|
c->screen->black, c->screen->white);
|
||||||
|
XSelectInput(dpy, c->parent, SubstructureRedirectMask | SubstructureNotifyMask|ButtonPressMask| PointerMotionMask|LeaveWindowMask);
|
||||||
if (mapped)
|
if (mapped)
|
||||||
c->reparenting = 1;
|
c->reparenting = 1;
|
||||||
if (doreshape && !fixsize)
|
if (doreshape && !fixsize)
|
||||||
XResizeWindow(dpy, c->window, c->dx, c->dy);
|
XResizeWindow(dpy, c->window, c->dx, c->dy);
|
||||||
XSetWindowBorderWidth(dpy, c->window, 0);
|
XSetWindowBorderWidth(dpy, c->window, 0);
|
||||||
|
if (1 || c->screen->depth <= 8) {
|
||||||
|
XSetWindowBorderWidth(dpy, c->parent, 1);
|
||||||
|
}
|
||||||
XReparentWindow(dpy, c->window, c->parent, BORDER, BORDER);
|
XReparentWindow(dpy, c->window, c->parent, BORDER, BORDER);
|
||||||
#ifdef SHAPE
|
#ifdef SHAPE
|
||||||
if (shape) {
|
if (shape) {
|
||||||
|
|
@ -328,7 +332,7 @@ getcmaps(Client *c)
|
||||||
c->cmap = attr.colormap;
|
c->cmap = attr.colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = _getprop(c->window, wm_colormaps, XA_WINDOW, 100L, (unsigned char **)&cw);
|
n = _getprop(c->window, wm_colormaps, XA_WINDOW, 100L, (void*)&cw);
|
||||||
if (c->ncmapwins != 0) {
|
if (c->ncmapwins != 0) {
|
||||||
XFree((char *)c->cmapwins);
|
XFree((char *)c->cmapwins);
|
||||||
free((char *)c->wmcmaps);
|
free((char *)c->wmcmaps);
|
||||||
|
|
@ -421,7 +425,7 @@ get1prop(Window w, Atom a, Atom type)
|
||||||
{
|
{
|
||||||
char **p, *x;
|
char **p, *x;
|
||||||
|
|
||||||
if (_getprop(w, a, type, 1L, (unsigned char**)&p) <= 0)
|
if (_getprop(w, a, type, 1L, (void*)&p) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
x = *p;
|
x = *p;
|
||||||
XFree((void*) p);
|
XFree((void*) p);
|
||||||
|
|
@ -458,7 +462,7 @@ getstate(Window w, int *state)
|
||||||
{
|
{
|
||||||
long *p = 0;
|
long *p = 0;
|
||||||
|
|
||||||
if (_getprop(w, wm_state, wm_state, 2L, (unsigned char**)&p) <= 0)
|
if (_getprop(w, wm_state, wm_state, 2L, (void*)&p) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*state = (int) *p;
|
*state = (int) *p;
|
||||||
|
|
@ -476,7 +480,7 @@ getproto(Client *c)
|
||||||
|
|
||||||
w = c->window;
|
w = c->window;
|
||||||
c->proto = 0;
|
c->proto = 0;
|
||||||
if ((n = _getprop(w, wm_protocols, XA_ATOM, 20L, (unsigned char**)&p)) <= 0)
|
if ((n = _getprop(w, wm_protocols, XA_ATOM, 20L, (void*)&p)) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,31 @@ button(XButtonEvent *e)
|
||||||
return;
|
return;
|
||||||
c = getclient(e->window, 0);
|
c = getclient(e->window, 0);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
if (debug) fprintf(stderr, "but: e x=%d y=%d c x=%d y=%d dx=%d dy=%d BORDR %d\n",
|
||||||
|
e->x, e->y, c->x, c->y, c->dx, c->dy, BORDER);
|
||||||
|
if (e->x <= BORDER || e->x > (c->dx + BORDER) ||
|
||||||
|
e->y <= BORDER || e->y > (c->dy + BORDER)) {
|
||||||
|
switch (e->button) {
|
||||||
|
case Button1:
|
||||||
|
case Button2:
|
||||||
|
reshape(c, e->button, pull, e);
|
||||||
|
return;
|
||||||
|
case Button3:
|
||||||
|
move(c, Button3);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
e->x += c->x - BORDER;
|
e->x += c->x - BORDER;
|
||||||
e->y += c->y - BORDER;
|
e->y += c->y - BORDER;
|
||||||
}
|
}
|
||||||
else if (e->window != e->root)
|
else if (e->window != e->root) {
|
||||||
|
if (debug) fprintf(stderr, "but no client: e x=%d y=%d\n",
|
||||||
|
e->x, e->y);
|
||||||
XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y,
|
XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y,
|
||||||
&e->x, &e->y, &dw);
|
&e->x, &e->y, &dw);
|
||||||
|
}
|
||||||
switch (e->button) {
|
switch (e->button) {
|
||||||
case Button1:
|
case Button1:
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
@ -79,10 +98,10 @@ button(XButtonEvent *e)
|
||||||
spawn(s);
|
spawn(s);
|
||||||
break;
|
break;
|
||||||
case 1: /* Reshape */
|
case 1: /* Reshape */
|
||||||
reshape(selectwin(1, 0, s));
|
reshape(selectwin(1, 0, s), Button3, sweep, 0);
|
||||||
break;
|
break;
|
||||||
case 2: /* Move */
|
case 2: /* Move */
|
||||||
move(selectwin(0, 0, s));
|
move(selectwin(0, 0, s), Button3);
|
||||||
break;
|
break;
|
||||||
case 3: /* Delete */
|
case 3: /* Delete */
|
||||||
shift = 0;
|
shift = 0;
|
||||||
|
|
@ -137,7 +156,7 @@ spawn(ScreenInfo *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
reshape(Client *c)
|
reshape(Client *c, int but, int (*fn)(Client*, int, XButtonEvent *), XButtonEvent *e)
|
||||||
{
|
{
|
||||||
int odx, ody;
|
int odx, ody;
|
||||||
|
|
||||||
|
|
@ -145,7 +164,7 @@ reshape(Client *c)
|
||||||
return;
|
return;
|
||||||
odx = c->dx;
|
odx = c->dx;
|
||||||
ody = c->dy;
|
ody = c->dy;
|
||||||
if (sweep(c) == 0)
|
if (fn(c, but, e) == 0)
|
||||||
return;
|
return;
|
||||||
active(c);
|
active(c);
|
||||||
top(c);
|
top(c);
|
||||||
|
|
@ -159,11 +178,11 @@ reshape(Client *c)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
move(Client *c)
|
move(Client *c, int but)
|
||||||
{
|
{
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return;
|
return;
|
||||||
if (drag(c) == 0)
|
if (drag(c, but) == 0)
|
||||||
return;
|
return;
|
||||||
active(c);
|
active(c);
|
||||||
top(c);
|
top(c);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue