summaryrefslogtreecommitdiffstats
path: root/src/include/macros.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/include/macros.h
parentInitial commit. (diff)
downloadinkscape-upstream.tar.xz
inkscape-upstream.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/include/macros.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/include/macros.h b/src/include/macros.h
new file mode 100644
index 0000000..aa1719d
--- /dev/null
+++ b/src/include/macros.h
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef SEEN_MACROS_H
+#define SEEN_MACROS_H
+
+/**
+ * Useful macros for inkscape
+ *
+ * Author:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ *
+ * Copyright (C) 2002 Lauris Kaplinski
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+// I'm of the opinion that this file should be removed, so I will in the future take the necessary steps to wipe it out.
+// Macros are not in general bad, but these particular ones are rather ugly. --Liam
+
+#define sp_signal_disconnect_by_data(o,d) g_signal_handlers_disconnect_matched(o, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, d)
+
+// "primary" modifier: Ctrl on Linux/Windows and Cmd on macOS.
+// note: Could query this at runtime with
+// `gdk_keymap_get_modifier_mask(..., GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR)`
+#ifdef GDK_WINDOWING_QUARTZ
+#define INK_GDK_PRIMARY_MASK GDK_MOD2_MASK
+#else
+#define INK_GDK_PRIMARY_MASK GDK_CONTROL_MASK
+#endif
+
+// all modifiers used by Inkscape
+#define INK_GDK_MODIFIER_MASK (GDK_SHIFT_MASK | INK_GDK_PRIMARY_MASK | GDK_MOD1_MASK)
+
+// keyboard modifiers in an event
+#define MOD__SHIFT(event) ((event)->key.state & GDK_SHIFT_MASK)
+#define MOD__CTRL(event) ((event)->key.state & INK_GDK_PRIMARY_MASK)
+#define MOD__ALT(event) ((event)->key.state & GDK_MOD1_MASK)
+#define MOD__SHIFT_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == GDK_SHIFT_MASK)
+#define MOD__CTRL_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == INK_GDK_PRIMARY_MASK)
+#define MOD__ALT_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == GDK_MOD1_MASK)
+
+#endif // SEEN_MACROS_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :