aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-28 00:09:40 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-28 00:09:40 +0200
commitcf0a94502a791f2b8a64cc6449b1e9dcaa3e3874 (patch)
tree3e622602d2983a73135e30ed55a796b3af55556e /src
parenta7810253566384804e469bd78b00fde24b09fef0 (diff)
Add alt+f1 keybind on target window to reset window rotation
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 62450ee..80b1f50 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -608,6 +608,8 @@ bool CMainApplication::BInit()
window_resized = false;
XSelectInput(x_display, src_window_id, StructureNotifyMask);
+ if(!XGrabKey(x_display, AnyKey, AnyModifier, src_window_id, True, GrabModeAsync, GrabModeAsync))
+ fprintf(stderr, "Failed to grab alt + f1 keybind\n");
if(!XFixesQueryExtension(x_display, &x_fixes_event_base, &x_fixes_error_base)) {
fprintf(stderr, "Your x11 server is missing the xfixes extension\n");
@@ -895,6 +897,8 @@ void CMainApplication::Shutdown()
XCloseDisplay(x_display);
}
+#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
+
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -955,6 +959,12 @@ bool CMainApplication::HandleInput()
}
}
+ if (XCheckTypedWindowEvent(x_display, src_window_id, KeyPress, &xev)) {
+ KeySym pressed_keysym = XKeycodeToKeysym(x_display, xev.xkey.keycode, 0);
+ if(pressed_keysym == XK_F1 && CLEANMASK(xev.xkey.state) == Mod1Mask)
+ m_bResetRotation = true;
+ }
+
if(XCheckTypedWindowEvent(x_display, src_window_id, x_fixes_event_base + XFixesCursorNotify, &xev)) {
XFixesCursorNotifyEvent *cursor_notify_event = (XFixesCursorNotifyEvent*)&xev;
if(cursor_notify_event->subtype == XFixesDisplayCursorNotify && cursor_notify_event->window == src_window_id) {