mirror of
https://github.com/swaywm/sway.git
synced 2026-04-18 06:46:56 -04:00
Merge 0c8737d1ef into f12023b1a2
This commit is contained in:
commit
6213ec0760
5 changed files with 59 additions and 33 deletions
|
|
@ -38,8 +38,8 @@ struct sway_view_impl {
|
|||
const char *(*get_string_prop)(struct sway_view *view,
|
||||
enum sway_view_prop prop);
|
||||
uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
|
||||
uint32_t (*configure)(struct sway_view *view, double lx, double ly,
|
||||
int width, int height);
|
||||
bool (*configure)(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height);
|
||||
void (*set_activated)(struct sway_view *view, bool activated);
|
||||
void (*set_tiled)(struct sway_view *view, bool tiled);
|
||||
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
||||
|
|
@ -252,8 +252,8 @@ const char *view_get_shell(struct sway_view *view);
|
|||
void view_get_constraints(struct sway_view *view, double *min_width,
|
||||
double *max_width, double *min_height, double *max_height);
|
||||
|
||||
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||
int height);
|
||||
bool view_configure(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height);
|
||||
|
||||
bool view_inhibit_idle(struct sway_view *view);
|
||||
|
||||
|
|
|
|||
|
|
@ -405,24 +405,28 @@ static void transaction_commit(struct sway_transaction *transaction) {
|
|||
bool hidden = node_is_view(node) && !node->destroying &&
|
||||
!view_is_visible(node->sway_container->view);
|
||||
if (should_configure(node, instruction)) {
|
||||
instruction->serial = view_configure(node->sway_container->view,
|
||||
bool successful = view_configure(node->sway_container->view,
|
||||
&instruction->serial,
|
||||
instruction->container_state.content_x,
|
||||
instruction->container_state.content_y,
|
||||
instruction->container_state.content_width,
|
||||
instruction->container_state.content_height);
|
||||
if (!hidden) {
|
||||
instruction->waiting = true;
|
||||
++transaction->num_waiting;
|
||||
}
|
||||
|
||||
// From here on we are rendering a saved buffer of the view, which
|
||||
// means we can send a frame done event to make the client redraw it
|
||||
// as soon as possible. Additionally, this is required if a view is
|
||||
// mapping and its default geometry doesn't intersect an output.
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
wlr_surface_send_frame_done(
|
||||
node->sway_container->view->surface, &now);
|
||||
if (successful) {
|
||||
if (!hidden) {
|
||||
instruction->waiting = true;
|
||||
++transaction->num_waiting;
|
||||
}
|
||||
|
||||
// From here on we are rendering a saved buffer of the view, which
|
||||
// means we can send a frame done event to make the client redraw it
|
||||
// as soon as possible. Additionally, this is required if a view is
|
||||
// mapping and its default geometry doesn't intersect an output.
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
wlr_surface_send_frame_done(
|
||||
node->sway_container->view->surface, &now);
|
||||
}
|
||||
}
|
||||
if (!hidden && node_is_view(node) &&
|
||||
wl_list_empty(&node->sway_container->view->saved_buffers)) {
|
||||
|
|
|
|||
|
|
@ -154,15 +154,23 @@ static const char *get_string_prop(struct sway_view *view,
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t configure(struct sway_view *view, double lx, double ly,
|
||||
int width, int height) {
|
||||
static bool configure(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height) {
|
||||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
xdg_shell_view_from_view(view);
|
||||
if (xdg_shell_view == NULL) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
return wlr_xdg_toplevel_set_size(view->wlr_xdg_toplevel,
|
||||
width, height);
|
||||
|
||||
// avoid same size configures as clients may not ack & commit them
|
||||
struct wlr_xdg_toplevel *top = view->wlr_xdg_toplevel;
|
||||
if ((int) top->pending.width == width &&
|
||||
(int) top->pending.height == height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*serial = wlr_xdg_toplevel_set_size(top, width, height);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_activated(struct sway_view *view, bool activated) {
|
||||
|
|
|
|||
|
|
@ -268,18 +268,18 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) {
|
|||
}
|
||||
}
|
||||
|
||||
static uint32_t configure(struct sway_view *view, double lx, double ly, int width,
|
||||
int height) {
|
||||
static bool configure(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height) {
|
||||
struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
||||
if (xwayland_view == NULL) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
|
||||
|
||||
wlr_xwayland_surface_configure(xsurface, lx, ly, width, height);
|
||||
|
||||
// xwayland doesn't give us a serial for the configure
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void set_activated(struct sway_view *view, bool activated) {
|
||||
|
|
@ -567,13 +567,17 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
|
|||
view->natural_height = ev->height;
|
||||
container_floating_resize_and_center(view->container);
|
||||
|
||||
configure(view, view->container->pending.content_x,
|
||||
bool successful = configure(view, NULL,
|
||||
view->container->pending.content_x,
|
||||
view->container->pending.content_y,
|
||||
view->container->pending.content_width,
|
||||
view->container->pending.content_height);
|
||||
node_set_dirty(&view->container->node);
|
||||
|
||||
if (successful) {
|
||||
node_set_dirty(&view->container->node);
|
||||
}
|
||||
} else {
|
||||
configure(view, view->container->current.content_x,
|
||||
configure(view, NULL, view->container->current.content_x,
|
||||
view->container->current.content_y,
|
||||
view->container->current.content_width,
|
||||
view->container->current.content_height);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <math.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
|
|
@ -168,12 +169,21 @@ void view_get_constraints(struct sway_view *view, double *min_width,
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||
int height) {
|
||||
bool view_configure(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height) {
|
||||
// Many clients don't play nicely if you try to reconfigure them out of
|
||||
// their specified constraints. Clamp the values.
|
||||
double minw, maxw, minh, maxh;
|
||||
view_get_constraints(view, &minw, &maxw, &minh, &maxh);
|
||||
|
||||
width = fmax(fmin(width, maxw), minw);
|
||||
height = fmax(fmin(height, maxh), minh);
|
||||
|
||||
if (view->impl->configure) {
|
||||
return view->impl->configure(view, lx, ly, width, height);
|
||||
return view->impl->configure(view, serial, lx, ly, width, height);
|
||||
}
|
||||
return 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool view_inhibit_idle(struct sway_view *view) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue