mirror of
https://github.com/labwc/labwc.git
synced 2026-03-22 05:33:57 -04:00
tree-wide: add g_server global and prep for auto-replace
This commit is contained in:
parent
50bb882cf0
commit
60ac8f07bb
8 changed files with 35 additions and 27 deletions
|
|
@ -211,6 +211,7 @@ struct rcxml {
|
||||||
bool mag_filter;
|
bool mag_filter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* defined in main.c */
|
||||||
extern struct rcxml rc;
|
extern struct rcxml rc;
|
||||||
|
|
||||||
void rcxml_read(const char *filename);
|
void rcxml_read(const char *filename);
|
||||||
|
|
|
||||||
|
|
@ -313,6 +313,9 @@ struct server {
|
||||||
pid_t primary_client_pid;
|
pid_t primary_client_pid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* defined in main.c */
|
||||||
|
extern struct server g_server;
|
||||||
|
|
||||||
void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup);
|
void xdg_popup_create(struct view *view, struct wlr_xdg_popup *wlr_popup);
|
||||||
void xdg_shell_init(struct server *server);
|
void xdg_shell_init(struct server *server);
|
||||||
void xdg_shell_finish(struct server *server);
|
void xdg_shell_finish(struct server *server);
|
||||||
|
|
|
||||||
|
|
@ -187,8 +187,6 @@ backend_check_drm(struct wlr_backend *backend, void *is_drm)
|
||||||
static bool
|
static bool
|
||||||
should_update_activation(struct server *server)
|
should_update_activation(struct server *server)
|
||||||
{
|
{
|
||||||
assert(server);
|
|
||||||
|
|
||||||
static const char *act_env = "LABWC_UPDATE_ACTIVATION_ENV";
|
static const char *act_env = "LABWC_UPDATE_ACTIVATION_ENV";
|
||||||
char *env = getenv(act_env);
|
char *env = getenv(act_env);
|
||||||
if (env) {
|
if (env) {
|
||||||
|
|
|
||||||
|
|
@ -483,11 +483,10 @@ static enum lab_key_handled
|
||||||
handle_compositor_keybindings(struct keyboard *keyboard,
|
handle_compositor_keybindings(struct keyboard *keyboard,
|
||||||
struct wlr_keyboard_key_event *event)
|
struct wlr_keyboard_key_event *event)
|
||||||
{
|
{
|
||||||
struct seat *seat = keyboard->base.seat;
|
struct server *server = &g_server;
|
||||||
struct server *server = seat->server;
|
|
||||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||||
struct keyinfo keyinfo = get_keyinfo(wlr_keyboard, event->keycode);
|
struct keyinfo keyinfo = get_keyinfo(wlr_keyboard, event->keycode);
|
||||||
bool locked = seat->server->session_lock_manager->locked;
|
bool locked = server->session_lock_manager->locked;
|
||||||
|
|
||||||
key_state_set_pressed(event->keycode,
|
key_state_set_pressed(event->keycode,
|
||||||
event->state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
event->state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||||
|
|
|
||||||
33
src/main.c
33
src/main.c
|
|
@ -14,7 +14,16 @@
|
||||||
#include "translate.h"
|
#include "translate.h"
|
||||||
#include "menu/menu.h"
|
#include "menu/menu.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Globals
|
||||||
|
*
|
||||||
|
* Rationale: these are unlikely to ever have more than one instance
|
||||||
|
* per process, and need to last for the lifetime of the process.
|
||||||
|
* Accessing them indirectly through pointers embedded in every other
|
||||||
|
* struct just adds noise to the code.
|
||||||
|
*/
|
||||||
struct rcxml rc = { 0 };
|
struct rcxml rc = { 0 };
|
||||||
|
struct server g_server = { 0 };
|
||||||
|
|
||||||
static const struct option long_options[] = {
|
static const struct option long_options[] = {
|
||||||
{"config", required_argument, NULL, 'c'},
|
{"config", required_argument, NULL, 'c'},
|
||||||
|
|
@ -246,35 +255,35 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
increase_nofile_limit();
|
increase_nofile_limit();
|
||||||
|
|
||||||
struct server server = { 0 };
|
struct server *server = &g_server;
|
||||||
server_init(&server);
|
server_init(server);
|
||||||
server_start(&server);
|
server_start(server);
|
||||||
|
|
||||||
struct theme theme = { 0 };
|
struct theme theme = { 0 };
|
||||||
theme_init(&theme, &server, rc.theme_name);
|
theme_init(&theme, server, rc.theme_name);
|
||||||
rc.theme = &theme;
|
rc.theme = &theme;
|
||||||
server.theme = &theme;
|
server->theme = &theme;
|
||||||
|
|
||||||
menu_init(&server);
|
menu_init(server);
|
||||||
|
|
||||||
/* Delay startup of applications until the event loop is ready */
|
/* Delay startup of applications until the event loop is ready */
|
||||||
struct idle_ctx idle_ctx = {
|
struct idle_ctx idle_ctx = {
|
||||||
.server = &server,
|
.server = server,
|
||||||
.primary_client = primary_client,
|
.primary_client = primary_client,
|
||||||
.startup_cmd = startup_cmd
|
.startup_cmd = startup_cmd
|
||||||
};
|
};
|
||||||
wl_event_loop_add_idle(server.wl_event_loop, idle_callback, &idle_ctx);
|
wl_event_loop_add_idle(server->wl_event_loop, idle_callback, &idle_ctx);
|
||||||
|
|
||||||
wl_display_run(server.wl_display);
|
wl_display_run(server->wl_display);
|
||||||
|
|
||||||
session_shutdown(&server);
|
session_shutdown(server);
|
||||||
|
|
||||||
menu_finish(&server);
|
menu_finish(server);
|
||||||
theme_finish(&theme);
|
theme_finish(&theme);
|
||||||
rcxml_finish();
|
rcxml_finish();
|
||||||
font_finish();
|
font_finish();
|
||||||
|
|
||||||
server_finish(&server);
|
server_finish(server);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ regions_from_name(const char *region_name, struct output *output)
|
||||||
struct region *
|
struct region *
|
||||||
regions_from_cursor(struct server *server)
|
regions_from_cursor(struct server *server)
|
||||||
{
|
{
|
||||||
assert(server);
|
|
||||||
double lx = server->seat.cursor->x;
|
double lx = server->seat.cursor->x;
|
||||||
double ly = server->seat.cursor->y;
|
double ly = server->seat.cursor->y;
|
||||||
|
|
||||||
|
|
|
||||||
14
src/server.c
14
src/server.c
|
|
@ -111,7 +111,7 @@ reload_config_and_theme(struct server *server)
|
||||||
static int
|
static int
|
||||||
handle_sighup(int signal, void *data)
|
handle_sighup(int signal, void *data)
|
||||||
{
|
{
|
||||||
struct server *server = data;
|
struct server *server = &g_server;
|
||||||
|
|
||||||
keyboard_cancel_all_keybind_repeats(&server->seat);
|
keyboard_cancel_all_keybind_repeats(&server->seat);
|
||||||
session_environment_init();
|
session_environment_init();
|
||||||
|
|
@ -134,7 +134,7 @@ handle_sigchld(int signal, void *data)
|
||||||
{
|
{
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
info.si_pid = 0;
|
info.si_pid = 0;
|
||||||
struct server *server = data;
|
struct server *server = &g_server;
|
||||||
|
|
||||||
/* First call waitid() with NOWAIT which doesn't consume the zombie */
|
/* First call waitid() with NOWAIT which doesn't consume the zombie */
|
||||||
if (waitid(P_ALL, /*id*/ 0, &info, WEXITED | WNOHANG | WNOWAIT) == -1) {
|
if (waitid(P_ALL, /*id*/ 0, &info, WEXITED | WNOHANG | WNOWAIT) == -1) {
|
||||||
|
|
@ -302,9 +302,9 @@ static bool
|
||||||
server_global_filter(const struct wl_client *client, const struct wl_global *global, void *data)
|
server_global_filter(const struct wl_client *client, const struct wl_global *global, void *data)
|
||||||
{
|
{
|
||||||
const struct wl_interface *iface = wl_global_get_interface(global);
|
const struct wl_interface *iface = wl_global_get_interface(global);
|
||||||
struct server *server = (struct server *)data;
|
struct server *server = &g_server;
|
||||||
/* Silence unused var compiler warnings */
|
/* Silence unused var compiler warnings */
|
||||||
(void)iface; (void)server;
|
(void)iface;
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
struct wl_client *xwayland_client = (server->xwayland && server->xwayland->server)
|
struct wl_client *xwayland_client = (server->xwayland && server->xwayland->server)
|
||||||
|
|
@ -436,18 +436,18 @@ server_init(struct server *server)
|
||||||
/* Increase max client buffer size to make slow clients less likely to terminate */
|
/* Increase max client buffer size to make slow clients less likely to terminate */
|
||||||
wl_display_set_default_max_buffer_size(server->wl_display, 1024 * 1024);
|
wl_display_set_default_max_buffer_size(server->wl_display, 1024 * 1024);
|
||||||
|
|
||||||
wl_display_set_global_filter(server->wl_display, server_global_filter, server);
|
wl_display_set_global_filter(server->wl_display, server_global_filter, NULL);
|
||||||
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
server->wl_event_loop = wl_display_get_event_loop(server->wl_display);
|
||||||
|
|
||||||
/* Catch signals */
|
/* Catch signals */
|
||||||
server->sighup_source = wl_event_loop_add_signal(
|
server->sighup_source = wl_event_loop_add_signal(
|
||||||
server->wl_event_loop, SIGHUP, handle_sighup, server);
|
server->wl_event_loop, SIGHUP, handle_sighup, NULL);
|
||||||
server->sigint_source = wl_event_loop_add_signal(
|
server->sigint_source = wl_event_loop_add_signal(
|
||||||
server->wl_event_loop, SIGINT, handle_sigterm, server->wl_display);
|
server->wl_event_loop, SIGINT, handle_sigterm, server->wl_display);
|
||||||
server->sigterm_source = wl_event_loop_add_signal(
|
server->sigterm_source = wl_event_loop_add_signal(
|
||||||
server->wl_event_loop, SIGTERM, handle_sigterm, server->wl_display);
|
server->wl_event_loop, SIGTERM, handle_sigterm, server->wl_display);
|
||||||
server->sigchld_source = wl_event_loop_add_signal(
|
server->sigchld_source = wl_event_loop_add_signal(
|
||||||
server->wl_event_loop, SIGCHLD, handle_sigchld, server);
|
server->wl_event_loop, SIGCHLD, handle_sigchld, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prevent wayland clients that request the X11 clipboard but closing
|
* Prevent wayland clients that request the X11 clipboard but closing
|
||||||
|
|
|
||||||
|
|
@ -606,8 +606,7 @@ update_icon(struct xwayland_view *xwayland_view)
|
||||||
|
|
||||||
xcb_window_t window_id = xwayland_view->xwayland_surface->window_id;
|
xcb_window_t window_id = xwayland_view->xwayland_surface->window_id;
|
||||||
|
|
||||||
xcb_connection_t *xcb_conn = wlr_xwayland_get_xwm_connection(
|
xcb_connection_t *xcb_conn = wlr_xwayland_get_xwm_connection(g_server.xwayland);
|
||||||
xwayland_view->base.server->xwayland);
|
|
||||||
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_conn, 0,
|
xcb_get_property_cookie_t cookie = xcb_get_property(xcb_conn, 0,
|
||||||
window_id, atoms[ATOM_NET_WM_ICON], XCB_ATOM_CARDINAL, 0, 0x10000);
|
window_id, atoms[ATOM_NET_WM_ICON], XCB_ATOM_CARDINAL, 0, 0x10000);
|
||||||
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_conn, cookie, NULL);
|
xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_conn, cookie, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue