mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +01:00
fixes to comply to ANSI C
This commit is contained in:
@@ -625,6 +625,8 @@ WMPoint wmkpoint(int x, int y);
|
|||||||
|
|
||||||
WMSize wmksize(unsigned int width, unsigned int height);
|
WMSize wmksize(unsigned int width, unsigned int height);
|
||||||
|
|
||||||
|
WMRect wmkrect(int x, int y, unsigned int width, unsigned int height);
|
||||||
|
|
||||||
#ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY
|
#ifdef ANSI_C_DOESNT_LIKE_IT_THIS_WAY
|
||||||
#define wmksize(width, height) (WMSize){(width), (height)}
|
#define wmksize(width, height) (WMSize){(width), (height)}
|
||||||
#define wmkpoint(x, y) (WMPoint){(x), (y)}
|
#define wmkpoint(x, y) (WMPoint){(x), (y)}
|
||||||
|
|||||||
@@ -1615,7 +1615,9 @@ WMReadPropListFromFile(char *file)
|
|||||||
pldata->lineNumber = 1;
|
pldata->lineNumber = 1;
|
||||||
|
|
||||||
if (fread(pldata->ptr, length, 1, f) != 1) {
|
if (fread(pldata->ptr, length, 1, f) != 1) {
|
||||||
|
if (ferror(f)) {
|
||||||
wsyserror(_("error reading from file '%s'"), file);
|
wsyserror(_("error reading from file '%s'"), file);
|
||||||
|
}
|
||||||
plist = NULL;
|
plist = NULL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,18 @@ wmksize(unsigned int width, unsigned int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WMRect
|
||||||
|
wmkrect(int x, int y, unsigned int width, unsigned int height)
|
||||||
|
{
|
||||||
|
WMRect rect;
|
||||||
|
|
||||||
|
rect.pos.x = x;
|
||||||
|
rect.pos.y = y;
|
||||||
|
rect.size.width = width;
|
||||||
|
rect.size.height = height;
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -415,11 +415,11 @@ wMaximizeWindow(WWindow *wwin, int directions)
|
|||||||
if (WFLAGP(wwin, no_resizable))
|
if (WFLAGP(wwin, no_resizable))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
usableArea = totalArea = (WArea){
|
totalArea.x1 = 0;
|
||||||
0, 0,
|
totalArea.y1 = 0;
|
||||||
wwin->screen_ptr->scr_width,
|
totalArea.x2 = wwin->screen_ptr->scr_width;
|
||||||
wwin->screen_ptr->scr_height
|
totalArea.y2 = wwin->screen_ptr->scr_height;
|
||||||
};
|
usableArea = totalArea;
|
||||||
|
|
||||||
if (!(directions & MAX_IGNORE_XINERAMA)) {
|
if (!(directions & MAX_IGNORE_XINERAMA)) {
|
||||||
WScreen *scr = wwin->screen_ptr;
|
WScreen *scr = wwin->screen_ptr;
|
||||||
@@ -1524,7 +1524,7 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
|
|||||||
int head;
|
int head;
|
||||||
const int heads = wXineramaHeads(scr);
|
const int heads = wXineramaHeads(scr);
|
||||||
|
|
||||||
struct {
|
struct HeadVars {
|
||||||
int pf; /* primary axis */
|
int pf; /* primary axis */
|
||||||
int sf; /* secondary axis */
|
int sf; /* secondary axis */
|
||||||
int fullW;
|
int fullW;
|
||||||
@@ -1534,16 +1534,18 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
|
|||||||
int sw, sh;
|
int sw, sh;
|
||||||
int xo, yo;
|
int xo, yo;
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
} vars[heads];
|
} *vars;
|
||||||
|
|
||||||
int isize = wPreferences.icon_size;
|
int isize = wPreferences.icon_size;
|
||||||
|
|
||||||
|
vars = (struct HeadVars*)wmalloc(sizeof(struct HeadVars)*heads);
|
||||||
|
|
||||||
for (head = 0; head < heads; ++head) {
|
for (head = 0; head < heads; ++head) {
|
||||||
#if 0
|
#if 0
|
||||||
WMRect rect = wGetRectForHead(scr, head);
|
WMRect rect = wGetRectForHead(scr, head);
|
||||||
#else
|
#else
|
||||||
WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
|
WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
|
||||||
WMRect rect = (WMRect){ area.x1, area.y1, area.x2-area.x1, area.y2-area.y1 };
|
WMRect rect = wmkrect(area.x1, area.y1, area.x2-area.x1, area.y2-area.y1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vars[head].pi = vars[head].si = 0;
|
vars[head].pi = vars[head].si = 0;
|
||||||
@@ -1674,6 +1676,8 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
|
|||||||
/* we reversed the order, so we use next */
|
/* we reversed the order, so we use next */
|
||||||
wwin = wwin->next;
|
wwin = wwin->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wfree(vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
@@ -3195,7 +3195,7 @@ setIconTitleBack(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo)
|
|||||||
if (scr->icon_title_texture) {
|
if (scr->icon_title_texture) {
|
||||||
wTextureDestroy(scr, (WTexture*)scr->icon_title_texture);
|
wTextureDestroy(scr, (WTexture*)scr->icon_title_texture);
|
||||||
}
|
}
|
||||||
// ?? why is this necessary? color was already parsed and alloc'ed
|
/* // ?? why is this necessary? color was already parsed and alloc'ed */
|
||||||
XQueryColor (dpy, scr->w_colormap, color);
|
XQueryColor (dpy, scr->w_colormap, color);
|
||||||
scr->icon_title_texture = wTextureMakeSolid(scr, color);
|
scr->icon_title_texture = wTextureMakeSolid(scr, color);
|
||||||
|
|
||||||
@@ -3464,6 +3464,7 @@ setKeyGrab(WScreen *scr, WDefaultEntry *entry, WShortKey *shortcut, long index)
|
|||||||
static int
|
static int
|
||||||
setIconPosition(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo)
|
setIconPosition(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo)
|
||||||
{
|
{
|
||||||
|
wScreenUpdateUsableArea(scr);
|
||||||
wArrangeIcons(scr, True);
|
wArrangeIcons(scr, True);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -2646,7 +2646,7 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y,
|
|||||||
static int
|
static int
|
||||||
onScreen(WScreen *scr, int x, int y, int sx, int ex, int sy, int ey)
|
onScreen(WScreen *scr, int x, int y, int sx, int ex, int sy, int ey)
|
||||||
{
|
{
|
||||||
WMRect rect = {x, y, ICON_SIZE, ICON_SIZE};
|
WMRect rect = wmkrect(x, y, ICON_SIZE, ICON_SIZE);
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
wGetRectPlacementInfo(scr, rect, &flags);
|
wGetRectPlacementInfo(scr, rect, &flags);
|
||||||
|
|||||||
@@ -1726,7 +1726,7 @@ handleMotionNotify(XEvent *event)
|
|||||||
WScreen *scr = wScreenForRootWindow(event->xmotion.root);
|
WScreen *scr = wScreenForRootWindow(event->xmotion.root);
|
||||||
|
|
||||||
if (wPreferences.scrollable_menus) {
|
if (wPreferences.scrollable_menus) {
|
||||||
WMPoint p = { event->xmotion.x_root, event->xmotion.y_root };
|
WMPoint p = wmkpoint(event->xmotion.x_root, event->xmotion.y_root);
|
||||||
WMRect rect = wGetRectForHead(scr, wGetHeadForPoint(scr, p));
|
WMRect rect = wGetRectForHead(scr, wGetHeadForPoint(scr, p));
|
||||||
|
|
||||||
if (scr->flags.jump_back_pending ||
|
if (scr->flags.jump_back_pending ||
|
||||||
|
|||||||
14
src/menu.c
14
src/menu.c
@@ -1746,9 +1746,10 @@ isPointNearBoder(WMenu *menu, int x, int y)
|
|||||||
int menuX2 = menu->frame_x + MENUW(menu);
|
int menuX2 = menu->frame_x + MENUW(menu);
|
||||||
int menuY2 = menu->frame_y + MENUH(menu);
|
int menuY2 = menu->frame_y + MENUH(menu);
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
/* XXX: handle screen joins proper !! */
|
int head = wGetHeadForPoint(menu->frame->screen_ptr, wmkpoint(x, y));
|
||||||
WMRect rect = wGetRectForHead(menu->frame->screen_ptr,
|
WMRect rect = wGetRectForHead(menu->frame->screen_ptr, head);
|
||||||
wGetHeadForPoint(menu->frame->screen_ptr, (WMPoint){ x, y}));
|
|
||||||
|
/* XXX: handle screen joins properly !! */
|
||||||
|
|
||||||
if (x >= menuX1 && x <= menuX2 &&
|
if (x >= menuX1 && x <= menuX2 &&
|
||||||
(y < rect.pos.y + MENU_SCROLL_BORDER ||
|
(y < rect.pos.y + MENU_SCROLL_BORDER ||
|
||||||
@@ -1764,14 +1765,13 @@ isPointNearBoder(WMenu *menu, int x, int y)
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _delay {
|
typedef struct _delay {
|
||||||
WWindow *wwin;
|
|
||||||
WMenu *menu;
|
WMenu *menu;
|
||||||
int ox, oy;
|
int ox, oy;
|
||||||
} _delay;
|
} _delay;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_leaving(_delay *dl)
|
leaving(_delay *dl)
|
||||||
{
|
{
|
||||||
wMenuMove(dl->menu, dl->ox, dl->oy, True);
|
wMenuMove(dl->menu, dl->ox, dl->oy, True);
|
||||||
dl->menu->jump_back = NULL;
|
dl->menu->jump_back = NULL;
|
||||||
@@ -1832,7 +1832,7 @@ wMenuScroll(WMenu *menu, XEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rect = wGetRectForHead(scr, wGetHeadForPoint(scr, (WMPoint){ x, y }));
|
rect = wGetRectForHead(scr, wGetHeadForPoint(scr, wmkpoint(x, y)));
|
||||||
on_x_edge = x <= rect.pos.x + 1 || x >= rect.pos.x + rect.size.width - 2;
|
on_x_edge = x <= rect.pos.x + 1 || x >= rect.pos.x + rect.size.width - 2;
|
||||||
on_y_edge = y <= rect.pos.y + 1 || y >= rect.pos.y + rect.size.height - 2;
|
on_y_edge = y <= rect.pos.y + 1 || y >= rect.pos.y + rect.size.height - 2;
|
||||||
on_border = on_x_edge || on_y_edge;
|
on_border = on_x_edge || on_y_edge;
|
||||||
@@ -1892,7 +1892,7 @@ wMenuScroll(WMenu *menu, XEvent *event)
|
|||||||
scr->flags.jump_back_pending = 1;
|
scr->flags.jump_back_pending = 1;
|
||||||
}
|
}
|
||||||
else delayer = omenu->jump_back;
|
else delayer = omenu->jump_back;
|
||||||
WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)_leaving, delayer);
|
WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)leaving, delayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,22 +141,18 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head)
|
|||||||
int isize = wPreferences.icon_size;
|
int isize = wPreferences.icon_size;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
WMBagIterator iter;
|
WMBagIterator iter;
|
||||||
/*
|
|
||||||
* Find out screen boundaries.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allows each head to have miniwindows
|
|
||||||
*/
|
|
||||||
WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
|
WArea area = wGetUsableAreaForHead(scr, head, NULL, False);
|
||||||
WMRect rect = (WMRect){ area.x1, area.y1, area.x2-area.x1, area.y2-area.y1 };
|
|
||||||
|
|
||||||
sx1 = rect.pos.x;
|
/* Find out screen boundaries. */
|
||||||
sy1 = rect.pos.y;
|
|
||||||
sw = rect.size.width;
|
/* Allows each head to have miniwindows */
|
||||||
sh = rect.size.height;
|
|
||||||
sx2 = sx1 + sw;
|
sx1 = area.x1;
|
||||||
sy2 = sy1 + sh;
|
sy1 = area.y1;
|
||||||
|
sx2 = area.x2;
|
||||||
|
sy2 = area.y2;
|
||||||
|
sw = sx2-sx1;
|
||||||
|
sh = sy2-sy1;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (scr->dock) {
|
if (scr->dock) {
|
||||||
|
|||||||
34
src/screen.c
34
src/screen.c
@@ -624,8 +624,8 @@ wScreenInit(int screen_number)
|
|||||||
|
|
||||||
wInitXinerama(scr);
|
wInitXinerama(scr);
|
||||||
|
|
||||||
scr->usableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: checl NULL */
|
scr->usableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr));
|
||||||
scr->totalUsableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: */
|
scr->totalUsableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr));
|
||||||
|
|
||||||
for (i=0; i<wXineramaHeads(scr); ++i) {
|
for (i=0; i<wXineramaHeads(scr); ++i) {
|
||||||
WMRect rect = wGetRectForHead(scr, i);
|
WMRect rect = wGetRectForHead(scr, i);
|
||||||
@@ -839,7 +839,8 @@ wScreenUpdateUsableArea(WScreen *scr)
|
|||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* scr->totalUsableArea[] will become the usableArea used for Windowplacement,
|
* scr->totalUsableArea[] will become the usableArea used for Windowplacement,
|
||||||
* scr->usableArea[] will be used for iconplacement, hence no iconyard nor border.
|
* scr->usableArea[] will be used for iconplacement, hence no iconyard nor
|
||||||
|
* border.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -848,18 +849,20 @@ wScreenUpdateUsableArea(WScreen *scr)
|
|||||||
int dock_head = scr->xine_info.primary_head;
|
int dock_head = scr->xine_info.primary_head;
|
||||||
|
|
||||||
if (scr->dock) {
|
if (scr->dock) {
|
||||||
WMRect rect = { scr->dock->x_pos, scr->dock->y_pos, wPreferences.icon_size, wPreferences.icon_size };
|
WMRect rect;
|
||||||
|
rect.pos.x = scr->dock->x_pos;
|
||||||
|
rect.pos.y = scr->dock->y_pos;
|
||||||
|
rect.size.width = wPreferences.icon_size;
|
||||||
|
rect.size.height = wPreferences.icon_size;
|
||||||
dock_head = wGetHeadForRect(scr, rect);
|
dock_head = wGetHeadForRect(scr, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<wXineramaHeads(scr); ++i) {
|
for (i=0; i<wXineramaHeads(scr); ++i) {
|
||||||
WMRect rect = wGetRectForHead(scr, i);
|
WMRect rect = wGetRectForHead(scr, i);
|
||||||
scr->totalUsableArea[i] = (WArea){
|
scr->totalUsableArea[i].x1 = rect.pos.x;
|
||||||
rect.pos.x,
|
scr->totalUsableArea[i].y1 = rect.pos.y;
|
||||||
rect.pos.y,
|
scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width;
|
||||||
rect.pos.x + rect.size.width,
|
scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height;
|
||||||
rect.pos.y + rect.size.height
|
|
||||||
};
|
|
||||||
|
|
||||||
if (scr->dock && dock_head==i &&
|
if (scr->dock && dock_head==i &&
|
||||||
(!scr->dock->lowered || wPreferences.no_window_over_dock)) {
|
(!scr->dock->lowered || wPreferences.no_window_over_dock)) {
|
||||||
@@ -912,18 +915,16 @@ wScreenUpdateUsableArea(WScreen *scr)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("usableArea[%d]: %d %d %d %d\n", i,
|
printf("usableArea[%d]: %d %d %d %d\n", i,
|
||||||
scr->usableArea[i].x1,
|
scr->usableArea[i].x1, scr->usableArea[i].x2,
|
||||||
scr->usableArea[i].x2,
|
scr->usableArea[i].y1, scr->usableArea[i].y2);
|
||||||
scr->usableArea[i].y1,
|
|
||||||
scr->usableArea[i].y2);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wPreferences.no_window_over_icons) {
|
if (wPreferences.no_window_over_icons) {
|
||||||
if (wPreferences.icon_yard & IY_VERT) {
|
if (wPreferences.icon_yard & IY_VERT) {
|
||||||
if (wPreferences.icon_yard & IY_RIGHT) {
|
if (wPreferences.icon_yard & IY_RIGHT) {
|
||||||
scr->totalUsableArea[i].x1 += wPreferences.icon_size;
|
|
||||||
} else {
|
|
||||||
scr->totalUsableArea[i].x2 -= wPreferences.icon_size;
|
scr->totalUsableArea[i].x2 -= wPreferences.icon_size;
|
||||||
|
} else {
|
||||||
|
scr->totalUsableArea[i].x1 += wPreferences.icon_size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (wPreferences.icon_yard & IY_TOP) {
|
if (wPreferences.icon_yard & IY_TOP) {
|
||||||
@@ -938,6 +939,7 @@ wScreenUpdateUsableArea(WScreen *scr)
|
|||||||
scr->totalUsableArea[i].x1 = rect.pos.x;
|
scr->totalUsableArea[i].x1 = rect.pos.x;
|
||||||
scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width;
|
scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) {
|
if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) {
|
||||||
scr->totalUsableArea[i].y1 = rect.pos.y;
|
scr->totalUsableArea[i].y1 = rect.pos.y;
|
||||||
scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height;
|
scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height;
|
||||||
|
|||||||
@@ -3005,7 +3005,8 @@ wWindowDeleteSavedStatesForPID(pid_t pid)
|
|||||||
void
|
void
|
||||||
wWindowSetOmnipresent(WWindow *wwin, Bool flag)
|
wWindowSetOmnipresent(WWindow *wwin, Bool flag)
|
||||||
{
|
{
|
||||||
if ( wwin->flags.omnipresent == flag) return;
|
if (wwin->flags.omnipresent == flag)
|
||||||
|
return;
|
||||||
|
|
||||||
wwin->flags.omnipresent = flag;
|
wwin->flags.omnipresent = flag;
|
||||||
WMPostNotificationName(WMNChangedState, wwin, "omnipresent");
|
WMPostNotificationName(WMNChangedState, wwin, "omnipresent");
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ WArea wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool no
|
|||||||
|
|
||||||
WMPoint wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height);
|
WMPoint wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height);
|
||||||
|
|
||||||
|
Bool wWindowTouchesHead(WWindow *wwin, int head);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user