Skip to content

Commit 4116a2f

Browse files
committed
chore: small refactor p2
1 parent e98784c commit 4116a2f

54 files changed

Lines changed: 568 additions & 450 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/foreign_capture.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#pragma once
2+
3+
void foreign_capture_init(void);
4+
void foreign_capture_fini(void);

include/lock.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
#include <wayland-server.h>
44

5-
typedef struct session_lock_t {
6-
struct wlr_session_lock_v1 *session_lock;
7-
struct wlr_scene_tree *scene_tree;
8-
9-
struct wl_listener new_surface;
10-
struct wl_listener unlock;
11-
struct wl_listener destroy;
12-
} session_lock_t;
13-
14-
void handle_new_session_lock(struct wl_listener *listener, void *data);
155
void destroy_lock_surface(struct wl_listener *listener, void *data);
6+
7+
void session_lock_init(void);
8+
void session_lock_fini(void);

include/once.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <wlr/util/log.h>
2+
3+
#if DEBUG
4+
#define ONCE() \
5+
do { \
6+
static int _called_once_flag_##__LINE__ = 0; \
7+
if (_called_once_flag_##__LINE__) \
8+
wlr_log(WLR_ERROR, "Function %s called more than once", __func__); \
9+
_called_once_flag_##__LINE__ = 1; \
10+
} while(0)
11+
#else
12+
#define ONCE() ;
13+
#endif

include/output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ typedef struct output_t {
6565
struct output_t *prev, *next;
6666
} output_t;
6767

68-
void handle_new_output(struct wl_listener *listener, void *data);
68+
void output_create(struct wlr_output *wlr_output);
6969
void output_enable(output_t *output);
7070
void output_disable(output_t *output);
7171
void output_destroy(output_t *output);

include/toplevel.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ void toplevel_send_frame_done(toplevel_t *toplevel);
8989

9090
void toplevel_freeze_sibling_buffers(desktop_t *d, node_t *n);
9191

92-
void handle_new_toplevel_capture_request(struct wl_listener *listener, void *data);
93-
9492
void toplevel_set_effect(toplevel_t *tl, surface_effect_t effect, bool enabled);
9593
void toplevel_set_border_radius(toplevel_t *tl, float radius);
9694
void toplevel_set_shadow(toplevel_t *tl, bool enabled);

include/xwayland.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ typedef struct xwayland_unmanaged_t {
9797
struct wl_listener override_redirect;
9898
} xwayland_unmanaged_t;
9999

100-
void handle_xwayland_ready(struct wl_listener *listener, void *data);
101-
void handle_xwayland_surface(struct wl_listener *listener, void *data);
102-
103100
void xwayland_view_close(xwayland_toplevel_t *xwayland_view);
104101
void xwayland_view_set_activated(xwayland_toplevel_t *xwayland_view, bool activated);
105102

106103
void xwayland_set_effect(xwayland_toplevel_t *xwayland_view, surface_effect_t effect, bool enabled);
107104
void xwayland_set_border_radius(xwayland_toplevel_t *xwayland_view, float radius);
108105
void xwayland_set_shadow(xwayland_toplevel_t *xwayland_view, bool enabled);
106+
107+
void xwayland_init(void);
108+
void xwayland_fini(void);

meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ project(
55
)
66

77
add_project_arguments('-DWLR_USE_UNSTABLE', language: 'c')
8+
if get_option('debug')
9+
add_project_arguments('-DDEBUG', language: 'c')
10+
endif
811

912
wayland_protos = dependency('wayland-protocols')
1013

@@ -106,6 +109,7 @@ executable(
106109
'src' / 'effects.c',
107110
'src' / 'effects_gles2.c',
108111
'src' / 'effects_vk.c',
112+
'src' / 'foreign_capture.c',
109113
'src' / 'gesture.c',
110114
'src' / 'global_shortcuts.c',
111115
'src' / 'idle.c',

src/animation.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "animation.h"
22
#include "bezier.h"
33
#include "layer.h"
4+
#include "once.h"
45
#include "output.h"
56
#include "spring.h"
67
#include "surface.h"
@@ -12,7 +13,6 @@
1213
#include <stdlib.h>
1314
#include <wlr/types/wlr_output.h>
1415
#include <wlr/types/wlr_scene.h>
15-
#include <wlr/util/log.h>
1616

1717
#define SPRING_FIXED_DT 0.001
1818
#define SPRING_MAX_STEPS 10
@@ -295,13 +295,15 @@ bool animation_type_get_enabled(const char *type_name) {
295295
}
296296

297297
void animation_init(void) {
298+
ONCE();
298299
wl_list_init(&animations);
299300

300301
for (int i = 0; i < ANIM_TYPE_COUNT; i++)
301302
anim_type_configs[i].enabled = true;
302303
}
303304

304305
void animation_fini(void) {
306+
ONCE();
305307
animation_entry_t *entry, *tmp;
306308
wl_list_for_each_safe(entry, tmp, &animations, link) {
307309
if (entry->from_opacity != entry->to_opacity && entry->scene_tree) {

src/backend.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "input.h"
22
#include "keyboard.h"
3+
#include "once.h"
34
#include "output.h"
45
#include "pointer.h"
56
#include "seat.h"
@@ -66,7 +67,17 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
6667
}
6768
}
6869

70+
static void handle_new_output(struct wl_listener *listener, void *data) {
71+
(void)listener;
72+
struct wlr_output *wlr_output = data;
73+
if (!wlr_output)
74+
return;
75+
76+
output_create(wlr_output);
77+
}
78+
6979
void backend_init(void) {
80+
ONCE();
7081
server.backend = wlr_backend_autocreate(wl_display_get_event_loop(server.wl_display),
7182
&server.session);
7283
if (server.backend == NULL) {
@@ -93,6 +104,7 @@ void backend_init(void) {
93104
}
94105

95106
void backend_fini(void) {
107+
ONCE();
96108
wl_list_remove(&server.new_input.link);
97109
wl_list_remove(&server.new_output.link);
98110
}

src/bell.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "config.h"
2+
#include "once.h"
23
#include "server.h"
34
#include <wlr/types/wlr_xdg_system_bell_v1.h>
4-
#include <wlr/util/log.h>
55

66
static int handle_system_bell_timer(void *data) {
77
(void)data;
@@ -24,6 +24,7 @@ static void handle_ring_system_bell(struct wl_listener *listener, void *data) {
2424
}
2525

2626
void bell_init(void) {
27+
ONCE();
2728
server.xdg_system_bell = wlr_xdg_system_bell_v1_create(server.wl_display, 1);
2829
if (!server.xdg_system_bell) {
2930
wlr_log(WLR_ERROR, "Failed to create xdg system bell");
@@ -34,5 +35,6 @@ void bell_init(void) {
3435
}
3536

3637
void bell_fini(void) {
38+
ONCE();
3739
wl_list_remove(&server.ring_system_bell.link);
3840
}

0 commit comments

Comments
 (0)