diff --git a/digesting_libdecor.c b/digesting_libdecor.c index e4a72c2..5fc0df8 100755 --- a/digesting_libdecor.c +++ b/digesting_libdecor.c @@ -119,8 +119,7 @@ wlevent__wl_registry_global(void *data, struct wl_registry *wl_registry, else if (strcmp(interface, "wl_seat") == 0){ struct seat *seat; if (version < 3){ - libdecor_notify_plugin_error(LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, - "%s version 3 required but only version %i is available\n", interface, version); + ctx.has_error = true; } seat = calloc(1, sizeof *seat); @@ -133,8 +132,7 @@ wlevent__wl_registry_global(void *data, struct wl_registry *wl_registry, else if (strcmp(interface, "wl_output") == 0){ struct output *output; if (version < 2){ - libdecor_notify_plugin_error(LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, - "%s version 2 required but only version %i is available\n", interface, version); + ctx.has_error = true; } output = calloc(1, sizeof *output); @@ -164,54 +162,6 @@ const struct wl_registry_listener wl_registry_listener = { wlevent__wl_registry_global_remove, }; -static void -libdecorevent__error(enum libdecor_error error, const char *msg){} - -static void -libdecorevent__frame_configure(struct libdecor_frame *frame, - struct libdecor_configuration *config, - void *udata){ - int w = ctx.w; - int h = ctx.h; - if (libdecor_configuration_get_content_size(config, frame, &w, &h)){ - ctx.w = w; - ctx.h = h; - } - if (!ctx.configured){ - ctx.configured = 1; - struct libdecor_state *state = libdecor_state_new(w, h); - libdecor_frame_commit(frame, state, config); - libdecor_state_free(state); - } - else{ - ctx.has_cached_config = 1; - ctx.cached_config = *config; - } -} - -static void -libdecorevent__frame_close(struct libdecor_frame *frame, void *udata){ - ctx.close_signal = 1; -} - -static void -libdecorevent__frame_commit(struct libdecor_frame *frame, void *udata){ - wl_surface_commit(ctx.wl_surface); -} - -static void -libdecorevent__frame_dismiss_popup(struct libdecor_frame *frame, - const char *seat_name, - void *user_data){ -} - -static void -libdecorevent__frame_bounds(struct libdecor_frame *frame, - int width, - int height, - void *user_data){ -} - static void shm_format(void *user_data, struct wl_shm *wl_shm, uint32_t format){ if (format == WL_SHM_FORMAT_ARGB8888){ @@ -335,6 +285,10 @@ int main(){ if (ctx.wl_registry != 0){ wl_registry_add_listener(ctx.wl_registry, &wl_registry_listener, 0); + ctx.wl_callback = wl_display_sync(ctx.wl_display); + wl_callback_add_listener(ctx.wl_callback, &init_wl_display_callback_listener, 0); + + wl_display_flush(ctx.wl_display); wl_display_dispatch(ctx.wl_display); wl_display_roundtrip(ctx.wl_display); @@ -349,18 +303,6 @@ int main(){ } } - if (ctx.wl_compositor != 0 && - ctx.wl_subcompositor != 0 && - ctx.wl_shm != 0){ - ctx.wl_callback = wl_display_sync(ctx.wl_display); - wl_callback_add_listener(ctx.wl_callback, - &init_wl_display_callback_listener, - 0); - wl_display_roundtrip(ctx.wl_display); - - wl_display_flush(ctx.wl_display); - } - int opengl_load_success = 0; if (ctx.wl_compositor != 0 && ctx.wl_subcompositor != 0 && @@ -851,7 +793,24 @@ xdg_surface_configure(void *user_data, configuration->serial = serial; - libdecorevent__frame_configure(frame, configuration, frame_priv->user_data); + { + int w = ctx.w; + int h = ctx.h; + if (libdecor_configuration_get_content_size(configuration, frame, &w, &h)){ + ctx.w = w; + ctx.h = h; + } + if (!ctx.configured){ + ctx.configured = 1; + struct libdecor_state *state = libdecor_state_new(w, h); + libdecor_frame_commit(frame, state, configuration); + libdecor_state_free(state); + } + else{ + ctx.has_cached_config = 1; + ctx.cached_config = *configuration; + } + } libdecor_configuration_free(configuration); } @@ -945,13 +904,8 @@ xdg_toplevel_configure(void *user_data, } static void -xdg_toplevel_close(void *user_data, - struct xdg_toplevel *xdg_toplevel) -{ - struct libdecor_frame *frame = user_data; - struct libdecor_frame_private *frame_priv = frame->priv; - - libdecorevent__frame_close(frame, frame_priv->user_data); +xdg_toplevel_close(void *user_data, struct xdg_toplevel *xdg_toplevel){ + ctx.close_signal = 1; } #ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION @@ -971,7 +925,7 @@ xdg_toplevel_configure_bounds(void *user_data, width -= left + right; height -= top + bottom; - libdecorevent__frame_bounds(frame, width, height, frame_priv->user_data); + // } #endif @@ -1379,8 +1333,7 @@ libdecor_frame_dismiss_popup(struct libdecor_frame *frame, const char *seat_name) { struct libdecor_frame_private *frame_priv = frame->priv; - - libdecorevent__frame_dismiss_popup(frame, seat_name, frame_priv->user_data); + // } void @@ -1591,12 +1544,7 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame, struct libdecor_frame_private *frame_priv = frame->priv; if (!valid_limits(frame_priv)) { - libdecor_notify_plugin_error(LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, - "minimum size (%i,%i) must be smaller than maximum size (%i,%i)", - frame_priv->state.content_limits.min_width, - frame_priv->state.content_limits.min_height, - frame_priv->state.content_limits.max_width, - frame_priv->state.content_limits.max_height); + ctx.has_error = true; } /* If the frame is configured as non-resizable before the first @@ -1665,8 +1613,7 @@ void libdecor_frame_toplevel_commit(struct libdecor_frame *frame) { struct libdecor_frame_private *frame_priv = frame->priv; - - libdecorevent__frame_commit(frame, frame_priv->user_data); + wl_surface_commit(ctx.wl_surface); } void @@ -1791,14 +1738,6 @@ const struct xdg_wm_base_listener xdg_wm_base_listener = { xdg_wm_base_ping, }; -static void -notify_error(enum libdecor_error error, const char *message) -{ - ctx.has_error = true; - libdecorevent__error(error, message); - libdecor_plugin_gtk_destroy(); -} - static void finish_init(void){ struct libdecor_frame *frame; @@ -1821,30 +1760,6 @@ libdecor_notify_plugin_ready(void){ } } -void -libdecor_notify_plugin_error(enum libdecor_error error, - const char *__restrict fmt, - ...) -{ - char *msg = NULL; - int nbytes = 0; - va_list argp; - - if (ctx.has_error) - return; - - va_start(argp, fmt); - nbytes = vasprintf(&msg, fmt, argp); - va_end(argp); - - if (nbytes > 0){ - notify_error(error, msg); - } - - if (msg) - free(msg); -} - void cleanup(void){ libdecor_plugin_gtk_destroy(); @@ -2550,8 +2465,7 @@ create_shm_buffer(int width, fd = libdecor_os_create_anonymous_file(size); if (fd < 0) { - fprintf(stderr, "creating a buffer file for %d B failed: %s\n", - size, strerror(errno)); + fprintf(stderr, "creating a buffer file for %d B failed: %s\n", size, strerror(errno)); return NULL; } @@ -3589,8 +3503,7 @@ synthesize_pointer_enter(struct seat *seat) } static void -synthesize_pointer_leave(struct seat *seat) -{ +synthesize_pointer_leave(struct seat *seat){ struct wl_surface *surface; struct libdecor_frame_gtk *frame_gtk; @@ -3612,9 +3525,7 @@ synthesize_pointer_leave(struct seat *seat) } static void -libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, - const char *seat_name) -{ +libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, const char *seat_name){ struct libdecor_frame_gtk *frame_gtk = (struct libdecor_frame_gtk *) frame; struct seat *seat; @@ -3622,8 +3533,7 @@ libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, wl_list_for_each(seat, &ctx.seat_list, link) { if (STREQL(seat->name, seat_name)) { if (seat->grabbed) { - fprintf(stderr, "libdecor-WARNING: Application " - "tried to grab seat twice\n"); + fprintf(stderr, "libdecor-WARNING: Application tried to grab seat twice\n"); } synthesize_pointer_leave(seat); seat->grabbed = true; @@ -3631,8 +3541,7 @@ libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, } } - fprintf(stderr, - "libdecor-WARNING: Application tried to grab unknown seat\n"); + fprintf(stderr, "libdecor-WARNING: Application tried to grab unknown seat\n"); } static void diff --git a/digesting_libdecor.h b/digesting_libdecor.h index 6544fdd..17b8575 100644 --- a/digesting_libdecor.h +++ b/digesting_libdecor.h @@ -474,10 +474,6 @@ void libdecor_frame_toplevel_commit(struct libdecor_frame *frame); void libdecor_notify_plugin_ready(void); -void libdecor_notify_plugin_error(enum libdecor_error error, - const char *__restrict fmt, - ...); - int libdecor_state_get_content_width(struct libdecor_state *state); int libdecor_state_get_content_height(struct libdecor_state *state); @@ -502,7 +498,6 @@ int libdecor_os_create_anonymous_file(off_t size); // #include "libdecor.c" -static void notify_error(enum libdecor_error error, const char *message); static void finish_init(void); //#include "plugins/gtk/libdecor-gtk.c"