1
0
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:
dan
2003-07-16 20:58:49 +00:00
parent bd7943d9a7
commit 8457611316
19 changed files with 838 additions and 817 deletions

View File

@@ -625,6 +625,8 @@ WMPoint wmkpoint(int x, int y);
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
#define wmksize(width, height) (WMSize){(width), (height)}
#define wmkpoint(x, y) (WMPoint){(x), (y)}

View File

@@ -1615,7 +1615,9 @@ WMReadPropListFromFile(char *file)
pldata->lineNumber = 1;
if (fread(pldata->ptr, length, 1, f) != 1) {
if (ferror(f)) {
wsyserror(_("error reading from file '%s'"), file);
}
plist = NULL;
goto cleanup;
}

View File

@@ -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;
}

View File

@@ -415,11 +415,11 @@ wMaximizeWindow(WWindow *wwin, int directions)
if (WFLAGP(wwin, no_resizable))
return;
usableArea = totalArea = (WArea){
0, 0,
wwin->screen_ptr->scr_width,
wwin->screen_ptr->scr_height
};
totalArea.x1 = 0;
totalArea.y1 = 0;
totalArea.x2 = wwin->screen_ptr->scr_width;
totalArea.y2 = wwin->screen_ptr->scr_height;
usableArea = totalArea;
if (!(directions & MAX_IGNORE_XINERAMA)) {
WScreen *scr = wwin->screen_ptr;
@@ -1524,7 +1524,7 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
int head;
const int heads = wXineramaHeads(scr);
struct {
struct HeadVars {
int pf; /* primary axis */
int sf; /* secondary axis */
int fullW;
@@ -1534,16 +1534,18 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
int sw, sh;
int xo, yo;
int xs, ys;
} vars[heads];
} *vars;
int isize = wPreferences.icon_size;
vars = (struct HeadVars*)wmalloc(sizeof(struct HeadVars)*heads);
for (head = 0; head < heads; ++head) {
#if 0
WMRect rect = wGetRectForHead(scr, head);
#else
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
vars[head].pi = vars[head].si = 0;
@@ -1674,6 +1676,8 @@ wArrangeIcons(WScreen *scr, Bool arrangeAll)
/* we reversed the order, so we use next */
wwin = wwin->next;
}
wfree(vars);
}
#if 0

View File

@@ -3195,7 +3195,7 @@ setIconTitleBack(WScreen *scr, WDefaultEntry *entry, XColor *color, void *foo)
if (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);
scr->icon_title_texture = wTextureMakeSolid(scr, color);
@@ -3464,6 +3464,7 @@ setKeyGrab(WScreen *scr, WDefaultEntry *entry, WShortKey *shortcut, long index)
static int
setIconPosition(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo)
{
wScreenUpdateUsableArea(scr);
wArrangeIcons(scr, True);
return 0;

View File

@@ -2646,7 +2646,7 @@ wDockSnapIcon(WDock *dock, WAppIcon *icon, int req_x, int req_y,
static int
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;
wGetRectPlacementInfo(scr, rect, &flags);

View File

@@ -1726,7 +1726,7 @@ handleMotionNotify(XEvent *event)
WScreen *scr = wScreenForRootWindow(event->xmotion.root);
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));
if (scr->flags.jump_back_pending ||

View File

@@ -1746,9 +1746,10 @@ isPointNearBoder(WMenu *menu, int x, int y)
int menuX2 = menu->frame_x + MENUW(menu);
int menuY2 = menu->frame_y + MENUH(menu);
int flag = 0;
/* XXX: handle screen joins proper !! */
WMRect rect = wGetRectForHead(menu->frame->screen_ptr,
wGetHeadForPoint(menu->frame->screen_ptr, (WMPoint){ x, y}));
int head = wGetHeadForPoint(menu->frame->screen_ptr, wmkpoint(x, y));
WMRect rect = wGetRectForHead(menu->frame->screen_ptr, head);
/* XXX: handle screen joins properly !! */
if (x >= menuX1 && x <= menuX2 &&
(y < rect.pos.y + MENU_SCROLL_BORDER ||
@@ -1764,14 +1765,13 @@ isPointNearBoder(WMenu *menu, int x, int y)
typedef struct _delay {
WWindow *wwin;
WMenu *menu;
int ox, oy;
} _delay;
static void
_leaving(_delay *dl)
leaving(_delay *dl)
{
wMenuMove(dl->menu, dl->ox, dl->oy, True);
dl->menu->jump_back = NULL;
@@ -1832,7 +1832,7 @@ wMenuScroll(WMenu *menu, XEvent *event)
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_y_edge = y <= rect.pos.y + 1 || y >= rect.pos.y + rect.size.height - 2;
on_border = on_x_edge || on_y_edge;
@@ -1892,7 +1892,7 @@ wMenuScroll(WMenu *menu, XEvent *event)
scr->flags.jump_back_pending = 1;
}
else delayer = omenu->jump_back;
WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)_leaving, delayer);
WMAddTimerHandler(MENU_JUMP_BACK_DELAY,(WMCallback*)leaving, delayer);
}
}

