From b7c18a9c12fccc48cd4123a5f153f1965667685d Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sat, 14 Aug 2021 13:39:43 +0200 Subject: [PATCH] Change EXGetGeometry() to EXGetSize() Only w and h are ever used. Also remove now unnecessary initializations of returned values. --- src/eimage.c | 5 ++--- src/icons.c | 9 +++------ src/text.c | 8 ++++---- src/x.c | 25 ++----------------------- src/xwin.h | 4 +--- 5 files changed, 12 insertions(+), 39 deletions(-) diff --git a/src/eimage.c b/src/eimage.c index 3725a44d..6988c622 100644 --- a/src/eimage.c +++ b/src/eimage.c @@ -634,7 +634,7 @@ ScaleTile(Win wsrc, EX_Drawable src, Win wdst, EX_Pixmap dst, sw = WinGetW(wsrc); sh = WinGetH(wsrc); - EXGetGeometry(src, NULL, NULL, NULL, &stw, &sth, NULL, NULL); + EXGetSize(src, &stw, &sth); if (stw >= sw && sth >= sh) { ScaleRect(wsrc, src, wdst, dst, 0, 0, sw, sh, dx, dy, dw, dh, scale); @@ -670,8 +670,7 @@ EDrawableDumpImage(EX_Drawable draw, const char *txt) Imlib_Image im; int w, h; - w = h = 0; - EXGetGeometry(draw, NULL, NULL, NULL, &w, &h, NULL, NULL); + EXGetSize(draw, &w, &h); if (w <= 0 || h <= 0) return; im = EImageGrabDrawableScaled(ELookupXwin(draw), draw, NoXID, diff --git a/src/icons.c b/src/icons.c index 44c7dc06..661f62f0 100644 --- a/src/icons.c +++ b/src/icons.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2018 Kim Woelders + * Copyright (C) 2004-2021 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -179,11 +179,8 @@ IB_GetAppIcon(EWin * ewin, int size) if (!ewin->icccm.icon_pmap) return NULL; - w = 0; - h = 0; - EXGetGeometry(ewin->icccm.icon_pmap, NULL, NULL, NULL, &w, &h, NULL, NULL); - - if (w < 1 || h < 1) + EXGetSize(ewin->icccm.icon_pmap, &w, &h); + if (w <= 0 || h <= 0) return NULL; im = EImageGrabDrawable(ewin->icccm.icon_pmap, ewin->icccm.icon_mask, diff --git a/src/text.c b/src/text.c index d726f5e9..0fa634c7 100644 --- a/src/text.c +++ b/src/text.c @@ -68,7 +68,7 @@ TextDrawRotTo(Win win, EX_Drawable src, EX_Drawable dst, int x, int y, EImageFree(im); break; case FONT_TO_DOWN: - EXGetGeometry(src, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + EXGetSize(src, &win_w, NULL); im = EImageGrabDrawable(src, NoXID, win_w - y - h, x, h, w, 0); EImageOrientate(im, 3); EImageRenderOnDrawable(im, win, dst, 0, 0, 0, w, h); @@ -101,7 +101,7 @@ TextDrawRotBack(Win win, EX_Drawable dst, EX_Drawable src, int x, int y, EImageFree(im); break; case FONT_TO_DOWN: - EXGetGeometry(dst, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + EXGetSize(dst, &win_w, NULL); im = EImageGrabDrawable(src, NoXID, 0, 0, w, h, 0); EImageOrientate(im, 1); EImageRenderOnDrawable(im, win, dst, 0, win_w - y - h, x, h, w); @@ -141,7 +141,7 @@ TextImageGet(Win win __UNUSED__, EX_Drawable src, int x, int y, int w, int h, EImageOrientate(im, 1); break; case FONT_TO_DOWN: - EXGetGeometry(src, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + EXGetSize(src, &win_w, NULL); im = EImageGrabDrawable(src, NoXID, win_w - y - h, x, h, w, 0); EImageOrientate(im, 3); break; @@ -171,7 +171,7 @@ TextImagePut(EImage * im, Win win, EX_Drawable dst, int x, int y, EImageRenderOnDrawable(im, win, dst, 0, y, x, h, w); break; case FONT_TO_DOWN: - EXGetGeometry(dst, NULL, NULL, NULL, &win_w, NULL, NULL, NULL); + EXGetSize(dst, &win_w, NULL); EImageOrientate(im, 1); EImageRenderOnDrawable(im, win, dst, 0, win_w - y - h, x, h, w); break; diff --git a/src/x.c b/src/x.c index 024c6ed5..90a2c5e6 100644 --- a/src/x.c +++ b/src/x.c @@ -803,8 +803,7 @@ EXGetWindowAttributes(EX_Window xwin, XWindowAttributes * pxwa) } int -EXGetGeometry(EX_Drawable draw, EX_Window * root_return, int *x, int *y, - int *w, int *h, int *bw, int *depth) +EXGetSize(EX_Drawable draw, int *w, int *h) { int ok; Window rr; @@ -817,37 +816,17 @@ EXGetGeometry(EX_Drawable draw, EX_Window * root_return, int *x, int *y, #if 0 /* Debug */ Eprintf("%s win=%#x, error %d\n", __func__, draw, ok); #endif - if (root_return) - *root_return = NoXID; - if (x) - *x = 0; - if (y) - *y = 0; if (w) *w = 0; if (h) *h = 0; - if (bw) - *bw = 0; - if (depth) - *depth = 0; return 0; } - if (root_return) - *root_return = rr; - if (x) - *x = xx; - if (y) - *y = yy; if (w) *w = ww; if (h) *h = hh; - if (bw) - *bw = bb; - if (depth) - *depth = dd; return 1; } @@ -1239,7 +1218,7 @@ EXDrawableOk(EX_Drawable draw) if (draw == NoXID) return 0; - return EXGetGeometry(draw, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + return EXGetSize(draw, NULL, NULL); } int diff --git a/src/xwin.h b/src/xwin.h index bbd9fbe5..ff8a652e 100644 --- a/src/xwin.h +++ b/src/xwin.h @@ -254,9 +254,7 @@ unsigned int EAllocColor(EX_Colormap cmap, unsigned int argb); EX_Window EXWindowGetParent(EX_Window xwin); int EXGetWindowAttributes(EX_Window xwin, XWindowAttributes * pxwa); -int EXGetGeometry(EX_Window xwin, EX_Window * root_return, - int *x, int *y, int *w, int *h, int *bw, - int *depth); +int EXGetSize(EX_Window xwin, int *w, int *h); void EXRestackWindows(EX_Window * windows, int nwindows);