VERSION = 0.4
CC = gcc
-LIBS = -lm -lxcb -lxcb-icccm -lxcb-ewmh -lxcb-xinerama
+LIBS = -lm -lxcb -lxcb-icccm -lxcb-ewmh -lxcb-xinerama -lxcb-cursor
CFLAGS = -std=c99 -pedantic -Wall -Wextra -D_POSIX_C_SOURCE=2 -DVERSION=\"$(VERSION)\"
LDFLAGS = $(LIBS)
- libxcb
- xcb-util
- xcb-util-wm
+- xcb-util-cursor
## Installation
-- Window move/resize pointer cursor feedbacks (via *util-cursor*).
- Grow/shrink through swap.
- Send to previous/next desktop.
- Command line completion for *bspc*.
#include <xcb/xcb.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb_ewmh.h>
+#include <xcb/xcb_cursor.h>
#include <xcb/xinerama.h>
#include "types.h"
#include "settings.h"
while (rule_head != NULL)
remove_rule(rule_head);
free(frozen_pointer);
+ xcb_cursor_context_free(cursor_context);
}
void register_events(void)
frozen_pointer = make_pointer_state();
last_focused_window = XCB_NONE;
save_pointer_position(&last_pointer_position);
+ if (xcb_cursor_context_new(&cursor_context, dpy) == -1)
+ warn("Couldn't create the cursor context.\n");
split_mode = MODE_AUTOMATIC;
visible = true;
exit_status = 0;
#ifndef _BSPWM_H
#define _BSPWM_H
+#include "xcb/xcb_cursor.h"
#include "types.h"
#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY)
pointer_state_t *frozen_pointer;
xcb_window_t last_focused_window;
xcb_point_t last_pointer_position;
+xcb_cursor_context_t *cursor_context;
int exit_status;
mid_x = c->floating_rectangle.x + (c->floating_rectangle.width / 2);
mid_y = c->floating_rectangle.y + (c->floating_rectangle.height / 2);
if (pos.x > mid_x) {
- if (pos.y > mid_y)
+ if (pos.y > mid_y) {
frozen_pointer->corner = BOTTOM_RIGHT;
- else
+ window_set_cursor(loc.node->client->window, CURSOR_RESIZE_BR);
+ } else {
frozen_pointer->corner = TOP_RIGHT;
+ window_set_cursor(loc.node->client->window, CURSOR_RESIZE_TR);
+ }
} else {
- if (pos.y > mid_y)
+ if (pos.y > mid_y) {
frozen_pointer->corner = BOTTOM_LEFT;
- else
+ window_set_cursor(loc.node->client->window, CURSOR_RESIZE_BL);
+ } else {
frozen_pointer->corner = TOP_LEFT;
+ window_set_cursor(loc.node->client->window, CURSOR_RESIZE_TL);
+ }
}
+ } else {
+ window_set_cursor(loc.node->client->window, CURSOR_MOVE);
}
break;
}
{
PUTS("ungrab pointer");
+ window_set_cursor(frozen_pointer->node->client->window, CURSOR_NORMAL);
update_floating_rectangle(frozen_pointer->node->client);
monitor_t *m = underlying_monitor(frozen_pointer->node->client);
if (m != NULL && m != frozen_pointer->monitor) {
#ifndef _EVENTS_H
#define _EVENTS_H
+#define CURSOR_NORMAL "left_ptr"
+#define CURSOR_MOVE "fleur"
+#define CURSOR_RESIZE_TL "top_left_corner"
+#define CURSOR_RESIZE_TR "top_right_corner"
+#define CURSOR_RESIZE_BR "bottom_right_corner"
+#define CURSOR_RESIZE_BL "bottom_left_corner"
+
#include <xcb/xcb.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb.h>
#include <xcb/xcb_event.h>
#include <xcb/xcb_icccm.h>
+#include <xcb/xcb_cursor.h>
#include "types.h"
#include "tree.h"
#include "bspwm.h"
window_set_visibility(win, true);
}
+void window_set_cursor(xcb_window_t win, char *name)
+{
+ xcb_cursor_t cursor = xcb_cursor_load_cursor(cursor_context, name);
+ uint32_t values[] = {cursor};
+ xcb_change_window_attributes(dpy, win, XCB_CW_CURSOR, values);
+}
+
void toggle_visibility(void)
{
visible = !visible;
void window_set_visibility(xcb_window_t, bool);
void window_hide(xcb_window_t);
void window_show(xcb_window_t);
+void window_set_cursor(xcb_window_t, char *);
void toggle_visibility(void);
uint32_t get_main_border_color(client_t *, bool, bool);
void update_floating_rectangle(client_t *);