[mouse] Use different cursors for corners

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-07 16:38:33 +02:00
parent f00b5b252c
commit 6d89565c8e
4 changed files with 43 additions and 20 deletions

View File

@ -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[] =

View File

@ -37,6 +37,11 @@
#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 */

38
mouse.c
View File

@ -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;
}
else
{
mouse_y = bottom;
fixed_y = top;
}
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;
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 */

View File

@ -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;