mirror of
https://github.com/swaywm/sway.git
synced 2025-01-12 23:36:42 +01:00
Compare commits
5 commits
68e20b2aeb
...
b5d63bbb48
Author | SHA1 | Date | |
---|---|---|---|
|
b5d63bbb48 | ||
|
801bc76ce3 | ||
|
49464d233e | ||
|
131026b190 | ||
|
2535a2e9f9 |
4 changed files with 52 additions and 45 deletions
|
@ -90,6 +90,7 @@ struct swaynag {
|
||||||
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
|
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
|
|
||||||
|
bool needs_redraw;
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
int32_t scale;
|
int32_t scale;
|
||||||
|
|
|
@ -106,9 +106,9 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1).
|
||||||
*border* none|normal|csd|pixel [<n>]
|
*border* none|normal|csd|pixel [<n>]
|
||||||
Set border style for focused window. _normal_ includes a border of
|
Set border style for focused window. _normal_ includes a border of
|
||||||
thickness _n_ and a title bar. _pixel_ is a border without title bar _n_
|
thickness _n_ and a title bar. _pixel_ is a border without title bar _n_
|
||||||
pixels thick. Default is _normal_ with border thickness 2. _csd_ is short
|
pixels thick. The title bar always shows in stacking or tabbed layouts.
|
||||||
for client-side-decorations, which allows the client to draw its own
|
_csd_ is short for client-side-decorations, which allows the client to draw
|
||||||
decorations.
|
its own decorations. Default is _normal_ with border thickness 2.
|
||||||
|
|
||||||
*border* toggle
|
*border* toggle
|
||||||
Cycles through the available border styles.
|
Cycles through the available border styles.
|
||||||
|
|
|
@ -235,12 +235,10 @@ static uint32_t render_to_cairo(cairo_t *cairo, struct swaynag *swaynag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int border = swaynag->type->bar_border_thickness;
|
int border = swaynag->type->bar_border_thickness;
|
||||||
if (max_height > swaynag->height) {
|
|
||||||
max_height += border;
|
max_height += border;
|
||||||
}
|
|
||||||
cairo_set_source_u32(cairo, swaynag->type->border_bottom);
|
cairo_set_source_u32(cairo, swaynag->type->border_bottom);
|
||||||
cairo_rectangle(cairo, 0,
|
cairo_rectangle(cairo, 0,
|
||||||
swaynag->height - border,
|
max_height - border,
|
||||||
swaynag->width,
|
swaynag->width,
|
||||||
border);
|
border);
|
||||||
cairo_fill(cairo);
|
cairo_fill(cairo);
|
||||||
|
@ -252,6 +250,7 @@ void render_frame(struct swaynag *swaynag) {
|
||||||
if (!swaynag->run_display) {
|
if (!swaynag->run_display) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
swaynag->needs_redraw = false;
|
||||||
|
|
||||||
cairo_surface_t *recorder = cairo_recording_surface_create(
|
cairo_surface_t *recorder = cairo_recording_surface_create(
|
||||||
CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||||
|
@ -262,17 +261,24 @@ void render_frame(struct swaynag *swaynag) {
|
||||||
cairo_paint(cairo);
|
cairo_paint(cairo);
|
||||||
cairo_restore(cairo);
|
cairo_restore(cairo);
|
||||||
uint32_t height = render_to_cairo(cairo, swaynag);
|
uint32_t height = render_to_cairo(cairo, swaynag);
|
||||||
if (height != swaynag->height) {
|
if (swaynag->height == 0) {
|
||||||
|
// for first commit, set required size but do not attach a buffer
|
||||||
zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
|
zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
|
||||||
zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
|
zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
|
||||||
height);
|
height);
|
||||||
wl_surface_commit(swaynag->surface);
|
wl_surface_commit(swaynag->surface);
|
||||||
wl_display_roundtrip(swaynag->display);
|
goto cleanup;
|
||||||
} else {
|
}
|
||||||
|
if (height != swaynag->height) {
|
||||||
|
zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height);
|
||||||
|
zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface,
|
||||||
|
height);
|
||||||
|
}
|
||||||
|
|
||||||
swaynag->current_buffer = get_next_buffer(swaynag->shm,
|
swaynag->current_buffer = get_next_buffer(swaynag->shm,
|
||||||
swaynag->buffers,
|
swaynag->buffers,
|
||||||
swaynag->width * swaynag->scale,
|
swaynag->width * swaynag->scale,
|
||||||
swaynag->height * swaynag->scale);
|
height * swaynag->scale);
|
||||||
if (!swaynag->current_buffer) {
|
if (!swaynag->current_buffer) {
|
||||||
sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame.");
|
sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -292,8 +298,6 @@ void render_frame(struct swaynag *swaynag) {
|
||||||
wl_surface_damage(swaynag->surface, 0, 0,
|
wl_surface_damage(swaynag->surface, 0, 0,
|
||||||
swaynag->width, swaynag->height);
|
swaynag->width, swaynag->height);
|
||||||
wl_surface_commit(swaynag->surface);
|
wl_surface_commit(swaynag->surface);
|
||||||
wl_display_roundtrip(swaynag->display);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
cairo_surface_destroy(recorder);
|
cairo_surface_destroy(recorder);
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void swaynag_button_execute(struct swaynag *swaynag,
|
||||||
swaynag->run_display = false;
|
swaynag->run_display = false;
|
||||||
} else if (button->type == SWAYNAG_ACTION_EXPAND) {
|
} else if (button->type == SWAYNAG_ACTION_EXPAND) {
|
||||||
swaynag->details.visible = !swaynag->details.visible;
|
swaynag->details.visible = !swaynag->details.visible;
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
} else {
|
} else {
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
|
@ -98,7 +98,7 @@ static void layer_surface_configure(void *data,
|
||||||
swaynag->width = width;
|
swaynag->width = width;
|
||||||
swaynag->height = height;
|
swaynag->height = height;
|
||||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void layer_surface_closed(void *data,
|
static void layer_surface_closed(void *data,
|
||||||
|
@ -122,7 +122,7 @@ static void surface_enter(void *data, struct wl_surface *surface,
|
||||||
swaynag_output->name);
|
swaynag_output->name);
|
||||||
swaynag->output = swaynag_output;
|
swaynag->output = swaynag_output;
|
||||||
swaynag->scale = swaynag->output->scale;
|
swaynag->scale = swaynag->output->scale;
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -244,7 +244,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
&& y < button_up.y + button_up.height
|
&& y < button_up.y + button_up.height
|
||||||
&& swaynag->details.offset > 0) {
|
&& swaynag->details.offset > 0) {
|
||||||
swaynag->details.offset--;
|
swaynag->details.offset--;
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ static void wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
&& y < button_down.y + button_down.height
|
&& y < button_down.y + button_down.height
|
||||||
&& swaynag->details.offset < bot) {
|
&& swaynag->details.offset < bot) {
|
||||||
swaynag->details.offset++;
|
swaynag->details.offset++;
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ static void wl_pointer_axis(void *data, struct wl_pointer *wl_pointer,
|
||||||
swaynag->details.offset++;
|
swaynag->details.offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_frame(swaynag);
|
swaynag->needs_redraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_pointer_listener pointer_listener = {
|
static const struct wl_pointer_listener pointer_listener = {
|
||||||
|
@ -327,7 +327,7 @@ static void output_scale(void *data, struct wl_output *output,
|
||||||
if (!swaynag_output->swaynag->cursor_shape_manager) {
|
if (!swaynag_output->swaynag->cursor_shape_manager) {
|
||||||
update_all_cursors(swaynag_output->swaynag);
|
update_all_cursors(swaynag_output->swaynag);
|
||||||
}
|
}
|
||||||
render_frame(swaynag_output->swaynag);
|
swaynag_output->swaynag->needs_redraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,9 +503,11 @@ void swaynag_setup(struct swaynag *swaynag) {
|
||||||
void swaynag_run(struct swaynag *swaynag) {
|
void swaynag_run(struct swaynag *swaynag) {
|
||||||
swaynag->run_display = true;
|
swaynag->run_display = true;
|
||||||
render_frame(swaynag);
|
render_frame(swaynag);
|
||||||
while (swaynag->run_display
|
while (wl_display_dispatch(swaynag->display) != -1
|
||||||
&& wl_display_dispatch(swaynag->display) != -1) {
|
&& swaynag->run_display) {
|
||||||
// This is intentionally left blank
|
if (swaynag->needs_redraw) {
|
||||||
|
render_frame(swaynag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue