[digesting_libdecor] eliminate my implementation functions for libdecor's event callbacks
parent
405b88268c
commit
eb54b56ee6
|
|
@ -119,8 +119,7 @@ wlevent__wl_registry_global(void *data, struct wl_registry *wl_registry,
|
||||||
else if (strcmp(interface, "wl_seat") == 0){
|
else if (strcmp(interface, "wl_seat") == 0){
|
||||||
struct seat *seat;
|
struct seat *seat;
|
||||||
if (version < 3){
|
if (version < 3){
|
||||||
libdecor_notify_plugin_error(LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
ctx.has_error = true;
|
||||||
"%s version 3 required but only version %i is available\n", interface, version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
seat = calloc(1, sizeof *seat);
|
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){
|
else if (strcmp(interface, "wl_output") == 0){
|
||||||
struct output *output;
|
struct output *output;
|
||||||
if (version < 2){
|
if (version < 2){
|
||||||
libdecor_notify_plugin_error(LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE,
|
ctx.has_error = true;
|
||||||
"%s version 2 required but only version %i is available\n", interface, version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output = calloc(1, sizeof *output);
|
output = calloc(1, sizeof *output);
|
||||||
|
|
@ -164,54 +162,6 @@ const struct wl_registry_listener wl_registry_listener = {
|
||||||
wlevent__wl_registry_global_remove,
|
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
|
static void
|
||||||
shm_format(void *user_data, struct wl_shm *wl_shm, uint32_t format){
|
shm_format(void *user_data, struct wl_shm *wl_shm, uint32_t format){
|
||||||
if (format == WL_SHM_FORMAT_ARGB8888){
|
if (format == WL_SHM_FORMAT_ARGB8888){
|
||||||
|
|
@ -335,6 +285,10 @@ int main(){
|
||||||
|
|
||||||
if (ctx.wl_registry != 0){
|
if (ctx.wl_registry != 0){
|
||||||
wl_registry_add_listener(ctx.wl_registry, &wl_registry_listener, 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_dispatch(ctx.wl_display);
|
||||||
wl_display_roundtrip(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;
|
int opengl_load_success = 0;
|
||||||
if (ctx.wl_compositor != 0 &&
|
if (ctx.wl_compositor != 0 &&
|
||||||
ctx.wl_subcompositor != 0 &&
|
ctx.wl_subcompositor != 0 &&
|
||||||
|
|
@ -851,7 +793,24 @@ xdg_surface_configure(void *user_data,
|
||||||
|
|
||||||
configuration->serial = serial;
|
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);
|
libdecor_configuration_free(configuration);
|
||||||
}
|
}
|
||||||
|
|
@ -945,13 +904,8 @@ xdg_toplevel_configure(void *user_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_toplevel_close(void *user_data,
|
xdg_toplevel_close(void *user_data, struct xdg_toplevel *xdg_toplevel){
|
||||||
struct xdg_toplevel *xdg_toplevel)
|
ctx.close_signal = 1;
|
||||||
{
|
|
||||||
struct libdecor_frame *frame = user_data;
|
|
||||||
struct libdecor_frame_private *frame_priv = frame->priv;
|
|
||||||
|
|
||||||
libdecorevent__frame_close(frame, frame_priv->user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
|
#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
|
||||||
|
|
@ -971,7 +925,7 @@ xdg_toplevel_configure_bounds(void *user_data,
|
||||||
|
|
||||||
width -= left + right;
|
width -= left + right;
|
||||||
height -= top + bottom;
|
height -= top + bottom;
|
||||||
libdecorevent__frame_bounds(frame, width, height, frame_priv->user_data);
|
//
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1379,8 +1333,7 @@ libdecor_frame_dismiss_popup(struct libdecor_frame *frame,
|
||||||
const char *seat_name)
|
const char *seat_name)
|
||||||
{
|
{
|
||||||
struct libdecor_frame_private *frame_priv = frame->priv;
|
struct libdecor_frame_private *frame_priv = frame->priv;
|
||||||
|
//
|
||||||
libdecorevent__frame_dismiss_popup(frame, seat_name, frame_priv->user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1591,12 +1544,7 @@ libdecor_frame_apply_limits(struct libdecor_frame *frame,
|
||||||
struct libdecor_frame_private *frame_priv = frame->priv;
|
struct libdecor_frame_private *frame_priv = frame->priv;
|
||||||
|
|
||||||
if (!valid_limits(frame_priv)) {
|
if (!valid_limits(frame_priv)) {
|
||||||
libdecor_notify_plugin_error(LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION,
|
ctx.has_error = true;
|
||||||
"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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the frame is configured as non-resizable before the first
|
/* If the frame is configured as non-resizable before the first
|
||||||
|
|
@ -1665,8 +1613,7 @@ void
|
||||||
libdecor_frame_toplevel_commit(struct libdecor_frame *frame)
|
libdecor_frame_toplevel_commit(struct libdecor_frame *frame)
|
||||||
{
|
{
|
||||||
struct libdecor_frame_private *frame_priv = frame->priv;
|
struct libdecor_frame_private *frame_priv = frame->priv;
|
||||||
|
wl_surface_commit(ctx.wl_surface);
|
||||||
libdecorevent__frame_commit(frame, frame_priv->user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1791,14 +1738,6 @@ const struct xdg_wm_base_listener xdg_wm_base_listener = {
|
||||||
xdg_wm_base_ping,
|
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
|
static void
|
||||||
finish_init(void){
|
finish_init(void){
|
||||||
struct libdecor_frame *frame;
|
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
|
void
|
||||||
cleanup(void){
|
cleanup(void){
|
||||||
libdecor_plugin_gtk_destroy();
|
libdecor_plugin_gtk_destroy();
|
||||||
|
|
@ -2550,8 +2465,7 @@ create_shm_buffer(int width,
|
||||||
|
|
||||||
fd = libdecor_os_create_anonymous_file(size);
|
fd = libdecor_os_create_anonymous_file(size);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "creating a buffer file for %d B failed: %s\n",
|
fprintf(stderr, "creating a buffer file for %d B failed: %s\n", size, strerror(errno));
|
||||||
size, strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3589,8 +3503,7 @@ synthesize_pointer_enter(struct seat *seat)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
synthesize_pointer_leave(struct seat *seat)
|
synthesize_pointer_leave(struct seat *seat){
|
||||||
{
|
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct libdecor_frame_gtk *frame_gtk;
|
struct libdecor_frame_gtk *frame_gtk;
|
||||||
|
|
||||||
|
|
@ -3612,9 +3525,7 @@ synthesize_pointer_leave(struct seat *seat)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame,
|
libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, const char *seat_name){
|
||||||
const char *seat_name)
|
|
||||||
{
|
|
||||||
struct libdecor_frame_gtk *frame_gtk =
|
struct libdecor_frame_gtk *frame_gtk =
|
||||||
(struct libdecor_frame_gtk *) frame;
|
(struct libdecor_frame_gtk *) frame;
|
||||||
struct seat *seat;
|
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) {
|
wl_list_for_each(seat, &ctx.seat_list, link) {
|
||||||
if (STREQL(seat->name, seat_name)) {
|
if (STREQL(seat->name, seat_name)) {
|
||||||
if (seat->grabbed) {
|
if (seat->grabbed) {
|
||||||
fprintf(stderr, "libdecor-WARNING: Application "
|
fprintf(stderr, "libdecor-WARNING: Application tried to grab seat twice\n");
|
||||||
"tried to grab seat twice\n");
|
|
||||||
}
|
}
|
||||||
synthesize_pointer_leave(seat);
|
synthesize_pointer_leave(seat);
|
||||||
seat->grabbed = true;
|
seat->grabbed = true;
|
||||||
|
|
@ -3631,8 +3541,7 @@ libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr, "libdecor-WARNING: Application tried to grab unknown seat\n");
|
||||||
"libdecor-WARNING: Application tried to grab unknown seat\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -474,10 +474,6 @@ void libdecor_frame_toplevel_commit(struct libdecor_frame *frame);
|
||||||
|
|
||||||
void libdecor_notify_plugin_ready(void);
|
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_width(struct libdecor_state *state);
|
||||||
|
|
||||||
int libdecor_state_get_content_height(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"
|
// #include "libdecor.c"
|
||||||
|
|
||||||
static void notify_error(enum libdecor_error error, const char *message);
|
|
||||||
static void finish_init(void);
|
static void finish_init(void);
|
||||||
|
|
||||||
//#include "plugins/gtk/libdecor-gtk.c"
|
//#include "plugins/gtk/libdecor-gtk.c"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue