[digesting_libdecor] lift the gtk-plugin's registry listener vtable up next to my registry listener vtable
parent
63fc21f13a
commit
9a043fb9c9
|
|
@ -126,6 +126,53 @@ const struct wl_registry_listener wl_registry_listener = {
|
|||
wlevent__wl_registry_global_remove,
|
||||
};
|
||||
|
||||
static void
|
||||
registry_handle_global(void *user_data,
|
||||
struct wl_registry *wl_registry,
|
||||
uint32_t id,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
struct libdecor_plugin_gtk *plugin_gtk = user_data;
|
||||
|
||||
if (strcmp(interface, "wl_compositor") == 0){
|
||||
init_wl_compositor(plugin_gtk, id, version);
|
||||
}
|
||||
else if (strcmp(interface, "wl_subcompositor") == 0){
|
||||
init_wl_subcompositor(plugin_gtk, id, version);
|
||||
}
|
||||
else if (strcmp(interface, "wl_shm") == 0){
|
||||
init_wl_shm(plugin_gtk, id, version);
|
||||
}
|
||||
else if (strcmp(interface, "wl_seat") == 0){
|
||||
init_wl_seat(plugin_gtk, id, version);
|
||||
}
|
||||
else if (strcmp(interface, "wl_output") == 0){
|
||||
init_wl_output(plugin_gtk, id, version);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
registry_handle_global_remove(void *user_data,
|
||||
struct wl_registry *wl_registry,
|
||||
uint32_t name)
|
||||
{
|
||||
struct libdecor_plugin_gtk *plugin_gtk = user_data;
|
||||
struct output *output;
|
||||
|
||||
wl_list_for_each(output, &plugin_gtk->output_list, link) {
|
||||
if (output->id == name) {
|
||||
output_removed(plugin_gtk, output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const struct wl_registry_listener registry_listener = {
|
||||
registry_handle_global,
|
||||
registry_handle_global_remove
|
||||
};
|
||||
|
||||
/* (libdecor.h) libdecor_interface::error " An error event " */
|
||||
static void
|
||||
libdecorevent__error(enum libdecor_error error, const char *msg){}
|
||||
|
|
@ -256,11 +303,13 @@ int main(){
|
|||
gtk_init_success = 1;
|
||||
}
|
||||
|
||||
{
|
||||
color_scheme = libdecor_get_color_scheme();
|
||||
g_object_set(gtk_settings_get_default(),
|
||||
"gtk-application-prefer-dark-theme",
|
||||
(color_scheme == LIBDECOR_COLOR_SCHEME_PREFER_DARK), NULL);
|
||||
|
||||
if (!gtk_init_success){
|
||||
printf("failed to initialize gtk\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -289,8 +338,6 @@ int main(){
|
|||
plugin_gtk->cursor_size = 24;
|
||||
}
|
||||
|
||||
plugin_gtk->color_scheme_setting = color_scheme;
|
||||
|
||||
plugin_gtk->wl_registry = wl_display_get_registry(ctx.wl_display);
|
||||
wl_registry_add_listener(plugin_gtk->wl_registry,
|
||||
®istry_listener, plugin_gtk);
|
||||
|
|
@ -301,15 +348,13 @@ int main(){
|
|||
plugin_gtk);
|
||||
wl_display_roundtrip(ctx.wl_display);
|
||||
|
||||
if (!has_required_globals(plugin_gtk)) {
|
||||
fprintf(stderr, "libdecor-gtk-WARNING: Could not get required globals\n");
|
||||
libdecor_plugin_gtk_destroy(&plugin_gtk->plugin);
|
||||
goto plugin_failed;
|
||||
}
|
||||
|
||||
if (plugin_gtk->wl_compositor != 0 &&
|
||||
plugin_gtk->wl_subcompositor != 0 &&
|
||||
plugin_gtk->wl_shm != 0){
|
||||
ctx.plugin = &plugin_gtk->plugin;
|
||||
}
|
||||
plugin_failed:;
|
||||
}
|
||||
|
||||
if (ctx.plugin == 0){
|
||||
fprintf(stderr, "Failed to load static plugin: failed to init\n");
|
||||
exit(1);
|
||||
|
|
@ -3514,8 +3559,7 @@ set_component_input_region(struct libdecor_frame_gtk *frame_gtk,
|
|||
* the input region is the outer surface size minus the inner
|
||||
* content size
|
||||
*/
|
||||
input_region = wl_compositor_create_region(
|
||||
frame_gtk->plugin_gtk->wl_compositor);
|
||||
input_region = wl_compositor_create_region(frame_gtk->plugin_gtk->wl_compositor);
|
||||
wl_region_add(input_region, 0, 0,
|
||||
component_width, component_height);
|
||||
wl_region_subtract(input_region, -component_x, -component_y,
|
||||
|
|
@ -5009,27 +5053,6 @@ init_wl_output(struct libdecor_plugin_gtk *plugin_gtk,
|
|||
wl_output_add_listener(output->wl_output, &output_listener, output);
|
||||
}
|
||||
|
||||
static void
|
||||
registry_handle_global(void *user_data,
|
||||
struct wl_registry *wl_registry,
|
||||
uint32_t id,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
struct libdecor_plugin_gtk *plugin_gtk = user_data;
|
||||
|
||||
if (strcmp(interface, "wl_compositor") == 0)
|
||||
init_wl_compositor(plugin_gtk, id, version);
|
||||
else if (strcmp(interface, "wl_subcompositor") == 0)
|
||||
init_wl_subcompositor(plugin_gtk, id, version);
|
||||
else if (strcmp(interface, "wl_shm") == 0)
|
||||
init_wl_shm(plugin_gtk, id, version);
|
||||
else if (strcmp(interface, "wl_seat") == 0)
|
||||
init_wl_seat(plugin_gtk, id, version);
|
||||
else if (strcmp(interface, "wl_output") == 0)
|
||||
init_wl_output(plugin_gtk, id, version);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_surface_outputs(struct border_component *cmpnt, const struct output *output)
|
||||
{
|
||||
|
|
@ -5068,40 +5091,6 @@ output_removed(struct libdecor_plugin_gtk *plugin_gtk,
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void
|
||||
registry_handle_global_remove(void *user_data,
|
||||
struct wl_registry *wl_registry,
|
||||
uint32_t name)
|
||||
{
|
||||
struct libdecor_plugin_gtk *plugin_gtk = user_data;
|
||||
struct output *output;
|
||||
|
||||
wl_list_for_each(output, &plugin_gtk->output_list, link) {
|
||||
if (output->id == name) {
|
||||
output_removed(plugin_gtk, output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const struct wl_registry_listener registry_listener = {
|
||||
registry_handle_global,
|
||||
registry_handle_global_remove
|
||||
};
|
||||
|
||||
static bool
|
||||
has_required_globals(struct libdecor_plugin_gtk *plugin_gtk)
|
||||
{
|
||||
if (!plugin_gtk->wl_compositor)
|
||||
return false;
|
||||
if (!plugin_gtk->wl_subcompositor)
|
||||
return false;
|
||||
if (!plugin_gtk->wl_shm)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
globals_callback(void *user_data,
|
||||
struct wl_callback *callback,
|
||||
|
|
|
|||
|
|
@ -453,8 +453,6 @@ struct libdecor_plugin_gtk {
|
|||
char *cursor_theme_name;
|
||||
int cursor_size;
|
||||
|
||||
uint32_t color_scheme_setting;
|
||||
|
||||
int double_click_time_ms;
|
||||
int drag_threshold;
|
||||
|
||||
|
|
@ -610,9 +608,16 @@ static void init_xdg_wm_base(uint32_t id, uint32_t version);
|
|||
|
||||
//#include "plugins/gtk/libdecor-gtk.c"
|
||||
|
||||
static bool has_required_globals(struct libdecor_plugin_gtk *plugin_gtk);
|
||||
static void libdecor_plugin_gtk_destroy(struct libdecor_plugin *plugin);
|
||||
|
||||
static void init_wl_compositor(struct libdecor_plugin_gtk *plugin_gtk, uint32_t id, uint32_t version);
|
||||
static void init_wl_subcompositor(struct libdecor_plugin_gtk *plugin_gtk, uint32_t id, uint32_t version);
|
||||
static void init_wl_shm(struct libdecor_plugin_gtk *plugin_gtk, uint32_t id, uint32_t version);
|
||||
static void init_wl_seat(struct libdecor_plugin_gtk *plugin_gtk,
|
||||
uint32_t id, uint32_t version);
|
||||
static void init_wl_output(struct libdecor_plugin_gtk *plugin_gtk, uint32_t id, uint32_t version);
|
||||
|
||||
static void output_removed(struct libdecor_plugin_gtk *plugin_gtk, struct output *output);
|
||||
// digesting_libdecor
|
||||
|
||||
typedef struct Ctx{
|
||||
|
|
|
|||
Loading…
Reference in New Issue