From 6d89565c8ed1a6b23ae6428def17d219212ea00b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 7 Jun 2008 16:38:33 +0200 Subject: [PATCH] [mouse] Use different cursors for corners Signed-off-by: Julien Danjou --- awesome.c | 4 ++++ common/xutil.h | 11 ++++++++--- mouse.c | 46 ++++++++++++++++++++++++++++++---------------- structs.h | 2 +- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/awesome.c b/awesome.c index 6dbbe518c..8e75ce79f 100644 --- a/awesome.c +++ b/awesome.c @@ -390,6 +390,10 @@ main(int argc, char **argv) globalconf.cursor[CurNormal] = create_font_cursor(CURSOR_LEFT_PTR); globalconf.cursor[CurResize] = create_font_cursor(CURSOR_SIZING); 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); + globalconf.cursor[CurBotRight] = create_font_cursor(CURSOR_BOTTOM_RIGHT_CORNER); + globalconf.cursor[CurBotLeft] = create_font_cursor(CURSOR_BOTTOM_LEFT_CORNER); /* select for events */ const uint32_t change_win_vals[] = diff --git a/common/xutil.h b/common/xutil.h index 9222a6915..d6fa4e5d4 100644 --- a/common/xutil.h +++ b/common/xutil.h @@ -34,9 +34,14 @@ #include "common/list.h" /* See http://tronche.com/gui/x/xlib/appendix/b/ for values */ -#define CURSOR_FLEUR 52 -#define CURSOR_LEFT_PTR 68 -#define CURSOR_SIZING 120 +#define CURSOR_FLEUR 52 +#define CURSOR_LEFT_PTR 68 +#define CURSOR_SIZING 120 +#define CURSOR_BOTTOM_LEFT_CORNER 12 +#define CURSOR_BOTTOM_RIGHT_CORNER 14 +#define CURSOR_TOP_LEFT_CORNER 134 +#define CURSOR_TOP_RIGHT_CORNER 136 + #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 322ad1ff7..cc78c3c86 100644 --- a/mouse.c +++ b/mouse.c @@ -217,10 +217,10 @@ mouse_query_pointer(xcb_window_t window, int *x, int *y) return true; } -/** Grab the Pointer - * \param window - * \param cursor the Cursor to display (see struct.h CurNormal, CurResize etc) - * \return true on success, false if an error occured +/** Grab the Pointer. + * \param window The window grabbed. + * \param cursor The cursor to display (see struct.h CurNormal, CurResize, etc). + * \return True on success, false if an error occured. */ static bool mouse_grab_pointer(xcb_window_t window, size_t cursor) @@ -445,6 +445,7 @@ mouse_client_resize_floating(client_t *c) /* the resize bar */ simple_window_t *sw; draw_context_t *ctx; + size_t cursor = CurResize; screen = xcb_aux_get_screen(globalconf.connection, c->phys_screen); @@ -464,27 +465,40 @@ mouse_client_resize_floating(client_t *c) { mouse_y = top; fixed_y = bottom; + if(abs(left - mouse_x) < abs(right - mouse_x)) + { + mouse_x = left; + fixed_x = right; + cursor = CurTopLeft; + } + else + { + mouse_x = right; + fixed_x = left; + cursor = CurTopRight; + } } else { mouse_y = bottom; fixed_y = top; - } - - if(abs(left - mouse_x) < abs(right - mouse_x)) - { - mouse_x = left; - fixed_x = right; - } - else - { - mouse_x = right; - fixed_x = left; + if(abs(left - mouse_x) < abs(right - mouse_x)) + { + mouse_x = left; + fixed_x = right; + cursor = CurBotLeft; + } + else + { + mouse_x = right; + fixed_x = left; + cursor = CurBotRight; + } } } /* grab the pointer */ - if(!mouse_grab_pointer(screen->root, CurResize)) + if(!mouse_grab_pointer(screen->root, cursor)) return; /* set pointer to the moveable corner */ diff --git a/structs.h b/structs.h index bf061e04f..ed74cd47d 100644 --- a/structs.h +++ b/structs.h @@ -45,7 +45,7 @@ typedef enum /** Cursors */ enum -{ CurNormal, CurResize, CurMove, CurLast }; +{ CurNormal, CurResize, CurMove, CurTopLeft, CurTopRight, CurBotLeft, CurBotRight, CurLast }; typedef struct button_t button_t; typedef struct widget_t widget_t;