Wmfs: Replace XRectangle by Geo (using int instead short)

This commit is contained in:
Martin Duquesnoy 2011-06-06 17:37:31 +02:00
parent eeedd9e4be
commit e4dbca928d
11 changed files with 78 additions and 71 deletions

View File

@ -46,8 +46,8 @@ BarWindow*
barwin_create(Window parent,
int x,
int y,
uint w,
uint h,
int w,
int h,
uint bg,
char *fg,
Bool entermask,
@ -269,7 +269,7 @@ barwin_move(BarWindow *bw, int x, int y)
* \param h Height
*/
void
barwin_resize(BarWindow *bw, uint w, uint h)
barwin_resize(BarWindow *bw, int w, int h)
{
if(!bw || (bw->geo.width == w && bw->geo.height == h))
return;

View File

@ -67,10 +67,10 @@ cfactor_clean(Client *c)
*\param c Client pointer
*\return geo
*/
XRectangle
cfactor_geo(XRectangle geo, int fact[4], int *err)
Geo
cfactor_geo(Geo geo, int fact[4], int *err)
{
XRectangle cgeo = geo;
Geo cgeo = geo;
*err = 0;
@ -105,7 +105,7 @@ cfactor_geo(XRectangle geo, int fact[4], int *err)
*\param p Direction of resizing
*/
Bool
cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p)
cfactor_parentrow(Geo cg, Geo ccg, Position p)
{
switch(p)
{
@ -131,7 +131,7 @@ cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p)
static void
_cfactor_arrange_row(Client *c, Position p, int fac)
{
XRectangle cgeo = c->frame_geo;
Geo cgeo = c->frame_geo;
Client *cc;
/* Travel clients to search parents of row and apply fact */
@ -154,7 +154,7 @@ _cfactor_arrange_row(Client *c, Position p, int fac)
static Bool
_cfactor_check_geo_row(Client *c, Position p, int fac)
{
XRectangle cgeo = c->frame_geo;
Geo cgeo = c->frame_geo;
Client *cc;
int e, f[4] = { 0 };
@ -164,7 +164,7 @@ _cfactor_check_geo_row(Client *c, Position p, int fac)
for(cc = tiled_client(c->screen, clients); cc; cc = tiled_client(c->screen, cc->next))
if(cfactor_parentrow(cgeo, cc->frame_geo, p))
{
(XRectangle)cfactor_geo(cc->wrgeo, f, &e);
(Geo)cfactor_geo(cc->wrgeo, f, &e);
if(e)
return False;
}
@ -205,7 +205,7 @@ cfactor_arrange_two(Client *c1, Client *c2, Position p, int fac)
*\returm 1/0
*/
Bool
cfactor_check_2pc(XRectangle g1, XRectangle g2, Position p)
cfactor_check_2pc(Geo g1, Geo g2, Position p)
{
if(LDIR(p))
return (g1.height == g2.height);
@ -249,8 +249,8 @@ cfactor_check_geo(Client *c, Client *g, Position p, int fac)
cf[p] += fac;
gf[RPOS(p)] -= fac;
(XRectangle)cfactor_geo(c->geo, cf, &e);
(XRectangle)cfactor_geo(g->geo, gf, &ee);
(Geo)cfactor_geo(c->geo, cf, &e);
(Geo)cfactor_geo(g->geo, gf, &ee);
/* Size failure */
if(e || ee || !_cfactor_check_geo_row(c, p, fac)

View File

@ -217,7 +217,7 @@ client_get_next_with_direction(Client *bc, Position pos)
static void
client_above(Client *c)
{
XRectangle geo;
Geo geo;
memset(&geo, 0, sizeof(geo));
@ -728,7 +728,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
if(conf.client_auto_center)
{
XRectangle tmp;
Geo tmp;
tmp = screen_get_geo(selscreen);
mx = (tmp.width + mx - wa->width) >> 1;
my = (tmp.height + my - wa->height) >> 1;
@ -816,7 +816,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
*\param c Client pointer
*/
void
client_geo_hints(XRectangle *geo, Client *c)
client_geo_hints(Geo *geo, Client *c)
{
/* minimum possible */
if(geo->width < 1)
@ -866,7 +866,7 @@ client_geo_hints(XRectangle *geo, Client *c)
* \param r Bool for resize hint or not
*/
void
client_moveresize(Client *c, XRectangle geo, Bool r)
client_moveresize(Client *c, Geo geo, Bool r)
{
int os, e;
int rhx = 0;
@ -1257,7 +1257,7 @@ static void
client_set_screen(Client *c, int s)
{
int os;
XRectangle geo;
Geo geo;
if(!c || s < 0 || s > screen_count() - 1 || s == c->screen)
return;
@ -1340,7 +1340,7 @@ uicb_client_screen_set(uicb_t cmd)
void
uicb_client_move(uicb_t cmd)
{
XRectangle geo;
Geo geo;
int xi = 0, yi = 0;
if(!sel || sel->flags & (TileFlag | MaxFlag | LMaxFlag | FSSFlag))
@ -1365,7 +1365,7 @@ uicb_client_move(uicb_t cmd)
void
uicb_client_resize(uicb_t cmd)
{
XRectangle geo;
Geo geo;
int wi = 0, hi = 0;
if(!sel || sel->flags & (TileFlag | MaxFlag | LMaxFlag | FSSFlag))

View File

@ -156,7 +156,7 @@ draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image
* \param color Color of the rectangle
*/
void
draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
draw_rectangle(Drawable dr, int x, int y, int w, int h, uint color)
{
XRectangle r = { x, y, w, h };
@ -176,7 +176,7 @@ draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
* \param data Array of bytes that will be draw
*/
void
draw_graph(Drawable dr, int x, int y, uint w, uint h, uint color, char *data)
draw_graph(Drawable dr, int x, int y, int w, int h, uint color, char *data)
{
uint i;

View File

@ -158,7 +158,7 @@ frame_delete(Client *c)
* \param geo Coordinate info for move the frame
*/
void
frame_moveresize(Client *c, XRectangle geo)
frame_moveresize(Client *c, Geo geo)
{
CHECK(c);

View File

@ -259,8 +259,8 @@ static void
grid(int screen, Bool horizontal)
{
Client *c;
XRectangle sg = sgeo[screen];
XRectangle cgeo = {sg.x, sg.y, 0, 0};
Geo sg = sgeo[screen];
Geo cgeo = {sg.x, sg.y, 0, 0};
unsigned int i, n, temp, cols, rows, cpcols = 0;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
@ -328,9 +328,9 @@ static void
multi_tile(int screen, Position type)
{
Client *c;
XRectangle sg = sgeo[screen];
XRectangle mastergeo = {sg.x, sg.y, 0, 0};
XRectangle cgeo = {sg.x, sg.y, 0, 0};
Geo sg = sgeo[screen];
Geo mastergeo = {sg.x, sg.y, 0, 0};
Geo cgeo = {sg.x, sg.y, 0, 0};
uint i, n, tilesize = 0, mwfact, nmaster = tags[screen][seltag[screen]].nmaster;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
@ -460,10 +460,10 @@ static void
mirror(int screen, Bool horizontal)
{
Client *c;
XRectangle sg = sgeo[screen];
XRectangle mastergeo = {sg.x, sg.y, sg.width, sg.height};
XRectangle cgeo = {sg.x, sg.y , sg.width, sg.height};
XRectangle nextg[2];
Geo sg = sgeo[screen];
Geo mastergeo = {sg.x, sg.y, sg.width, sg.height};
Geo cgeo = {sg.x, sg.y , sg.width, sg.height};
Geo nextg[2];
uint i, n, tilesize = 0, mwfact;
uint nmaster = tags[screen][seltag[screen]].nmaster;
int pa, imp;

View File

@ -37,7 +37,7 @@ Window prevwin;
/** Draw the border when a client in dragging/resizing with mouse
*/
static void
mouse_dragborder(XRectangle geo, GC g)
mouse_dragborder(Geo geo, GC g)
{
XDrawRectangle(dpy, ROOT, g,
geo.x - (BORDH >> 1),
@ -130,7 +130,7 @@ mouse_move(Client *c)
int dint;
uint duint;
Window dw;
XRectangle geo = c->geo;
Geo geo = c->geo;
XGCValues xgc;
GC gci;
XEvent ev;
@ -211,7 +211,7 @@ mouse_move(Client *c)
void
mouse_resize(Client *c)
{
XRectangle geo = c->geo, ogeo = c->geo;
Geo geo = c->geo, ogeo = c->geo;
Position pos = Right;
XEvent ev;
Window w;

View File

@ -57,13 +57,13 @@ screen_count(void)
/** Get screen geometry by number
*\param s Screen number
*\return XRectangle struct
*\return Geo struct
*/
XRectangle
Geo
screen_get_geo(int s)
{
int barpos = tags[selscreen][seltag[selscreen]].barpos;
XRectangle geo;
Geo geo;
geo.x = BORDH;
if(barpos == IB_Hide || barpos == IB_Bottom)
@ -179,8 +179,8 @@ screen_init_geo(void)
int i;
int s = screen_count();
sgeo = xcalloc(s, sizeof(XRectangle));
spgeo = xcalloc(s, sizeof(XRectangle));
sgeo = xcalloc(s, sizeof(Geo));
spgeo = xcalloc(s, sizeof(Geo));
for(i = 0; i < s; ++i)
sgeo[i] = screen_get_geo(i);

View File

@ -49,7 +49,7 @@ SPLIT_MOVE_DIR(Bottom);
/** Arrange size of parent client of last closed client
*/
static void
_split_arrange_size(XRectangle g, XRectangle *cg, Position p)
_split_arrange_size(Geo g, Geo *cg, Position p)
{
if(LDIR(p))
cg->width += FRAMEW(g.width);
@ -68,7 +68,7 @@ _split_arrange_size(XRectangle g, XRectangle *cg, Position p)
/** Check if parent client of last closed client is OK for row resize
*/
static Bool
_split_check_row(XRectangle g1, XRectangle g2, Position p)
_split_check_row(Geo g1, Geo g2, Position p)
{
if(LDIR(p))
return (g1.y >= g2.y && (g1.y + g1.height) <= (g2.y + g2.height));
@ -128,7 +128,7 @@ static Bool
_split_check_row_dir(Client *c, Client *g, Position p)
{
int s, cs;
XRectangle cgeo;
Geo cgeo;
Client *cc;
cs = (LDIR(p) ? g->frame_geo.height : g->frame_geo.width);
@ -157,7 +157,7 @@ split_arrange_closed(Client *ghost)
{
Position p;
Bool b = False;
XRectangle cgeo;
Geo cgeo;
Client *c, *cc;
int screen = ghost->screen;
int tag = (ghost->tag ? ghost->tag : seltag[screen]);
@ -223,10 +223,10 @@ split_arrange_closed(Client *ghost)
*\param p True = Vertical, False = Horizontal
*\return sgeo Geo of future integrated client
*/
XRectangle
Geo
split_client(Client *c, Bool p)
{
XRectangle geo, sgeo;
Geo geo, sgeo;
if(!c || !(c->flags & TileFlag))
return c->wrgeo;
@ -270,7 +270,7 @@ split_client(Client *c, Bool p)
*\param geo New geo
*/
void
split_client_fill(Client *c, XRectangle geo)
split_client_fill(Client *c, Geo geo)
{
if(!c)
return;
@ -292,7 +292,7 @@ void
split_client_integrate(Client *c, Client *sc, int screen, int tag)
{
Bool b = True;
XRectangle g;
Geo g;
if(!c || c->flags & FreeFlag || !(tags[screen][tag].flags & SplitFlag))
return;

View File

@ -168,6 +168,13 @@ enum
net_last
};
/* Geometry structure */
typedef struct
{
int x, y;
int width, height;
} Geo;
/*
* BarWindow Structure
* (titlebar, infobar..)
@ -187,7 +194,7 @@ typedef struct
uint bg;
char *fg;
uint stipple_color;
XRectangle geo;
Geo geo;
Bool mapped, stipple, bord;
} BarWindow;
@ -203,11 +210,11 @@ struct Client
/* Screen */
int screen;
/* Window attribute */
XRectangle geo, pgeo; /* Window geo, tiling pure geo */
XRectangle tmp_geo, wrgeo; /* Temporary geo, without resizehint geo */
XRectangle frame_geo; /* Frame geo */
XRectangle ogeo; /* Old window attribute */
XRectangle split_geo, free_geo; /* Split & Free window attribute */
Geo geo, pgeo; /* Window geo, tiling pure geo */
Geo tmp_geo, wrgeo; /* Temporary geo, without resizehint geo */
Geo frame_geo; /* Frame geo */
Geo ogeo; /* Old window attribute */
Geo split_geo, free_geo; /* Split & Free window attribute */
/* Tile size factors */
int tilefact[4];
/* For resizehint usage */
@ -262,7 +269,7 @@ typedef struct
BarWindow *bar, *selbar;
BarWindow *layout_button;
BarWindow *tags_board, *tags[MAXTAG];
XRectangle geo;
Geo geo;
int position;
char *statustext;
Bool need_update;
@ -284,7 +291,7 @@ typedef struct Systray Systray;
struct Systray
{
Window win;
XRectangle geo;
Geo geo;
Systray *next, *prev;
};

View File

@ -117,7 +117,7 @@
/* barwin.c */
BarWindow *barwin_create(Window parent,
int x, int y,
uint w, uint h,
int w, int h,
uint bg, char*fg,
Bool entermask,
Bool stipple,
@ -132,15 +132,15 @@ void barwin_map_subwin(BarWindow *bw);
void barwin_unmap(BarWindow *bw);
void barwin_unmap_subwin(BarWindow *bw);
void barwin_move(BarWindow *bw, int x, int y);
void barwin_resize(BarWindow *bw, uint w, uint h);
void barwin_resize(BarWindow *bw, int w, int h);
void barwin_refresh_color(BarWindow *bw);
void barwin_refresh(BarWindow *bw);
/* draw.c */
void draw_text(Drawable d, int x, int y, char* fg, char *str);
void draw_image_ofset_text(Drawable d, int x, int y, char* fg, char *str, int x_image_ofset, int y_image_ofset);
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
void draw_graph(Drawable dr, int x, int y, uint w, uint h, uint color, char *data);
void draw_rectangle(Drawable dr, int x, int y, int w, int h, uint color);
void draw_graph(Drawable dr, int x, int y, int w, int h, uint color, char *data);
ushort textw(char *text);
@ -159,9 +159,9 @@ void uicb_toggle_tagautohide(uicb_t);
/* cfactor.c */
void cfactor_clean(Client *c);
XRectangle cfactor_geo(XRectangle geo, int fact[4], int *err);
Bool cfactor_check_2pc(XRectangle g1, XRectangle g2, Position p);
Bool cfactor_parentrow(XRectangle cg, XRectangle ccg, Position p);
Geo cfactor_geo(Geo geo, int fact[4], int *err);
Bool cfactor_check_2pc(Geo g1, Geo g2, Position p);
Bool cfactor_parentrow(Geo cg, Geo ccg, Position p);
void cfactor_set(Client *c, Position p, int fac);
void cfactor_multi_set(Client *c, int fac[4]);
/* Generated with macro {{{ */
@ -192,8 +192,8 @@ void client_kill(Client *c);
Bool ishide(Client *c, int screen);
void client_map(Client *c);
Client* client_manage(Window w, XWindowAttributes *wa, Bool ar);
void client_geo_hints(XRectangle *geo, Client *c);
void client_moveresize(Client *c, XRectangle geo, Bool r);
void client_geo_hints(Geo *geo, Client *c);
void client_moveresize(Client *c, Geo geo, Bool r);
void client_maximize(Client *c);
void client_size_hints(Client *c);
void client_swap(Client *c1, Client *c2);
@ -247,7 +247,7 @@ void ewmh_manage_window_type(Client *c);
/* frame.c */
void frame_create(Client *c);
void frame_delete(Client *c);
void frame_moveresize(Client *c, XRectangle geo);
void frame_moveresize(Client *c, Geo geo);
void frame_update_color(Client *c, Bool focused);
void frame_update(Client *c);
@ -338,7 +338,7 @@ void uicb_tag_toggle_expose(uicb_t cmd);
/* screen.c */
int screen_count(void);
XRectangle screen_get_geo(int s);
Geo screen_get_geo(int s);
int screen_get_with_geo(int x, int y);
int screen_get_sel(void);
void screen_set_sel(int screen);
@ -405,8 +405,8 @@ void split_store_geo(int screen, int tag);
void split_set_current(Client *nc, Client *ghost);
void split_apply_current(int screen, int tag);
void split_arrange_closed(Client *ghost);
XRectangle split_client(Client *c, Bool p);
void split_client_fill(Client *c, XRectangle geo);
Geo split_client(Client *c, Bool p);
void split_client_fill(Client *c, Geo geo);
void split_client_integrate(Client *c, Client *sc, int screen, int tag);
void split_move_dir(Client *c, Position p);
void uicb_split_toggle(uicb_t cmd);
@ -442,8 +442,8 @@ int prevselscreen;
Conf conf;
Key *keys;
Bool estatus;
XRectangle *sgeo;
XRectangle *spgeo;
Geo *sgeo;
Geo *spgeo;
Cursor cursor[CurLast];
char *argv_global;
char **all_argv;