View File

@@ -141,22 +141,18 @@ PlaceIcon(WScreen *scr, int *x_ret, int *y_ret, int head)
int isize = wPreferences.icon_size;
int done = 0;
WMBagIterator iter;
/*
* Find out screen boundaries.
*/
/*
* Allows each head to have miniwindows
*/
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;
sy1 = rect.pos.y;
sw = rect.size.width;
sh = rect.size.height;
sx2 = sx1 + sw;
sy2 = sy1 + sh;
/* Find out screen boundaries. */
/* Allows each head to have miniwindows */
sx1 = area.x1;
sy1 = area.y1;
sx2 = area.x2;
sy2 = area.y2;
sw = sx2-sx1;
sh = sy2-sy1;
#if 0
if (scr->dock) {

View File

@@ -624,8 +624,8 @@ wScreenInit(int screen_number)
wInitXinerama(scr);
scr->usableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: checl NULL */
scr->totalUsableArea = (WArea *)wmalloc( sizeof(WArea)*wXineramaHeads(scr)); /* XXX: */
scr->usableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr));
scr->totalUsableArea = (WArea *)wmalloc(sizeof(WArea)*wXineramaHeads(scr));
for (i=0; i<wXineramaHeads(scr); ++i) {
WMRect rect = wGetRectForHead(scr, i);
@@ -839,7 +839,8 @@ wScreenUpdateUsableArea(WScreen *scr)
{
/*
* 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;
@@ -848,18 +849,20 @@ wScreenUpdateUsableArea(WScreen *scr)
int dock_head = scr->xine_info.primary_head;
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);
}
for (i=0; i<wXineramaHeads(scr); ++i) {
WMRect rect = wGetRectForHead(scr, i);
scr->totalUsableArea[i] = (WArea){
rect.pos.x,
rect.pos.y,
rect.pos.x + rect.size.width,
rect.pos.y + rect.size.height
};
scr->totalUsableArea[i].x1 = rect.pos.x;
scr->totalUsableArea[i].y1 = rect.pos.y;
scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width;
scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height;
if (scr->dock && dock_head==i &&
(!scr->dock->lowered || wPreferences.no_window_over_dock)) {
@@ -912,18 +915,16 @@ wScreenUpdateUsableArea(WScreen *scr)
#if 0
printf("usableArea[%d]: %d %d %d %d\n", i,
scr->usableArea[i].x1,
scr->usableArea[i].x2,
scr->usableArea[i].y1,
scr->usableArea[i].y2);
scr->usableArea[i].x1, scr->usableArea[i].x2,
scr->usableArea[i].y1, scr->usableArea[i].y2);
#endif
if (wPreferences.no_window_over_icons) {
if (wPreferences.icon_yard & IY_VERT) {
if (wPreferences.icon_yard & IY_RIGHT) {
scr->totalUsableArea[i].x1 += wPreferences.icon_size;
} else {
scr->totalUsableArea[i].x2 -= wPreferences.icon_size;
} else {
scr->totalUsableArea[i].x1 += wPreferences.icon_size;
}
} else {
if (wPreferences.icon_yard & IY_TOP) {
@@ -938,6 +939,7 @@ wScreenUpdateUsableArea(WScreen *scr)
scr->totalUsableArea[i].x1 = rect.pos.x;
scr->totalUsableArea[i].x2 = rect.pos.x + rect.size.width;
}
if (scr->totalUsableArea[i].y2 - scr->totalUsableArea[i].y1 < rect.size.height/2) {
scr->totalUsableArea[i].y1 = rect.pos.y;
scr->totalUsableArea[i].y2 = rect.pos.y + rect.size.height;

View File

@@ -3005,7 +3005,8 @@ wWindowDeleteSavedStatesForPID(pid_t pid)
void
wWindowSetOmnipresent(WWindow *wwin, Bool flag)
{
if ( wwin->flags.omnipresent == flag) return;
if (wwin->flags.omnipresent == flag)
return;
wwin->flags.omnipresent = flag;
WMPostNotificationName(WMNChangedState, wwin, "omnipresent");

View File

@@ -51,6 +51,8 @@ WArea wGetUsableAreaForHead(WScreen *scr, int head, WArea *totalAreaPtr, Bool no
WMPoint wGetPointToCenterRectInHead(WScreen *scr, int head, int width, int height);
Bool wWindowTouchesHead(WWindow *wwin, int head);
#endif