summaryrefslogtreecommitdiff
path: root/src/wayland/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wayland/internal.h')
-rw-r--r--src/wayland/internal.h129
1 files changed, 76 insertions, 53 deletions
diff --git a/src/wayland/internal.h b/src/wayland/internal.h
index dc85943..79fd88d 100644
--- a/src/wayland/internal.h
+++ b/src/wayland/internal.h
@@ -89,14 +89,21 @@ struct drag_icon {
int fd;
};
+#ifndef likely
+#define likely(x) __builtin_expect(!!(x), 1)
+#endif
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
struct conn_drag {
struct wl_data_source *source;
struct xdg_toplevel_drag_v1 *toplevel;
struct drag_icon icon;
const struct yasl_drag_listener *listener;
void *ud;
- uint32_t scale_120;
struct seat *seat;
+ uint32_t scale_120;
bool dropped;
bool carrying;
};
@@ -105,17 +112,19 @@ struct conn_drag {
struct touch_point {
struct yasl_surface *surface;
- int32_t id;
double x, y;
+ int32_t id;
bool active;
- bool down, moved, up;
+ bool down;
+ bool moved;
+ bool up;
};
struct seat {
+ /* 8-byte aligned pointers and 64-bit values */
struct yasl_display *conn;
struct seat *next;
struct wl_seat *proxy;
- uint32_t name;
struct wl_keyboard *keyboard;
struct wl_pointer *pointer;
struct wl_touch *touch;
@@ -128,59 +137,63 @@ struct seat {
struct tablet_pad *tablet_pads;
struct zwp_text_input_v3 *text_input;
struct clipboard *clipboard;
-
struct xkb_keymap *xkb_keymap;
struct xkb_state *xkb_state;
- xkb_mod_mask_t input_mod_masks[8];
- xkb_mod_index_t mod_shift, mod_alt, mod_ctrl, mod_super;
- bool input_mods_ready;
uint64_t repeat_started_ns;
- int repeat_fd, repeat_watch;
- int32_t repeat_rate, repeat_delay;
- uint32_t repeat_key;
- bool repeat_held;
-
struct yasl_surface *pointer_focus;
struct yasl_surface *keyboard_focus;
struct yasl_surface *tablet_focus;
struct yasl_surface *ime_focus;
struct yasl_surface *focus_leaving;
- uint32_t input_serial;
- uint32_t press_serial;
struct yasl_surface *press_surface;
+ struct yasl_surface *ptr_left;
+ struct tablet_tool *tool;
+ struct touch_point *touch_primary;
+ uint64_t pointer_buttons;
+ uint64_t tool_buttons;
+ double axis_v, axis_h, frame_v;
+ double touch_scroll_y, touch_scroll_rest;
+
+ /* Embedded structs */
+ xkb_mod_mask_t input_mod_masks[8];
+ struct yasl_vector2i pointer_pos;
+ struct yasl_vector2i ptr_left_pos;
+ struct yasl_vector2i tool_pos;
+ struct touch_point touch_points[SEAT_TOUCH_POINTS];
+ struct press_queue ptr_presses;
+ struct press_queue tool_presses;
+ /* 4-byte integers */
+ uint32_t name;
+ xkb_mod_index_t mod_shift, mod_alt, mod_ctrl, mod_super;
+ int repeat_fd, repeat_watch;
+ int32_t repeat_rate, repeat_delay;
+ uint32_t repeat_key;
+ uint32_t input_serial;
+ uint32_t press_serial;
uint32_t pointer_serial;
int cursor_shape;
- struct yasl_vector2i pointer_pos;
- uint64_t pointer_buttons;
- double axis_v, axis_h, frame_v;
int frame_v120;
int axis_discrete_v, axis_discrete_h;
int axis_value120_v, axis_value120_h;
- bool axis_has_v120_v, axis_has_v120_h;
+ struct yasl_pointer_pen pen;
+ int tool_wheel;
+
+ /* 1-byte booleans grouped tightly */
+ bool input_mods_ready;
+ bool repeat_held;
+ bool axis_has_v120_v;
+ bool axis_has_v120_h;
bool axis_smooth;
bool motion_pending;
- struct press_queue ptr_presses;
- struct yasl_surface *ptr_left;
- struct yasl_vector2i ptr_left_pos;
bool ptr_left_motion;
-
- struct tablet_tool *tool;
- struct press_queue tool_presses;
- struct yasl_vector2i tool_pos;
- uint64_t tool_buttons;
- struct yasl_pointer_pen pen;
- int tool_wheel;
bool tool_motion;
-
- struct touch_point touch_points[SEAT_TOUCH_POINTS];
- struct touch_point *touch_primary;
bool touch_pressed;
bool touch_scrolling;
- double touch_scroll_y, touch_scroll_rest;
};
#define YASL_QUEUE_CAP 256
+#define YASL_QUEUE_MASK (YASL_QUEUE_CAP - 1)
struct input_queue {
struct yasl_input_event events[YASL_QUEUE_CAP];
int head;
@@ -190,17 +203,17 @@ struct input_queue {
static inline void input_queue_push(struct input_queue *q, const struct yasl_input_event *ev)
{
- if (q->count >= YASL_QUEUE_CAP) return;
+ if (unlikely(q->count >= YASL_QUEUE_CAP)) return;
q->events[q->tail] = *ev;
- q->tail = (q->tail + 1) % YASL_QUEUE_CAP;
+ q->tail = (q->tail + 1) & YASL_QUEUE_MASK;
q->count++;
}
static inline bool input_queue_pop(struct input_queue *q, struct yasl_input_event *ev)
{
- if (q->count <= 0) return false;
+ if (unlikely(q->count <= 0)) return false;
*ev = q->events[q->head];
- q->head = (q->head + 1) % YASL_QUEUE_CAP;
+ q->head = (q->head + 1) & YASL_QUEUE_MASK;
q->count--;
return true;
}
@@ -211,6 +224,7 @@ static inline void input_queue_clear(struct input_queue *q)
}
struct yasl_display {
+ /* 8-byte pointers & 64-bit masks */
struct wl_display *wl;
struct wl_registry *registry;
struct wl_compositor *compositor;
@@ -228,7 +242,6 @@ struct yasl_display {
struct wp_cursor_shape_manager_v1 *cursor_shape_mgr;
struct wl_cursor_theme *cursor_theme;
const char *cursor_theme_name;
- int cursor_size, cursor_theme_scale;
struct zwp_tablet_manager_v2 *tablet_mgr;
struct zwp_text_input_manager_v3 *text_input_mgr;
struct wp_tearing_control_manager_v1 *tearing_mgr;
@@ -240,20 +253,28 @@ struct yasl_display {
const struct yasl_display_cbs *cbs;
void *ud;
char *app_id;
- clockid_t pres_clock;
- bool pres_clock_known;
struct xdg_toplevel_drag_manager_v1 *toplevel_drag_mgr;
struct conn_drag drag;
struct yasl_surface *surfaces;
struct yasl_surface *paste_target;
+ struct yasl_surface *dead;
+
+ /* 4-byte integers */
+ int cursor_size;
+ int cursor_theme_scale;
+ clockid_t pres_clock;
int watch;
int depth;
- struct yasl_surface *dead;
+
+ /* 1-byte booleans */
+ bool owns_loop;
+ bool pres_clock_known;
bool reading;
bool lost;
};
struct yasl_surface {
+ /* 8-byte pointers & 64-bit values */
struct yasl_display *conn;
struct yasl_surface *conn_next;
struct yasl_surface *dead_next;
@@ -263,16 +284,11 @@ struct yasl_surface {
struct xdg_toplevel *toplevel;
struct xdg_popup *popup;
struct zxdg_toplevel_decoration_v1 *toplevel_decor;
- bool server_decorated;
struct wp_fractional_scale_v1 *frac_scale;
struct wp_viewport *viewport;
-
char *ime_preedit;
char *ime_commit;
char *ime_shown;
- int ime_cursor_begin, ime_cursor_end;
- int ime_shown_begin, ime_shown_end;
- struct yasl_rect2i ime_caret;
struct seat *ime_seat;
struct wp_tearing_control_v1 *tearing_control;
struct latency_feedback *latency_feedbacks;
@@ -282,18 +298,23 @@ struct yasl_surface {
const struct yasl_surface_cbs *cbs;
void *ud;
uint64_t frames_skipped;
+ uint64_t outputs;
+ double scale_factor;
+ /* Sub-structures */
+ struct yasl_rect2i ime_caret;
+ struct yasl_rect2i content;
struct yasl_frame_clock clock;
- struct input_queue input;
-
struct buffer buffers[NBUF];
struct yasl_frame frame;
struct yasl_damage_list damage;
- bool frame_active;
- bool frame_presented;
+ int ime_cursor_begin;
+ struct input_queue input;
+ /* 4-byte integers */
+ int ime_cursor_end;
+ int ime_shown_begin, ime_shown_end;
int floating_width, floating_height;
- struct yasl_rect2i content;
int cur;
int width, height;
int logical_width, logical_height;
@@ -302,9 +323,11 @@ struct yasl_surface {
uint32_t scale_120;
uint32_t pending_scale_120;
uint32_t pending_serial;
- double scale_factor;
- uint64_t outputs;
+ /* 1-byte booleans packed tightly */
+ bool server_decorated;
+ bool frame_active;
+ bool frame_presented;
bool tiled;
bool size_pending;
bool sample_refresh;