glazier

the original window manipulator
Log | Files | Refs | Submodules | README | LICENSE

commit 9b96b9f0a2bc352035c886bc61510649524ede88
parent 4d75d6c1d889c15a32c4172e14ad957aeca86866
Author: Willy Goiffon <dev@z3bra.org>
Date:   Sat, 26 Oct 2019 15:31:42 +0200

Change declaration of crosshairs + config.def.h cleanup

Diffstat:
config.def.h | 14++++++++++----
glazier.c | 20++++++++++++++------
2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,12 +1,18 @@ -#define XHAIR_MOVE "hand1" -#define XHAIR_SIZE "tcross" -#define XHAIR_DFLT "left_ptr" +/* define crosshairs used for various operations */ +char *xhair[] = { + [XHAIR_MOVE] = "hand1", + [XHAIR_SIZE] = "lr_angle", + [XHAIR_TELE] = "tcross", + [XHAIR_DFLT] = "left_ptr", +}; +/* key that must be pressed to register mouse events */ int modifier = XCB_MOD_MASK_1; /* window borders and titlebar */ int border = 2; -int border_color = 0xdeadca7; +int border_color = 0x666666; +int border_color_active = 0xdeadca7; /* move/resize step amound in pixels */ int move_step = 8; diff --git a/glazier.c b/glazier.c @@ -5,7 +5,6 @@ #include "arg.h" #include "wm.h" -#include "config.h" #define LEN(x) (sizeof(x)/sizeof(x[0])) #define XEV(x) (evname[(x)->response_type & ~0x80]) @@ -23,6 +22,15 @@ struct cursor_t { int b; }; +enum { + XHAIR_DFLT, + XHAIR_MOVE, + XHAIR_SIZE, + XHAIR_TELE, +}; + +#include "config.h" + void usage(char *); static int takeover(); static int adopt(xcb_window_t); @@ -223,6 +231,7 @@ cb_mapreq(xcb_generic_event_t *ev) wm_remap(e->window, MAP); wm_set_border(border, border_color, e->window); wm_set_focus(e->window); + return 0; } @@ -242,7 +251,6 @@ cb_mouse_press(xcb_generic_event_t *ev) if (verbose) fprintf(stderr, "%s 0x%08x %d\n", XEV(e), e->event, e->detail); - cursor.x = e->root_x - wm_get_attribute(e->child, ATTR_X); cursor.y = e->root_y - wm_get_attribute(e->child, ATTR_Y); cursor.b = e->detail; @@ -253,14 +261,14 @@ cb_mouse_press(xcb_generic_event_t *ev) switch(e->detail) { case 1: curwid = e->child; - wm_reg_cursor_event(scrn->root, mask, XHAIR_MOVE); + wm_reg_cursor_event(scrn->root, mask, xhair[XHAIR_MOVE]); break; case 2: - wm_reg_cursor_event(scrn->root, mask, XHAIR_SIZE); + wm_reg_cursor_event(scrn->root, mask, xhair[XHAIR_TELE]); break; case 3: curwid = e->child; - wm_reg_cursor_event(scrn->root, mask, XHAIR_SIZE); + wm_reg_cursor_event(scrn->root, mask, xhair[XHAIR_SIZE]); break; case 4: x = wm_get_attribute(e->child, ATTR_X) - move_step/2; @@ -302,7 +310,7 @@ cb_mouse_release(xcb_generic_event_t *ev) exit(1); } - p = xcb_cursor_load_cursor(cx, XHAIR_DFLT); + p = xcb_cursor_load_cursor(cx, xhair[XHAIR_DFLT]); xcb_change_window_attributes(conn, e->event, XCB_CW_CURSOR, &p); xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);