2022-03-16 20:50:55 +01:00
# include "includes.hpp"
2022-03-27 17:25:20 +02:00
# include "debug/Log.hpp"
2022-03-28 16:10:30 +02:00
# include "helpers/MiscFunctions.hpp"
2022-03-28 22:31:39 +02:00
# include "helpers/WLListener.hpp"
2022-03-31 17:50:00 +02:00
# include "helpers/Color.hpp"
2022-03-16 20:50:55 +01:00
2022-04-11 19:51:37 +02:00
# include "wlrunstable/wlr_ext_workspace_v1.hpp"
2022-11-03 20:55:20 +01:00
# include <utility>
2022-03-16 20:50:55 +01:00
# ifndef NDEBUG
2022-06-18 13:09:38 +02:00
# ifdef HYPRLAND_DEBUG
2022-03-16 20:50:55 +01:00
# define ISDEBUG true
# else
# define ISDEBUG false
# endif
2022-06-18 13:09:38 +02:00
# else
# define ISDEBUG false
# endif
2022-03-16 20:50:55 +01:00
2022-03-17 18:25:16 +01:00
# define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name };
2022-03-28 22:31:39 +02:00
# define DYNLISTENFUNC(name) void listener_##name(void*, void*);
# define DYNLISTENER(name) CHyprWLListener hyprListener_##name;
2022-03-27 17:25:20 +02:00
# define DYNMULTILISTENER(name) wl_listener listen_##name;
2022-03-17 20:22:29 +01:00
2022-03-19 15:59:53 +01:00
# define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2))
2022-04-13 17:11:37 +02:00
# define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < delta)
2022-04-14 16:43:29 +02:00
# define PIXMAN_DAMAGE_FOREACH(region) int rectsNum = 0; \
const auto RECTSARR = pixman_region32_rectangles ( region , & rectsNum ) ; \
for ( int i = 0 ; i < rectsNum ; + + i )
2022-09-25 20:07:48 +02:00
2022-04-14 16:43:29 +02:00
2022-03-19 15:59:53 +01:00
# define interface class
2022-03-19 16:13:19 +01:00
# define STICKS(a, b) abs((a) - (b)) < 2
# define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
# define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
# define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
2022-03-20 13:37:07 +01:00
# define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
2022-03-27 17:25:20 +02:00
# define HYPRATOM(name) {name, 0}
2022-03-28 16:10:30 +02:00
# ifndef __INTELLISENSE__
2022-04-04 19:44:25 +02:00
# define RASSERT(expr, reason, ...) \
2022-04-05 20:49:15 +02:00
if ( ! ( expr ) ) { \
2022-04-04 19:44:25 +02:00
Debug : : log ( CRIT , " \n ========================================================================================== \n ASSERTION FAILED! \n \n %s \n \n at: line %d in %s " , getFormat ( reason , # # __VA_ARGS__ ) . c_str ( ) , __LINE__ , ( [ ] ( ) constexpr - > std : : string { return std : : string ( __FILE__ ) . substr ( std : : string ( __FILE__ ) . find_last_of ( ' / ' ) + 1 ) ; } ) ( ) . c_str ( ) ) ; \
2022-04-24 22:05:07 +02:00
printf ( " Assertion failed! See the log in /tmp/hypr/hyprland.log for more info. " ) ; \
* ( ( int * ) nullptr ) = 1 ; /* so that we crash and get a coredump */ \
2022-03-27 22:34:02 +02:00
}
2022-03-28 16:10:30 +02:00
# else
2022-04-04 19:44:25 +02:00
# define RASSERT(expr, reason, ...)
2022-03-28 16:10:30 +02:00
# endif
2022-03-27 17:25:20 +02:00
2022-04-22 18:14:25 +02:00
# define ASSERT(expr) RASSERT(expr, "?")
2022-07-25 21:34:57 +02:00
# if ISDEBUG
# define UNREACHABLE() { Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); *((int*)nullptr) = 1; }
# else
# define UNREACHABLE() std::unreachable();
# endif
2022-04-22 18:14:25 +02:00
// git stuff
# ifndef GIT_COMMIT_HASH
# define GIT_COMMIT_HASH "?"
# endif
# ifndef GIT_BRANCH
# define GIT_BRANCH "?"
2022-04-22 18:29:32 +02:00
# endif
# ifndef GIT_COMMIT_MESSAGE
# define GIT_COMMIT_MESSAGE "?"
2022-04-22 18:33:30 +02:00
# endif
# ifndef GIT_DIRTY
# define GIT_DIRTY "?"
2022-05-31 14:01:00 +02:00
# endif
2022-09-25 20:07:48 +02:00
# define SPECIAL_WORKSPACE_ID -99