Add shaped window version of technical move/resize mode.
SVN revision: 30455
This commit is contained in:
parent
e5d10b0d8e
commit
328697893f
114
src/draw.c
114
src/draw.c
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
||||||
|
* Copyright (C) 2007 Kim Woelders
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
@ -31,6 +32,15 @@
|
||||||
#include <X11/bitmaps/gray>
|
#include <X11/bitmaps/gray>
|
||||||
#include <X11/bitmaps/gray3>
|
#include <X11/bitmaps/gray3>
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
EObj o;
|
||||||
|
Pixmap mask;
|
||||||
|
GC gc;
|
||||||
|
} ShapeWin;
|
||||||
|
|
||||||
|
static Font font = None; /* Used in mode 1 (technical) */
|
||||||
|
|
||||||
#define DRAW_H_ARROW(_dr, _gc, x1, x2, y1) \
|
#define DRAW_H_ARROW(_dr, _gc, x1, x2, y1) \
|
||||||
if (((x2) - (x1)) >= 12) \
|
if (((x2) - (x1)) >= 12) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -145,42 +155,90 @@ _ShapeGetColor(void)
|
||||||
return color_pixel;
|
return color_pixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EObj *
|
static void
|
||||||
_ShapeCreateWin(void)
|
_ShapeWinDestroy(ShapeWin * sw)
|
||||||
{
|
{
|
||||||
EObj *eo;
|
EoUnmap(sw);
|
||||||
|
EoFini(sw);
|
||||||
|
if (sw->gc)
|
||||||
|
EXFreeGC(sw->gc);
|
||||||
|
if (sw->mask != None)
|
||||||
|
EFreePixmap(sw->mask);
|
||||||
|
Efree(sw);
|
||||||
|
}
|
||||||
|
|
||||||
eo = EobjWindowCreate(EOBJ_TYPE_MISC, 0, 0, VRoot.w, VRoot.h, 0, "Wires");
|
static ShapeWin *
|
||||||
if (!eo)
|
_ShapeWinCreate(int md)
|
||||||
|
{
|
||||||
|
ShapeWin *sw;
|
||||||
|
|
||||||
|
sw = ECALLOC(ShapeWin, 1);
|
||||||
|
if (!sw)
|
||||||
return NULL;
|
return NULL;
|
||||||
eo->shadow = 0;
|
|
||||||
eo->fade = 0;
|
EoInit(sw, EOBJ_TYPE_MISC, None, 0, 0, VRoot.w, VRoot.h, 1, "Wires");
|
||||||
ESetWindowBackground(EobjGetWin(eo), _ShapeGetColor());
|
if (!EoGetWin(sw))
|
||||||
#ifdef xxShapeInput /* Should really check server too */
|
goto bail_out;
|
||||||
XShapeCombineRectangles(disp, EobjGetXwin(eo),
|
|
||||||
|
EoSetShadow(sw, 0);
|
||||||
|
EoSetFade(sw, 0);
|
||||||
|
EoSetFloating(sw, 1);
|
||||||
|
EoSetLayer(sw, 18);
|
||||||
|
ESetWindowBackground(EoGetWin(sw), _ShapeGetColor());
|
||||||
|
#ifdef ShapeInput /* Should really check server too */
|
||||||
|
XShapeCombineRectangles(disp, EoGetXwin(sw),
|
||||||
ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
|
ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted);
|
||||||
#endif
|
#endif
|
||||||
return eo;
|
|
||||||
|
if (md == 1)
|
||||||
|
{
|
||||||
|
sw->mask = ECreatePixmap(EoGetWin(sw), VRoot.w, VRoot.h, 1);
|
||||||
|
sw->gc = EXCreateGC(sw->mask, 0, NULL);
|
||||||
|
if (sw->mask == None || !sw->gc)
|
||||||
|
goto bail_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sw;
|
||||||
|
|
||||||
|
bail_out:
|
||||||
|
_ShapeWinDestroy(sw);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ShapeSetBox(EObj * eo, int x, int y, int w, int h,
|
_ShapeSet(ShapeWin * sw, int md, int x, int y, int w, int h,
|
||||||
int bl, int br, int bt, int bb, int seqno)
|
int bl, int br, int bt, int bb, int seqno)
|
||||||
{
|
{
|
||||||
XRectangle rl[8];
|
|
||||||
int w2, h2;
|
int w2, h2;
|
||||||
|
|
||||||
w2 = w + bl + br;
|
w2 = w + bl + br;
|
||||||
h2 = h + bt + bb;
|
h2 = h + bt + bb;
|
||||||
|
|
||||||
_SHAPE_SET_RECT((&rl[0]), x, y, w2, h2);
|
if (md == 1)
|
||||||
w = (w > 5) ? w - 2 : 3;
|
{
|
||||||
h = (h > 5) ? h - 2 : 3;
|
char str[32];
|
||||||
_SHAPE_SET_RECT((&rl[4]), x + bl + 1, y + bt + 1, w, h);
|
|
||||||
|
|
||||||
EShapeCombineRectangles(EobjGetWin(eo), ShapeBounding, 0, 0, rl,
|
XSetForeground(disp, sw->gc, 0);
|
||||||
8, (seqno == 0) ? ShapeSet : ShapeUnion, Unsorted);
|
XFillRectangle(disp, sw->mask, sw->gc, 0, 0, VRoot.w, VRoot.h);
|
||||||
EobjShapeUpdate(eo, 0);
|
XSetForeground(disp, sw->gc, 1);
|
||||||
|
DO_DRAW_MODE_1(sw->mask, sw->gc, x, y, w, h);
|
||||||
|
EShapeCombineMask(EoGetWin(sw), ShapeBounding, 0, 0, sw->mask,
|
||||||
|
(seqno == 0) ? ShapeSet : ShapeUnion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XRectangle rl[8];
|
||||||
|
|
||||||
|
_SHAPE_SET_RECT((&rl[0]), x, y, w2, h2);
|
||||||
|
w = (w > 5) ? w - 2 : 3;
|
||||||
|
h = (h > 5) ? h - 2 : 3;
|
||||||
|
_SHAPE_SET_RECT((&rl[4]), x + bl + 1, y + bt + 1, w, h);
|
||||||
|
|
||||||
|
EShapeCombineRectangles(EoGetWin(sw), ShapeBounding, 0, 0, rl,
|
||||||
|
8, (seqno == 0) ? ShapeSet : ShapeUnion,
|
||||||
|
Unsorted);
|
||||||
|
}
|
||||||
|
EoShapeUpdate(sw, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -189,7 +247,6 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h,
|
||||||
{
|
{
|
||||||
static GC gc = 0;
|
static GC gc = 0;
|
||||||
static Pixmap b2 = 0, b3 = 0;
|
static Pixmap b2 = 0, b3 = 0;
|
||||||
static Font font = 0;
|
|
||||||
Window root = VRoot.xwin;
|
Window root = VRoot.xwin;
|
||||||
int x1, y1, w1, h1, i, j, dx, dy;
|
int x1, y1, w1, h1, i, j, dx, dy;
|
||||||
int bl, br, bt, bb;
|
int bl, br, bt, bb;
|
||||||
|
@ -256,22 +313,23 @@ DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h,
|
||||||
|
|
||||||
EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
|
EwinBorderGetSize(ewin, &bl, &br, &bt, &bb);
|
||||||
|
|
||||||
if (md == 2 && !Conf.movres.old_mode)
|
if (md <= 2 && !Conf.movres.old_mode)
|
||||||
{
|
{
|
||||||
static EObj *shape_win = NULL;
|
static ShapeWin *shape_win = NULL;
|
||||||
|
|
||||||
if (firstlast == 0 && !shape_win)
|
if (firstlast == 0 && !shape_win)
|
||||||
shape_win = _ShapeCreateWin();
|
shape_win = _ShapeWinCreate(md);
|
||||||
if (!shape_win)
|
if (!shape_win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_ShapeSetBox(shape_win, x, y, w, h, bl, br, bt, bb, seqno);
|
_ShapeSet(shape_win, md, x, y, w, h, bl, br, bt, bb, seqno);
|
||||||
EobjMap(shape_win, 0);
|
EoMap(shape_win, 0);
|
||||||
|
|
||||||
CoordsShow(ewin);
|
CoordsShow(ewin);
|
||||||
|
|
||||||
if (firstlast == 2)
|
if (firstlast == 2)
|
||||||
{
|
{
|
||||||
EobjDestroy(shape_win);
|
_ShapeWinDestroy(shape_win);
|
||||||
shape_win = NULL;
|
shape_win = NULL;
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
|
|
|
@ -50,7 +50,7 @@ _NeedServerGrab(int mode)
|
||||||
{
|
{
|
||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (mode == 2)
|
if (mode <= 2)
|
||||||
return Conf.movres.old_mode;
|
return Conf.movres.old_mode;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue