window: track changes in libwayland-cursor api
libwayland-cursor does not provide enum wl_cursor_type anymore so this
brings back enum pointer_type.
This partially revers commit 1042dc15e0.
This commit is contained in:
committed by
Kristian Høgsberg
parent
bf38190744
commit
d8f527c845
+1
-2
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@@ -219,7 +218,7 @@ motion_handler(struct widget *widget,
|
|||||||
|
|
||||||
window_schedule_redraw(clickdot->window);
|
window_schedule_redraw(clickdot->window);
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -34,7 +34,6 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "../shared/cairo-util.h"
|
#include "../shared/cairo-util.h"
|
||||||
#include "../shared/config-parser.h"
|
#include "../shared/config-parser.h"
|
||||||
@@ -253,7 +252,7 @@ panel_launcher_enter_handler(struct widget *widget, struct input *input,
|
|||||||
launcher->focused = 1;
|
launcher->focused = 1;
|
||||||
widget_schedule_redraw(widget);
|
widget_schedule_redraw(widget);
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -527,7 +526,7 @@ unlock_dialog_widget_enter_handler(struct widget *widget,
|
|||||||
dialog->button_focused = 1;
|
dialog->button_focused = 1;
|
||||||
widget_schedule_redraw(widget);
|
widget_schedule_redraw(widget);
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+4
-4
@@ -318,7 +318,7 @@ create_drag_cursor(struct dnd_drag *dnd_drag,
|
|||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
pointer = display_get_pointer_image(dnd->display, WL_CURSOR_DRAGGING);
|
pointer = display_get_pointer_image(dnd->display, POINTER_DRAGGING);
|
||||||
|
|
||||||
rectangle.width = item_width + 2 * pointer->width;
|
rectangle.width = item_width + 2 * pointer->width;
|
||||||
rectangle.height = item_height + 2 * pointer->height;
|
rectangle.height = item_height + 2 * pointer->height;
|
||||||
@@ -410,7 +410,7 @@ dnd_button_handler(struct widget *widget,
|
|||||||
dnd_drag->drag_surface,
|
dnd_drag->drag_surface,
|
||||||
serial);
|
serial);
|
||||||
|
|
||||||
input_set_pointer_image(input, time, WL_CURSOR_DRAGGING);
|
input_set_pointer_image(input, time, POINTER_DRAGGING);
|
||||||
|
|
||||||
dnd_drag->opaque =
|
dnd_drag->opaque =
|
||||||
create_drag_cursor(dnd_drag, item, x, y, 1);
|
create_drag_cursor(dnd_drag, item, x, y, 1);
|
||||||
@@ -434,9 +434,9 @@ lookup_cursor(struct dnd *dnd, int x, int y)
|
|||||||
|
|
||||||
item = dnd_get_item(dnd, x, y);
|
item = dnd_get_item(dnd, x, y);
|
||||||
if (item)
|
if (item)
|
||||||
return WL_CURSOR_HAND1;
|
return POINTER_HAND1;
|
||||||
else
|
else
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
+2
-3
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
#include <wayland-cursor.h>
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
/** window title */
|
/** window title */
|
||||||
@@ -248,9 +247,9 @@ motion_handler(struct widget *widget, struct input *input, uint32_t time,
|
|||||||
|
|
||||||
if (x > e->x && x < e->x + e->w)
|
if (x > e->x && x < e->x + e->w)
|
||||||
if (y > e->y && y < e->y + e->h)
|
if (y > e->y && y < e->y + e->h)
|
||||||
return WL_CURSOR_HAND1;
|
return POINTER_HAND1;
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-2
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
struct flower {
|
struct flower {
|
||||||
@@ -134,7 +133,7 @@ static int
|
|||||||
motion_handler(struct widget *widget, struct input *input,
|
motion_handler(struct widget *widget, struct input *input,
|
||||||
uint32_t time, float x, float y, void *data)
|
uint32_t time, float x, float y, void *data)
|
||||||
{
|
{
|
||||||
return WL_CURSOR_HAND1;
|
return POINTER_HAND1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+1
-2
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@@ -244,7 +243,7 @@ motion_handler(struct widget *widget, struct input *input,
|
|||||||
gears->view.rotx = gears->view.rotx + 360;
|
gears->view.rotx = gears->view.rotx + 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+1
-2
@@ -30,7 +30,6 @@
|
|||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
struct smoke {
|
struct smoke {
|
||||||
@@ -259,7 +258,7 @@ smoke_motion_handler(struct widget *widget, struct input *input,
|
|||||||
smoke->b[0].d[k] += 1;
|
smoke->b[0].d[k] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WL_CURSOR_HAND1;
|
return POINTER_HAND1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
+1
-2
@@ -34,7 +34,6 @@
|
|||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-cursor.h>
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
@@ -2246,7 +2245,7 @@ motion_handler(struct widget *widget,
|
|||||||
widget_schedule_redraw(widget);
|
widget_schedule_redraw(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WL_CURSOR_IBEAM;
|
return POINTER_IBEAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct terminal *
|
static struct terminal *
|
||||||
|
|||||||
+60
-23
@@ -104,6 +104,7 @@ struct display {
|
|||||||
} xkb;
|
} xkb;
|
||||||
|
|
||||||
struct wl_cursor_theme *cursor_theme;
|
struct wl_cursor_theme *cursor_theme;
|
||||||
|
struct wl_cursor **cursors;
|
||||||
|
|
||||||
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC image_target_texture_2d;
|
||||||
PFNEGLCREATEIMAGEKHRPROC create_image;
|
PFNEGLCREATEIMAGEKHRPROC create_image;
|
||||||
@@ -287,8 +288,8 @@ struct shm_pool {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WL_CURSOR_DEFAULT = 100,
|
POINTER_DEFAULT = 100,
|
||||||
WL_CURSOR_UNSET
|
POINTER_UNSET
|
||||||
};
|
};
|
||||||
|
|
||||||
enum window_location {
|
enum window_location {
|
||||||
@@ -626,11 +627,48 @@ display_create_surface(struct display *display,
|
|||||||
return display_create_shm_surface(display, rectangle, flags, NULL);
|
return display_create_shm_surface(display, rectangle, flags, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *cursors[] = {
|
||||||
|
"bottom_left_corner",
|
||||||
|
"bottom_right_corner",
|
||||||
|
"bottom_side",
|
||||||
|
"grabbing",
|
||||||
|
"left_ptr",
|
||||||
|
"left_side",
|
||||||
|
"right_side",
|
||||||
|
"top_left_corner",
|
||||||
|
"top_right_corner",
|
||||||
|
"top_side",
|
||||||
|
"xterm",
|
||||||
|
"hand1",
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_cursors(struct display *display)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
display->cursor_theme = wl_cursor_theme_load(NULL, 32, display->shm);
|
||||||
|
display->cursors =
|
||||||
|
malloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]);
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(cursors); i++)
|
||||||
|
display->cursors[i] =
|
||||||
|
wl_cursor_theme_get_cursor(display->cursor_theme,
|
||||||
|
cursors[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
destroy_cursors(struct display *display)
|
||||||
|
{
|
||||||
|
wl_cursor_theme_destroy(display->cursor_theme);
|
||||||
|
}
|
||||||
|
|
||||||
struct wl_cursor_image *
|
struct wl_cursor_image *
|
||||||
display_get_pointer_image(struct display *display, int pointer)
|
display_get_pointer_image(struct display *display, int pointer)
|
||||||
{
|
{
|
||||||
struct wl_cursor *cursor =
|
struct wl_cursor *cursor =
|
||||||
wl_cursor_theme_get_cursor(display->cursor_theme, pointer);
|
wl_cursor_theme_get_cursor(display->cursor_theme,
|
||||||
|
cursors[pointer]);
|
||||||
|
|
||||||
return cursor ? cursor->images[0] : NULL;
|
return cursor ? cursor->images[0] : NULL;
|
||||||
}
|
}
|
||||||
@@ -1294,7 +1332,7 @@ frame_button_enter_handler(struct widget *widget,
|
|||||||
widget_schedule_redraw(frame_button->widget);
|
widget_schedule_redraw(frame_button->widget);
|
||||||
frame_button->state = FRAME_BUTTON_OVER;
|
frame_button->state = FRAME_BUTTON_OVER;
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1474,25 +1512,25 @@ frame_get_pointer_image_for_location(struct frame *frame, struct input *input)
|
|||||||
|
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case THEME_LOCATION_RESIZING_TOP:
|
case THEME_LOCATION_RESIZING_TOP:
|
||||||
return WL_CURSOR_TOP;
|
return POINTER_TOP;
|
||||||
case THEME_LOCATION_RESIZING_BOTTOM:
|
case THEME_LOCATION_RESIZING_BOTTOM:
|
||||||
return WL_CURSOR_BOTTOM;
|
return POINTER_BOTTOM;
|
||||||
case THEME_LOCATION_RESIZING_LEFT:
|
case THEME_LOCATION_RESIZING_LEFT:
|
||||||
return WL_CURSOR_LEFT;
|
return POINTER_LEFT;
|
||||||
case THEME_LOCATION_RESIZING_RIGHT:
|
case THEME_LOCATION_RESIZING_RIGHT:
|
||||||
return WL_CURSOR_RIGHT;
|
return POINTER_RIGHT;
|
||||||
case THEME_LOCATION_RESIZING_TOP_LEFT:
|
case THEME_LOCATION_RESIZING_TOP_LEFT:
|
||||||
return WL_CURSOR_TOP_LEFT;
|
return POINTER_TOP_LEFT;
|
||||||
case THEME_LOCATION_RESIZING_TOP_RIGHT:
|
case THEME_LOCATION_RESIZING_TOP_RIGHT:
|
||||||
return WL_CURSOR_TOP_RIGHT;
|
return POINTER_TOP_RIGHT;
|
||||||
case THEME_LOCATION_RESIZING_BOTTOM_LEFT:
|
case THEME_LOCATION_RESIZING_BOTTOM_LEFT:
|
||||||
return WL_CURSOR_BOTTOM_LEFT;
|
return POINTER_BOTTOM_LEFT;
|
||||||
case THEME_LOCATION_RESIZING_BOTTOM_RIGHT:
|
case THEME_LOCATION_RESIZING_BOTTOM_RIGHT:
|
||||||
return WL_CURSOR_BOTTOM_RIGHT;
|
return POINTER_BOTTOM_RIGHT;
|
||||||
case THEME_LOCATION_EXTERIOR:
|
case THEME_LOCATION_EXTERIOR:
|
||||||
case THEME_LOCATION_TITLEBAR:
|
case THEME_LOCATION_TITLEBAR:
|
||||||
default:
|
default:
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1567,7 +1605,7 @@ frame_button_handler(struct widget *widget,
|
|||||||
case THEME_LOCATION_TITLEBAR:
|
case THEME_LOCATION_TITLEBAR:
|
||||||
if (!window->shell_surface)
|
if (!window->shell_surface)
|
||||||
break;
|
break;
|
||||||
input_set_pointer_image(input, time, WL_CURSOR_DRAGGING);
|
input_set_pointer_image(input, time, POINTER_DRAGGING);
|
||||||
input_ungrab(input);
|
input_ungrab(input);
|
||||||
wl_shell_surface_move(window->shell_surface,
|
wl_shell_surface_move(window->shell_surface,
|
||||||
input_get_seat(input),
|
input_get_seat(input),
|
||||||
@@ -1659,7 +1697,7 @@ input_set_focus_widget(struct input *input, struct widget *focus,
|
|||||||
float x, float y)
|
float x, float y)
|
||||||
{
|
{
|
||||||
struct widget *old, *widget;
|
struct widget *old, *widget;
|
||||||
int pointer = WL_CURSOR_LEFT_PTR;
|
int pointer = POINTER_LEFT_PTR;
|
||||||
|
|
||||||
if (focus == input->focus_widget)
|
if (focus == input->focus_widget)
|
||||||
return;
|
return;
|
||||||
@@ -1695,7 +1733,7 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer,
|
|||||||
struct input *input = data;
|
struct input *input = data;
|
||||||
struct window *window = input->pointer_focus;
|
struct window *window = input->pointer_focus;
|
||||||
struct widget *widget;
|
struct widget *widget;
|
||||||
int cursor = WL_CURSOR_LEFT_PTR;
|
int cursor = POINTER_LEFT_PTR;
|
||||||
float sx = wl_fixed_to_double(sx_w);
|
float sx = wl_fixed_to_double(sx_w);
|
||||||
float sy = wl_fixed_to_double(sy_w);
|
float sy = wl_fixed_to_double(sy_w);
|
||||||
|
|
||||||
@@ -1826,7 +1864,7 @@ input_remove_pointer_focus(struct input *input)
|
|||||||
input_set_focus_widget(input, NULL, 0, 0);
|
input_set_focus_widget(input, NULL, 0, 0);
|
||||||
|
|
||||||
input->pointer_focus = NULL;
|
input->pointer_focus = NULL;
|
||||||
input->current_cursor = WL_CURSOR_UNSET;
|
input->current_cursor = POINTER_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2147,7 +2185,6 @@ static const struct wl_data_device_listener data_device_listener = {
|
|||||||
void
|
void
|
||||||
input_set_pointer_image(struct input *input, uint32_t time, int pointer)
|
input_set_pointer_image(struct input *input, uint32_t time, int pointer)
|
||||||
{
|
{
|
||||||
struct display *display = input->display;
|
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
struct wl_cursor *cursor;
|
struct wl_cursor *cursor;
|
||||||
struct wl_cursor_image *image;
|
struct wl_cursor_image *image;
|
||||||
@@ -2155,7 +2192,7 @@ input_set_pointer_image(struct input *input, uint32_t time, int pointer)
|
|||||||
if (pointer == input->current_cursor)
|
if (pointer == input->current_cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursor = wl_cursor_theme_get_cursor(display->cursor_theme, pointer);
|
cursor = input->display->cursors[pointer];
|
||||||
if (!cursor)
|
if (!cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2726,7 +2763,7 @@ menu_motion_handler(struct widget *widget,
|
|||||||
if (widget == menu->widget)
|
if (widget == menu->widget)
|
||||||
menu_set_item(data, y);
|
menu_set_item(data, y);
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -2738,7 +2775,7 @@ menu_enter_handler(struct widget *widget,
|
|||||||
if (widget == menu->widget)
|
if (widget == menu->widget)
|
||||||
menu_set_item(data, y);
|
menu_set_item(data, y);
|
||||||
|
|
||||||
return WL_CURSOR_LEFT_PTR;
|
return POINTER_LEFT_PTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -3245,7 +3282,7 @@ display_create(int argc, char *argv[])
|
|||||||
d->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
|
d->create_image = (void *) eglGetProcAddress("eglCreateImageKHR");
|
||||||
d->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
|
d->destroy_image = (void *) eglGetProcAddress("eglDestroyImageKHR");
|
||||||
|
|
||||||
d->cursor_theme = wl_cursor_theme_load(NULL, 32, d->shm);
|
create_cursors(d);
|
||||||
|
|
||||||
d->theme = theme_create();
|
d->theme = theme_create();
|
||||||
|
|
||||||
@@ -3291,7 +3328,7 @@ display_destroy(struct display *display)
|
|||||||
fini_xkb(display);
|
fini_xkb(display);
|
||||||
|
|
||||||
theme_destroy(display->theme);
|
theme_destroy(display->theme);
|
||||||
wl_cursor_theme_destroy(display->cursor_theme);
|
destroy_cursors(display);
|
||||||
|
|
||||||
#ifdef HAVE_CAIRO_EGL
|
#ifdef HAVE_CAIRO_EGL
|
||||||
fini_egl(display);
|
fini_egl(display);
|
||||||
|
|||||||
Reference in New Issue
Block a user