From f9cf1a4e89bbef715422665206949dfca561f770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 19 Jun 2021 23:54:49 +0200 Subject: Move cursor to center of window on raise --- src/event.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/event.c b/src/event.c index 222764f..d0e80fa 100644 --- a/src/event.c +++ b/src/event.c @@ -338,6 +338,7 @@ void HandleButtonEvent(const XButtonEvent *event) { void HandleKeyPress(const XKeyEvent *event) { ClientNode *np; KeyType key; + int height, width, x, y; key = GetKey(event); @@ -373,7 +374,24 @@ void HandleKeyPress(const XKeyEvent *event) { FocusPreviousStackedCircular(); break; case KEY_RAISE: - RaiseClient(np); + if(np) { + RaiseClient(np); + x = np->x; + y = np->y; + width = np->width; + height = np->height; + if(np->state.border & BORDER_OUTLINE) { + x -= borderWidth; + y -= borderWidth; + width += borderWidth * 2; + height += borderWidth * 2; + } + if(np->state.border & BORDER_TITLE) { + y -= titleHeight; + height += titleHeight; + } + MoveMouse(rootWindow, x + width / 2, y + height / 2); + } break; case KEY_CLOSE: if(np) { -- cgit v1.2.3