Dunst
Lightweight notification daemon
Loading...
Searching...
No Matches
output.c
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
7
8#include "output.h"
9#include "log.h"
10
11#ifdef ENABLE_X11
12#include "x11/x.h"
13#include "x11/screen.h"
14#endif
15
16#ifdef ENABLE_WAYLAND
17#include "wayland/wl.h"
18#endif
19
20bool is_running_wayland(void) {
21 char* wayland_display = getenv("WAYLAND_DISPLAY");
22 return !(wayland_display == NULL);
23}
24
25#ifdef ENABLE_X11
26const struct output output_x11 = {
27 x_setup,
28 x_free,
29
30 x_win_create,
31 x_win_destroy,
32
33 x_win_show,
34 x_win_hide,
35
36 x_display_surface,
37 x_win_get_context,
38
39 get_active_screen,
40
41 x_is_idle,
43
44 x_get_scale,
45};
46#endif
47
48#ifdef ENABLE_WAYLAND
49const struct output output_wl = {
50 wl_init,
51 wl_deinit,
52
53 wl_win_create,
54 wl_win_destroy,
55
56 wl_win_show,
57 wl_win_hide,
58
59 wl_display_surface,
60 wl_win_get_context,
61
62 wl_get_active_screen,
63
64 wl_is_idle,
65 wl_have_fullscreen_window,
66
67 wl_get_scale,
68};
69#endif
70
71#ifdef ENABLE_X11
72const struct output* get_x11_output(void) {
73 const struct output* output = &output_x11;
74 if (output->init()) {
75 return output;
76 } else {
77 DIE("Couldn't initialize X11 output. Aborting...");
78 }
79}
80#endif
81
82#ifdef ENABLE_WAYLAND
83const struct output* get_wl_output(void) {
84 const struct output* output = &output_wl;
85 if (output->init()) {
86 return output;
87 } else {
88#ifdef ENABLE_X11
89 LOG_W("Couldn't initialize wayland output. Falling back to X11 output.");
90 output->deinit();
91 return get_x11_output();
92#else
93 DIE("Couldn't initialize wayland output");
94#endif
95 }
96}
97#endif
98
99const struct output* output_create(bool force_xwayland)
100{
101#ifdef ENABLE_WAYLAND
102 if ((!force_xwayland || !X11_SUPPORT) && is_running_wayland()) {
103 LOG_I("Using Wayland output");
104 if (force_xwayland)
105 LOG_W("Ignoring force_xwayland setting because X11 output was not compiled");
106 return get_wl_output();
107 }
108#endif
109
110#ifdef ENABLE_X11
111 LOG_I("Using X11 output");
112 return get_x11_output();
113#endif
114
115 DIE("No applicable ouput was found (X11, Wayland)");
116}
Logging subsystem and helpers.
const struct output * output_create(bool force_xwayland)
return an initialized output, selecting the correct output type from either wayland or X11 according ...
Definition output.c:99
Generic graphics backend wrapper.
bool have_fullscreen_window(void)
Find the currently focused window and check if it's in fullscreen mode.
Definition screen.c:238
Xorg screen managment.
Wayland window managment.
Xorg output wrapper.