From dda2eb8c84fc691ad636f2cf2c0458c339836450 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 22 Jun 2008 22:23:24 +0000 Subject: [PATCH] Only one maximisation function. SVN revision: 34891 --- src/ewins.h | 5 ++--- src/ewmh.c | 8 ++------ src/ipc.c | 6 +++--- src/size.c | 37 ++++++++----------------------------- 4 files changed, 15 insertions(+), 41 deletions(-) diff --git a/src/ewins.h b/src/ewins.h index ecb22018..61582a76 100644 --- a/src/ewins.h +++ b/src/ewins.h @@ -458,9 +458,8 @@ void ActionsHandleMotion(void); int ActionsEnd(EWin * ewin); /* size.c */ -void MaxSize(EWin * ewin, const char *resize_type); -void MaxWidth(EWin * ewin, const char *resize_type); -void MaxHeight(EWin * ewin, const char *resize_type); +void MaxSizeHV(EWin * ewin, const char *resize_type, + int hor, int ver); /* stacking.c */ EWin *const *EwinListStackGet(int *num); diff --git a/src/ewmh.c b/src/ewmh.c index cae977be..8a4b9fff 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -936,8 +936,7 @@ EWMH_ProcessClientClientMessage(EWin * ewin, XClientMessageEvent * ev) else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT || atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ) { - void (*func) (EWin *, const char *); - unsigned int maxh, maxv; + int maxh, maxv; maxh = ewin->state.maximized_horz; maxv = ewin->state.maximized_vert; @@ -945,25 +944,22 @@ EWMH_ProcessClientClientMessage(EWin * ewin, XClientMessageEvent * ev) atom2 == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ) { /* (ok - ok) */ - func = MaxSize; maxh = do_set(maxh, action); maxv = do_set(maxv, action); } else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT) { - func = MaxHeight; maxv = do_set(maxv, action); } else { - func = MaxWidth; maxh = do_set(maxh, action); } if ((ewin->state.maximized_horz != maxh) || (ewin->state.maximized_vert != maxv)) { - func(ewin, "available"); + MaxSizeHV(ewin, "available", maxh, maxv); EWMH_SetWindowState(ewin); } } diff --git a/src/ipc.c b/src/ipc.c index 32979c05..0cb17f52 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -632,15 +632,15 @@ IpcWinop(const WinOp * wop, EWin * ewin, const char *prm) break; case EWIN_OP_MAX_WIDTH: - MaxWidth(ewin, param1); + MaxSizeHV(ewin, param1, 1, 0); break; case EWIN_OP_MAX_HEIGHT: - MaxHeight(ewin, param1); + MaxSizeHV(ewin, param1, 0, 1); break; case EWIN_OP_MAX_SIZE: - MaxSize(ewin, param1); + MaxSizeHV(ewin, param1, 1, 1); break; case EWIN_OP_FULLSCREEN: diff --git a/src/size.c b/src/size.c index 8b6abba5..ad7d647f 100644 --- a/src/size.c +++ b/src/size.c @@ -26,16 +26,13 @@ #include "hints.h" #include "screen.h" -#define MAX_HOR 0x1 -#define MAX_VER 0x2 - #define MAX_ABSOLUTE 0 /* Fill screen */ #define MAX_AVAILABLE 1 /* Expand until don't cover */ #define MAX_CONSERVATIVE 2 /* Expand until something */ #define MAX_XINERAMA 3 /* Fill Xinerama screen */ -static void -MaxSizeHV(EWin * ewin, const char *resize_type, int direction) +void +MaxSizeHV(EWin * ewin, const char *resize_type, int hor, int ver) { int x, y, w, h, x1, x2, y1, y2, type, bl, br, bt, bb; EWin *const *lst, *pe; @@ -44,9 +41,9 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) if (!ewin) return; - if (ewin->state.inhibit_max_hor && (direction & MAX_HOR)) + if (ewin->state.inhibit_max_hor && hor) return; - if (ewin->state.inhibit_max_ver && (direction & MAX_VER)) + if (ewin->state.inhibit_max_ver && ver) return; if (ewin->state.maximized_horz || ewin->state.maximized_vert) @@ -83,13 +80,13 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) switch (type) { case MAX_XINERAMA: - if (direction & MAX_HOR) + if (hor) { x = 0; w = WinGetW(VROOT); ewin->state.maximized_horz = 1; } - if (direction & MAX_VER) + if (ver) { y = 0; h = WinGetH(VROOT); @@ -116,7 +113,7 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) lst = EwinListGetAll(&num); } - if (direction & MAX_VER) + if (ver) { for (i = 0; i < num; i++) { @@ -142,7 +139,7 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) ewin->state.maximized_vert = 1; } - if (direction & MAX_HOR) + if (hor) { for (i = 0; i < num; i++) { @@ -190,21 +187,3 @@ MaxSizeHV(EWin * ewin, const char *resize_type, int direction) done: HintsSetWindowState(ewin); } - -void -MaxWidth(EWin * ewin, const char *resize_type) -{ - MaxSizeHV(ewin, resize_type, MAX_HOR); -} - -void -MaxHeight(EWin * ewin, const char *resize_type) -{ - MaxSizeHV(ewin, resize_type, MAX_VER); -} - -void -MaxSize(EWin * ewin, const char *resize_type) -{ - MaxSizeHV(ewin, resize_type, MAX_HOR | MAX_VER); -}