diff options
author | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2021-11-14 04:14:25 +0100 |
---|---|---|
committer | Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> | 2021-11-14 04:14:44 +0100 |
commit | d933ed4dd56f38285f4aef61b487307a497574c5 (patch) | |
tree | 9f058036fe6ef0aa4fc99d5f2eb84d0523ec1431 /src/surface.c | |
parent | fa3d1b5dfe4f93953c300595e8fd81abd76670ee (diff) | |
download | wlclock-d933ed4dd56f38285f4aef61b487307a497574c5.tar.gz wlclock-d933ed4dd56f38285f4aef61b487307a497574c5.tar.bz2 |
Use global context
Diffstat (limited to 'src/surface.c')
-rw-r--r-- | src/surface.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/src/surface.c b/src/surface.c index 106460a..f736504 100644 --- a/src/surface.c +++ b/src/surface.c @@ -26,8 +26,7 @@ static void layer_surface_handle_configure (void *data, uint32_t w, uint32_t h) { struct Wlclock_surface *surface = (struct Wlclock_surface *)data; - struct Wlclock *clock = surface->output->clock; - clocklog(clock, 1, "[surface] Layer surface configure request: global_name=%d w=%d h=%d serial=%d\n", + clocklog(1, "[surface] Layer surface configure request: global_name=%d w=%d h=%d serial=%d\n", surface->output->global_name, w, h, serial); zwlr_layer_surface_v1_ack_configure(layer_surface, serial); if ( (w != (uint32_t)surface->dimensions.w || h != (uint32_t)surface->dimensions.h) @@ -37,8 +36,8 @@ static void layer_surface_handle_configure (void *data, * while also keeping the center square and not changing the * border sizes. */ - int32_t size_a = (int32_t)w - clock->border_left - clock->border_right; - int32_t size_b = (int32_t)h - clock->border_top - clock->border_bottom; + int32_t size_a = (int32_t)w - context.border_left - context.border_right; + int32_t size_b = (int32_t)h - context.border_top - context.border_bottom; surface->dimensions.center_size = size_a < size_b ? size_a : size_b; if ( surface->dimensions.center_size < 10 ) surface->dimensions.center_size = 10; @@ -51,8 +50,7 @@ static void layer_surface_handle_configure (void *data, static void layer_surface_handle_closed (void *data, struct zwlr_layer_surface_v1 *layer_surface) { struct Wlclock_surface *surface = (struct Wlclock_surface *)data; - clocklog(surface->output->clock, 1, - "[surface] Layer surface has been closed: global_name=%d\n", + clocklog(1, "[surface] Layer surface has been closed: global_name=%d\n", surface->output->global_name); destroy_surface(surface); } @@ -64,8 +62,7 @@ const struct zwlr_layer_surface_v1_listener layer_surface_listener = { static int32_t get_exclusive_zone (struct Wlclock_surface *surface) { - struct Wlclock *clock = surface->output->clock; - if ( clock->exclusive_zone == 1 ) switch (clock->anchor) + if ( context.exclusive_zone == 1 ) switch (context.anchor) { case ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM: case ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP: @@ -79,36 +76,35 @@ static int32_t get_exclusive_zone (struct Wlclock_surface *surface) return 0; } else - return surface->output->clock->exclusive_zone; + return context.exclusive_zone; } static void configure_subsurface (struct Wlclock_surface *surface) { - clocklog(surface->output->clock, 1, "[surface] Configuring sub surface: global_name=%d\n", + clocklog(1, "[surface] Configuring sub surface: global_name=%d\n", surface->output->global_name); wl_subsurface_set_position(surface->subsurface, surface->dimensions.center_x, surface->dimensions.center_y); - struct wl_region *region = wl_compositor_create_region(surface->output->clock->compositor); + struct wl_region *region = wl_compositor_create_region(context.compositor); wl_surface_set_input_region(surface->hands_surface, region); wl_region_destroy(region); } static void configure_layer_surface (struct Wlclock_surface *surface) { - struct Wlclock *clock = surface->output->clock; - clocklog(clock, 1, "[surface] Configuring layer surface: global_name=%d\n", + clocklog(1, "[surface] Configuring layer surface: global_name=%d\n", surface->output->global_name); zwlr_layer_surface_v1_set_size(surface->layer_surface, surface->dimensions.w, surface->dimensions.h); - zwlr_layer_surface_v1_set_anchor(surface->layer_surface, clock->anchor); + zwlr_layer_surface_v1_set_anchor(surface->layer_surface, context.anchor); zwlr_layer_surface_v1_set_margin(surface->layer_surface, - clock->margin_top, clock->margin_right, - clock->margin_bottom, clock->margin_left); + context.margin_top, context.margin_right, + context.margin_bottom, context.margin_left); zwlr_layer_surface_v1_set_exclusive_zone(surface->layer_surface, get_exclusive_zone(surface)); - if (! clock->input) + if (! context.input) { - struct wl_region *region = wl_compositor_create_region(clock->compositor); + struct wl_region *region = wl_compositor_create_region(context.compositor); wl_surface_set_input_region(surface->background_surface, region); wl_region_destroy(region); } @@ -116,50 +112,49 @@ static void configure_layer_surface (struct Wlclock_surface *surface) bool create_surface (struct Wlclock_output *output) { - struct Wlclock *clock = output->clock; - clocklog(clock, 1, "[surface] Creating surface: global_name=%d\n", output->global_name); + clocklog(1, "[surface] Creating surface: global_name=%d\n", output->global_name); struct Wlclock_surface *surface = calloc(1, sizeof(struct Wlclock_surface)); if ( surface == NULL ) { - clocklog(NULL, 0, "ERROR: Could not allocate.\n"); + clocklog(0, "ERROR: Could not allocate.\n"); return false; } output->surface = surface; - surface->dimensions = clock->dimensions; + surface->dimensions = context.dimensions; surface->output = output; surface->background_surface = NULL; surface->hands_surface = NULL; surface->layer_surface = NULL; surface->configured = false; - if ( NULL == (surface->background_surface = wl_compositor_create_surface(clock->compositor)) ) + if ( NULL == (surface->background_surface = wl_compositor_create_surface(context.compositor)) ) { - clocklog(NULL, 0, "ERROR: Compositor did not create wl_surface (background).\n"); + clocklog(0, "ERROR: Compositor did not create wl_surface (background).\n"); return false; } if ( NULL == (surface->layer_surface = zwlr_layer_shell_v1_get_layer_surface( - clock->layer_shell, surface->background_surface, - output->wl_output, clock->layer, - clock->namespace)) ) + context.layer_shell, surface->background_surface, + output->wl_output, context.layer, + context.namespace)) ) { - clocklog(NULL, 0, "ERROR: Compositor did not create layer_surface.\n"); + clocklog(0, "ERROR: Compositor did not create layer_surface.\n"); return false; } zwlr_layer_surface_v1_add_listener(surface->layer_surface, &layer_surface_listener, surface); - if ( NULL == (surface->hands_surface = wl_compositor_create_surface(clock->compositor)) ) + if ( NULL == (surface->hands_surface = wl_compositor_create_surface(context.compositor)) ) { - clocklog(NULL, 0, "ERROR: Compositor did not create wl_surface (hands).\n"); + clocklog(0, "ERROR: Compositor did not create wl_surface (hands).\n"); return false; } if ( NULL == (surface->subsurface = wl_subcompositor_get_subsurface( - clock->subcompositor, surface->hands_surface, + context.subcompositor, surface->hands_surface, surface->background_surface)) ) { - clocklog(NULL, 0, "ERROR: Compositor did not create wl_subsurface.\n"); + clocklog(0, "ERROR: Compositor did not create wl_subsurface.\n"); return false; } @@ -204,11 +199,11 @@ void update_surface (struct Wlclock_surface *surface) wl_surface_commit(surface->background_surface); } -void update_all_hands (struct Wlclock *clock) +void update_all_hands (void) { - clocklog(clock, 1, "[surface] Updating all hands.\n"); + clocklog(1, "[surface] Updating all hands.\n"); struct Wlclock_output *op, *tmp; - wl_list_for_each_safe(op, tmp, &clock->outputs, link) + wl_list_for_each_safe(op, tmp, &context.outputs, link) if ( op->surface != NULL ) { render_hands_frame(op->surface); |