aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.c22
-rw-r--r--src/client.h5
-rw-r--r--src/event.c17
-rw-r--r--src/taskbar.c6
4 files changed, 34 insertions, 16 deletions
diff --git a/src/client.c b/src/client.c
index 6c1976e..14c214c 100644
--- a/src/client.c
+++ b/src/client.c
@@ -875,6 +875,28 @@ void KillClient(ClientNode *np) {
NULL);
}
+/** Move the cursor to the middle of the client. **/
+void MoveMouseToClient(ClientNode *np) {
+
+ int height, width, x, y;
+
+ 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);
+}
+
/** Raise the client. This will affect transients. */
void RaiseClient(ClientNode *np) {
diff --git a/src/client.h b/src/client.h
index 7fc98db..a9e577a 100644
--- a/src/client.h
+++ b/src/client.h
@@ -211,6 +211,11 @@ void DeleteClient(ClientNode *np);
*/
void KillClient(ClientNode *np);
+/** Move the cursor to the middle of a client.
+ * @param np The client to move to.
+ */
+void MoveMouseToClient(ClientNode *np);
+
/** Raise a client to the top of its layer.
* @param np The client to raise.
*/
diff --git a/src/event.c b/src/event.c
index d0e80fa..f88e2a5 100644
--- a/src/event.c
+++ b/src/event.c
@@ -338,7 +338,6 @@ void HandleButtonEvent(const XButtonEvent *event) {
void HandleKeyPress(const XKeyEvent *event) {
ClientNode *np;
KeyType key;
- int height, width, x, y;
key = GetKey(event);
@@ -376,21 +375,7 @@ void HandleKeyPress(const XKeyEvent *event) {
case KEY_RAISE:
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);
+ MoveMouseToClient(np);
}
break;
case KEY_CLOSE:
diff --git a/src/taskbar.c b/src/taskbar.c
index 8eb45d3..d86320d 100644
--- a/src/taskbar.c
+++ b/src/taskbar.c
@@ -267,6 +267,12 @@ void ProcessTaskButtonEvent(TrayComponentType *cp, int x, int y, int mask) {
if(np) {
switch(mask) {
+ case Button2:
+ MoveMouseToClient(np->client);
+ if(np->client->state.status & STAT_ACTIVE
+ && np->client == nodes[np->client->state.layer])
+ break;
+ /* FALLTHROUGH */
case Button1:
if(np->client->state.status & STAT_ACTIVE
&& np->client == nodes[np->client->state.layer]) {