commit 0d546e8
Michael Forney
·
2014-01-23 00:26:06 +0000 UTC
parent e7f2467
pointer: Set left pointer cursor by default
3 files changed,
+33,
-0
+1,
-0
1@@ -85,6 +85,7 @@ SWC_SHARED_OBJECTS = $(SWC_SOURCES:%.c=%.lo)
2 objects = $(foreach obj,$(1),$(dir)/$(obj).o $(dir)/$(obj).lo)
3 $(call objects,drm drm_buffer): protocol/wayland-drm-server-protocol.h
4 $(call objects,xserver): protocol/xserver-server-protocol.h
5+$(call objects,pointer): cursor/cursor_data.h
6
7 $(dir)/libswc.a: $(SWC_STATIC_OBJECTS)
8 $(call quiet,AR) cru $@ $^
+27,
-0
1@@ -4,6 +4,7 @@
2 #include "screen.h"
3 #include "shm.h"
4 #include "util.h"
5+#include "cursor/cursor_data.h"
6
7 #include <stdio.h>
8 #include <assert.h>
9@@ -158,6 +159,30 @@ static inline void update_cursor(struct swc_pointer * pointer)
10 wl_fixed_to_int(pointer->y) - pointer->cursor.hotspot.y);
11 }
12
13+void swc_pointer_set_cursor(struct swc_pointer * pointer, uint32_t id)
14+{
15+ struct cursor * cursor = &cursor_metadata[id];
16+ union wld_object object = { .ptr = &cursor_data[cursor->offset] };
17+
18+ if (pointer->cursor.internal_buffer.wld)
19+ wld_destroy_buffer(pointer->cursor.internal_buffer.wld);
20+
21+ pointer->cursor.internal_buffer.wld = wld_import_buffer
22+ (swc.shm->context, WLD_OBJECT_DATA, object,
23+ cursor->width, cursor->height, WLD_FORMAT_ARGB8888, cursor->width * 4);
24+
25+ if (!pointer->cursor.internal_buffer.wld)
26+ {
27+ ERROR("Failed to create cursor buffer\n");
28+ return;
29+ }
30+
31+ pointer->cursor.hotspot.x = cursor->hotspot_x;
32+ pointer->cursor.hotspot.y = cursor->hotspot_y;
33+ swc_view_attach(&pointer->cursor.view, &pointer->cursor.internal_buffer);
34+ update_cursor(pointer);
35+}
36+
37 bool swc_pointer_initialize(struct swc_pointer * pointer)
38 {
39 struct wld_buffer * buffer;
40@@ -185,6 +210,8 @@ bool swc_pointer_initialize(struct swc_pointer * pointer)
41 return false;
42
43 swc_buffer_initialize(&pointer->cursor.buffer, buffer);
44+ swc_buffer_initialize(&pointer->cursor.internal_buffer, NULL);
45+ swc_pointer_set_cursor(pointer, cursor_left_ptr);
46
47 swc_input_focus_initialize(&pointer->focus, &pointer->focus_handler);
48 pixman_region32_init(&pointer->region);
+5,
-0
1@@ -34,6 +34,9 @@ struct swc_pointer
2 struct wl_listener destroy_listener;
3 struct swc_buffer buffer;
4
5+ /* Used for cursors set with swc_pointer_set_cursor */
6+ struct swc_buffer internal_buffer;
7+
8 struct
9 {
10 int32_t x, y;
11@@ -52,6 +55,8 @@ void swc_pointer_set_focus(struct swc_pointer * pointer,
12 struct swc_surface * surface);
13 void swc_pointer_set_region(struct swc_pointer * pointer,
14 pixman_region32_t * region);
15+void swc_pointer_set_cursor(struct swc_pointer * pointer, uint32_t id);
16+
17 struct wl_resource * swc_pointer_bind(struct swc_pointer * pointer,
18 struct wl_client * client, uint32_t id);
19 void swc_pointer_handle_button(struct swc_pointer * pointer, uint32_t time,