From 8ab1831ed6349af365dad79de55c78bea7df06b5 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 7 Jun 2008 23:37:24 +0200 Subject: [PATCH] [mouse] Use different cursors for vert./horiz. resize Signed-off-by: Julien Danjou --- awesome.c | 2 ++ common/xutil.h | 3 ++- mouse.c | 15 ++++++++++++++- structs.h | 5 ++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/awesome.c b/awesome.c index 8e75ce79f..2648a9624 100644 --- a/awesome.c +++ b/awesome.c @@ -389,6 +389,8 @@ main(int argc, char **argv) /* init cursors */ globalconf.cursor[CurNormal] = create_font_cursor(CURSOR_LEFT_PTR); globalconf.cursor[CurResize] = create_font_cursor(CURSOR_SIZING); + globalconf.cursor[CurResizeH] = create_font_cursor(CURSOR_DOUBLE_ARROW_HORIZ); + globalconf.cursor[CurResizeV] = create_font_cursor(CURSOR_DOUBLE_ARROW_VERT); globalconf.cursor[CurMove] = create_font_cursor(CURSOR_FLEUR); globalconf.cursor[CurTopRight] = create_font_cursor(CURSOR_TOP_RIGHT_CORNER); globalconf.cursor[CurTopLeft] = create_font_cursor(CURSOR_TOP_LEFT_CORNER); diff --git a/common/xutil.h b/common/xutil.h index d6fa4e5d4..d1e863067 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -41,7 +41,8 @@ #define CURSOR_BOTTOM_RIGHT_CORNER 14 #define CURSOR_TOP_LEFT_CORNER 134 #define CURSOR_TOP_RIGHT_CORNER 136 - +#define CURSOR_DOUBLE_ARROW_HORIZ 108 +#define CURSOR_DOUBLE_ARROW_VERT 116 #define ANY_KEY 0L /* special Key Code, passed to GrabKey */ #define ANY_MODIFIER (1<<15) /* used in Grabbutton_t, GrabKey */ diff --git a/mouse.c b/mouse.c index 05507442f..f5155ff8a 100644 --- a/mouse.c +++ b/mouse.c @@ -551,6 +551,7 @@ mouse_client_resize_tiled(client_t *c) layout_t *layout; int mouse_x, mouse_y; + size_t cursor = CurResize; screen = xcb_aux_get_screen(globalconf.connection, c->phys_screen); tag = tags_get_current(c->screen)[0]; @@ -564,18 +565,30 @@ mouse_client_resize_tiled(client_t *c) /* select initial pointer position */ if(layout == layout_tile) + { mouse_x = area.x + area.width * tag->mwfact; + cursor = CurResizeH; + } else if(layout == layout_tileleft) + { mouse_x = area.x + area.width * (1. - tag->mwfact); + cursor = CurResizeH; + } else if(layout == layout_tilebottom) + { mouse_y = area.y + area.height * tag->mwfact; + cursor = CurResizeV; + } else if(layout == layout_tiletop) + { mouse_y = area.y + area.height * (1. - tag->mwfact); + cursor = CurResizeV; + } else return; /* grab the pointer */ - if(!mouse_grab_pointer(screen->root, CurResize)) + if(!mouse_grab_pointer(screen->root, cursor)) return; /* set pointer to the moveable border */ diff --git a/structs.h b/structs.h index ed74cd47d..034b034dd 100644 --- a/structs.h +++ b/structs.h @@ -45,7 +45,10 @@ typedef enum /** Cursors */ enum -{ CurNormal, CurResize, CurMove, CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast }; +{ + CurNormal, CurResize, CurResizeH, CurResizeV, CurMove, + CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast +}; typedef struct button_t button_t; typedef struct widget_t widget_t;