Use default cursor (XC_left_ptr) for all windows
This commit is contained in:
parent
f45e706c48
commit
45827607dc
|
@ -17,6 +17,11 @@
|
|||
#define _NET_WM_STATE_ADD 1
|
||||
#define _NET_WM_STATE_TOGGLE 2
|
||||
|
||||
/* This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a constant for that. */
|
||||
#define XCB_CURSOR_LEFT_PTR 68
|
||||
#define XCB_CURSOR_SB_H_DOUBLE_ARROW 108
|
||||
#define XCB_CURSOR_SB_V_DOUBLE_ARROW 116
|
||||
|
||||
enum { _NET_SUPPORTED = 0,
|
||||
_NET_SUPPORTING_WM_CHECK,
|
||||
_NET_WM_NAME,
|
||||
|
@ -31,7 +36,8 @@ enum { _NET_SUPPORTED = 0,
|
|||
|
||||
i3Font *load_font(xcb_connection_t *connection, const char *pattern);
|
||||
uint32_t get_colorpixel(xcb_connection_t *conn, Client *client, xcb_window_t window, char *hex);
|
||||
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t window_class, uint32_t mask, uint32_t *values);
|
||||
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t window_class, uint16_t cursor,
|
||||
uint32_t mask, uint32_t *values);
|
||||
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value);
|
||||
void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
|
||||
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t to_x, uint32_t to_y);
|
||||
|
|
|
@ -223,7 +223,7 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
|
|||
/* Open a new window, the resizebar. Grab the pointer and move the window around
|
||||
as the user moves the pointer. */
|
||||
Rect grabrect = {0, 0, root_screen->width_in_pixels, root_screen->height_in_pixels};
|
||||
xcb_window_t grabwin = create_window(conn, grabrect, XCB_WINDOW_CLASS_INPUT_ONLY, 0, NULL);
|
||||
xcb_window_t grabwin = create_window(conn, grabrect, XCB_WINDOW_CLASS_INPUT_ONLY, -1, 0, NULL);
|
||||
|
||||
Rect helprect;
|
||||
if (orientation == O_VERTICAL) {
|
||||
|
@ -234,10 +234,13 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
|
|||
} else {
|
||||
helprect.x = 0;
|
||||
helprect.y = event->root_y;
|
||||
helprect.width = root_screen->width_in_pixels; /* this has to be the cell’s width*/
|
||||
helprect.width = root_screen->width_in_pixels; /* this has to be the cell’s width */
|
||||
helprect.height = 2;
|
||||
}
|
||||
xcb_window_t helpwin = create_window(conn, helprect, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, NULL);
|
||||
xcb_window_t helpwin = create_window(conn, helprect, XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||
(orientation == O_VERTICAL ?
|
||||
XCB_CURSOR_SB_V_DOUBLE_ARROW :
|
||||
XCB_CURSOR_SB_H_DOUBLE_ARROW), 0, NULL);
|
||||
|
||||
uint32_t values[1] = {get_colorpixel(conn, NULL, helpwin, "#4c7899")};
|
||||
xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(conn, helpwin, XCB_CW_BACK_PIXEL, values);
|
||||
|
|
|
@ -174,7 +174,7 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
|
|||
height + 2 + 2 + font->height}; /* 2 px border plus font’s height */
|
||||
|
||||
/* Yo dawg, I heard you like windows, so I create a window around your window… */
|
||||
new->frame = create_window(conn, framerect, XCB_WINDOW_CLASS_INPUT_OUTPUT, mask, values);
|
||||
new->frame = create_window(conn, framerect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values);
|
||||
|
||||
/* Put the client inside the save set. Upon termination (whether killed or normal exit
|
||||
does not matter) of the window manager, these clients will be correctly reparented
|
||||
|
|
|
@ -184,7 +184,7 @@ void switch_layout_mode(xcb_connection_t *conn, Container *container, int mode)
|
|||
XCB_EVENT_MASK_EXPOSURE; /* …our window needs to be redrawn */
|
||||
|
||||
struct Stack_Window *stack_win = &(container->stack_win);
|
||||
stack_win->window = create_window(conn, rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, mask, values);
|
||||
stack_win->window = create_window(conn, rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values);
|
||||
|
||||
/* Generate a graphics context for the titlebar */
|
||||
stack_win->gc = xcb_generate_id(conn);
|
||||
|
|
18
src/xcb.c
18
src/xcb.c
|
@ -18,6 +18,7 @@
|
|||
#include <xcb/xcb.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "xcb.h"
|
||||
|
||||
TAILQ_HEAD(cached_fonts_head, Font) cached_fonts = TAILQ_HEAD_INITIALIZER(cached_fonts);
|
||||
|
||||
|
@ -122,14 +123,24 @@ uint32_t get_colorpixel(xcb_connection_t *conn, Client *client, xcb_window_t win
|
|||
* for errors.
|
||||
*
|
||||
*/
|
||||
xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_class, uint32_t mask, uint32_t *values) {
|
||||
xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_class, uint16_t cursor,
|
||||
uint32_t mask, uint32_t *values) {
|
||||
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
|
||||
xcb_window_t result = xcb_generate_id(conn);
|
||||
xcb_cursor_t cursor_id = xcb_generate_id(conn);
|
||||
xcb_void_cookie_t cookie;
|
||||
|
||||
/* If the window class is XCB_WINDOW_CLASS_INPUT_ONLY, depth has to be 0 */
|
||||
uint16_t depth = (window_class == XCB_WINDOW_CLASS_INPUT_ONLY ? 0 : XCB_COPY_FROM_PARENT);
|
||||
|
||||
/* Use the default cursor (left pointer) */
|
||||
if (cursor > -1) {
|
||||
i3Font *cursor_font = load_font(conn, "cursor");
|
||||
xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id,
|
||||
XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1,
|
||||
0, 0, 0, 65535, 65535, 65535);
|
||||
}
|
||||
|
||||
cookie = xcb_create_window_checked(conn,
|
||||
depth,
|
||||
result, /* the window id */
|
||||
|
@ -142,6 +153,11 @@ xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_cl
|
|||
values);
|
||||
check_error(conn, cookie, "Could not create window");
|
||||
|
||||
if (cursor > -1) {
|
||||
cookie = xcb_change_window_attributes_checked(conn, result, XCB_CW_CURSOR, &cursor_id);
|
||||
check_error(conn, cookie, "Could not change window attributes");
|
||||
}
|
||||
|
||||
/* Map the window (= make it visible) */
|
||||
xcb_map_window(conn, result);
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ static void initialize_screen(xcb_connection_t *connection, i3Screen *screen, Wo
|
|||
font->height + 6};
|
||||
uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
|
||||
uint32_t values[] = {1, XCB_EVENT_MASK_EXPOSURE};
|
||||
screen->bar = create_window(connection, bar_rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, mask, values);
|
||||
screen->bar = create_window(connection, bar_rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values);
|
||||
screen->bargc = xcb_generate_id(connection);
|
||||
xcb_create_gc(connection, screen->bargc, screen->bar, 0, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue