From: John Lindgren Date: Sat, 21 Oct 2023 00:24:29 +0000 (-0400) Subject: common: move MIN and MAX to common/macros.h X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=048d22d473dc28aad9236317dbd37ae26fde7845;p=proto%2Flabwc.git common: move MIN and MAX to common/macros.h --- diff --git a/include/common/macros.h b/include/common/macros.h index dc0eb65d..17ada31e 100644 --- a/include/common/macros.h +++ b/include/common/macros.h @@ -32,4 +32,22 @@ (dest)->name.notify = handle_##name; \ wl_signal_add(&(src)->events.name, &(dest)->name) +/** + * MIN() - Minimum of two values. + * + * @note Arguments may be evaluated twice. + */ +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +/** + * MAX() - Maximum of two values. + * + * @note Arguments may be evaluated twice. + */ +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + #endif /* LABWC_MACROS_H */ diff --git a/include/labwc.h b/include/labwc.h index e128a5c0..bae2dfb9 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -57,14 +57,6 @@ #define XCURSOR_DEFAULT "left_ptr" #define XCURSOR_SIZE 24 -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - enum input_mode { LAB_INPUT_STATE_PASSTHROUGH = 0, LAB_INPUT_STATE_MOVE, diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 79ea79d8..0f8547ba 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -17,6 +17,7 @@ #include #include "action.h" #include "common/list.h" +#include "common/macros.h" #include "common/mem.h" #include "common/nodename.h" #include "common/parse-bool.h" diff --git a/src/ssd/resize_indicator.c b/src/ssd/resize_indicator.c index d972d470..5360f1c0 100644 --- a/src/ssd/resize_indicator.c +++ b/src/ssd/resize_indicator.c @@ -3,6 +3,7 @@ #include #include #include +#include "common/macros.h" #include "common/scaled_font_buffer.h" #include "labwc.h" #include "resize_indicator.h" diff --git a/src/view.c b/src/view.c index e85934bf..e85ffab1 100644 --- a/src/view.c +++ b/src/view.c @@ -2,6 +2,7 @@ #include #include #include +#include "common/macros.h" #include "common/match.h" #include "common/mem.h" #include "common/scene-helpers.h"