mirror of
https://github.com/swaywm/sway.git
synced 2026-04-23 06:46:27 -04:00
merge sway master
This commit is contained in:
parent
c37aba2736
commit
7460d9f565
63 changed files with 642 additions and 461 deletions
|
|
@ -6,10 +6,11 @@ void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
|
|||
bool whole) {
|
||||
for (int i = 0; i < root->outputs->length; ++i) {
|
||||
struct sway_output *output = root->outputs->items[i];
|
||||
struct wlr_box *output_box = wlr_output_layout_get_box(
|
||||
root->output_layout, output->wlr_output);
|
||||
output_damage_surface(output, lx - output_box->x,
|
||||
ly - output_box->y, surface, whole);
|
||||
struct wlr_box output_box;
|
||||
wlr_output_layout_get_box(root->output_layout,
|
||||
output->wlr_output, &output_box);
|
||||
output_damage_surface(output, lx - output_box.x,
|
||||
ly - output_box.y, surface, whole);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#include "log.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/input/cursor.h"
|
||||
|
|
@ -270,10 +271,6 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_resource_get_client(sway_layer->layer_surface->resource);
|
||||
bool set_focus = seat->exclusive_client == client;
|
||||
|
||||
wl_list_remove(&sway_layer->output_destroy.link);
|
||||
wl_list_remove(&sway_layer->link);
|
||||
wl_list_init(&sway_layer->link);
|
||||
|
||||
if (set_focus) {
|
||||
struct sway_layer_surface *layer =
|
||||
find_mapped_layer_by_client(client, sway_layer->layer_surface->output);
|
||||
|
|
@ -282,7 +279,6 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
sway_layer->layer_surface->output = NULL;
|
||||
wlr_layer_surface_v1_destroy(sway_layer->layer_surface);
|
||||
}
|
||||
|
||||
|
|
@ -291,10 +287,7 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
wl_container_of(listener, layer, surface_commit);
|
||||
struct wlr_layer_surface_v1 *layer_surface = layer->layer_surface;
|
||||
struct wlr_output *wlr_output = layer_surface->output;
|
||||
if (wlr_output == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
struct wlr_box old_extent = layer->extent;
|
||||
|
||||
|
|
@ -341,13 +334,8 @@ static void unmap(struct sway_layer_surface *sway_layer) {
|
|||
cursor_rebase_all();
|
||||
|
||||
struct wlr_output *wlr_output = sway_layer->layer_surface->output;
|
||||
if (wlr_output == NULL) {
|
||||
return;
|
||||
}
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
if (output == NULL) {
|
||||
return;
|
||||
}
|
||||
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
|
||||
sway_layer->layer_surface->surface, true);
|
||||
}
|
||||
|
|
@ -375,22 +363,24 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&sway_layer->surface_commit.link);
|
||||
wl_list_remove(&sway_layer->new_popup.link);
|
||||
wl_list_remove(&sway_layer->new_subsurface.link);
|
||||
if (sway_layer->layer_surface->output != NULL) {
|
||||
struct sway_output *output = sway_layer->layer_surface->output->data;
|
||||
if (output != NULL) {
|
||||
arrange_layers(output);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
wl_list_remove(&sway_layer->output_destroy.link);
|
||||
sway_layer->layer_surface->output = NULL;
|
||||
}
|
||||
|
||||
struct wlr_output *wlr_output = sway_layer->layer_surface->output;
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
arrange_layers(output);
|
||||
transaction_commit_dirty();
|
||||
wl_list_remove(&sway_layer->output_destroy.link);
|
||||
sway_layer->layer_surface->output = NULL;
|
||||
|
||||
free(sway_layer);
|
||||
}
|
||||
|
||||
static void handle_map(struct wl_listener *listener, void *data) {
|
||||
struct sway_layer_surface *sway_layer = wl_container_of(listener,
|
||||
sway_layer, map);
|
||||
struct sway_output *output = sway_layer->layer_surface->output->data;
|
||||
struct wlr_output *wlr_output = sway_layer->layer_surface->output;
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
|
||||
sway_layer->layer_surface->surface, true);
|
||||
wlr_surface_send_enter(sway_layer->layer_surface->surface,
|
||||
|
|
@ -408,9 +398,7 @@ static void subsurface_damage(struct sway_layer_subsurface *subsurface,
|
|||
bool whole) {
|
||||
struct sway_layer_surface *layer = subsurface->layer_surface;
|
||||
struct wlr_output *wlr_output = layer->layer_surface->output;
|
||||
if (!wlr_output) {
|
||||
return;
|
||||
}
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
int ox = subsurface->wlr_subsurface->current.x + layer->geo.x;
|
||||
int oy = subsurface->wlr_subsurface->current.y + layer->geo.y;
|
||||
|
|
@ -513,6 +501,7 @@ static void popup_damage(struct sway_layer_popup *layer_popup, bool whole) {
|
|||
}
|
||||
}
|
||||
struct wlr_output *wlr_output = layer->layer_surface->output;
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
output_damage_surface(output, ox, oy, surface, whole);
|
||||
}
|
||||
|
|
@ -521,6 +510,7 @@ static void popup_handle_map(struct wl_listener *listener, void *data) {
|
|||
struct sway_layer_popup *popup = wl_container_of(listener, popup, map);
|
||||
struct sway_layer_surface *layer = popup_get_layer(popup);
|
||||
struct wlr_output *wlr_output = layer->layer_surface->output;
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
wlr_surface_send_enter(popup->wlr_popup->base->surface, wlr_output);
|
||||
popup_damage(popup, true);
|
||||
}
|
||||
|
|
@ -550,7 +540,9 @@ static void popup_unconstrain(struct sway_layer_popup *popup) {
|
|||
struct sway_layer_surface *layer = popup_get_layer(popup);
|
||||
struct wlr_xdg_popup *wlr_popup = popup->wlr_popup;
|
||||
|
||||
struct sway_output *output = layer->layer_surface->output->data;
|
||||
struct wlr_output *wlr_output = layer->layer_surface->output;
|
||||
sway_assert(wlr_output, "wlr_layer_surface_v1 has null output");
|
||||
struct sway_output *output = wlr_output->data;
|
||||
|
||||
// the output box expressed in the coordinate system of the toplevel parent
|
||||
// of the popup
|
||||
|
|
@ -642,6 +634,10 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
|
|||
sway_log(SWAY_ERROR,
|
||||
"no output to auto-assign layer surface '%s' to",
|
||||
layer_surface->namespace);
|
||||
// Note that layer_surface->output can be NULL
|
||||
// here, but none of our destroy callbacks are
|
||||
// registered yet so we don't have to make them
|
||||
// handle that case.
|
||||
wlr_layer_surface_v1_destroy(layer_surface);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_presentation_time.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
|
|
@ -737,14 +737,15 @@ static void update_output_manager_config(struct sway_server *server) {
|
|||
}
|
||||
struct wlr_output_configuration_head_v1 *config_head =
|
||||
wlr_output_configuration_head_v1_create(config, output->wlr_output);
|
||||
struct wlr_box *output_box = wlr_output_layout_get_box(
|
||||
root->output_layout, output->wlr_output);
|
||||
struct wlr_box output_box;
|
||||
wlr_output_layout_get_box(root->output_layout,
|
||||
output->wlr_output, &output_box);
|
||||
// We mark the output enabled even if it is switched off by DPMS
|
||||
config_head->state.enabled = output->current_mode != NULL && output->enabled;
|
||||
config_head->state.mode = output->current_mode;
|
||||
if (output_box) {
|
||||
config_head->state.x = output_box->x;
|
||||
config_head->state.y = output_box->y;
|
||||
if (!wlr_box_empty(&output_box)) {
|
||||
config_head->state.x = output_box.x;
|
||||
config_head->state.y = output_box.y;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <wlr/types/wlr_output_damage.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include "log.h"
|
||||
#include "config.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200112L
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include "sway/server.h"
|
||||
#include "sway/surface.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ static const struct sway_view_child_impl popup_impl;
|
|||
static void popup_get_view_coords(struct sway_view_child *child,
|
||||
int *sx, int *sy) {
|
||||
struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
|
||||
struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
|
||||
struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup;
|
||||
|
||||
wlr_xdg_popup_get_toplevel_coords(surface->popup,
|
||||
surface->popup->geometry.x - surface->current.geometry.x,
|
||||
surface->popup->geometry.y - surface->current.geometry.y,
|
||||
wlr_xdg_popup_get_toplevel_coords(wlr_popup,
|
||||
wlr_popup->geometry.x - wlr_popup->base->current.geometry.x,
|
||||
wlr_popup->geometry.y - wlr_popup->base->current.geometry.y,
|
||||
sx, sy);
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
|
|||
|
||||
static void popup_unconstrain(struct sway_xdg_popup *popup) {
|
||||
struct sway_view *view = popup->child.view;
|
||||
struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_surface->popup;
|
||||
struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup;
|
||||
|
||||
struct sway_output *output = view->container->pending.workspace->output;
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ static struct sway_xdg_popup *popup_create(
|
|||
return NULL;
|
||||
}
|
||||
view_child_init(&popup->child, &popup_impl, view, xdg_surface->surface);
|
||||
popup->wlr_xdg_surface = xdg_surface;
|
||||
popup->wlr_xdg_popup = xdg_surface->popup;
|
||||
|
||||
wl_signal_add(&xdg_surface->events.new_popup, &popup->new_popup);
|
||||
popup->new_popup.notify = popup_handle_new_popup;
|
||||
|
|
@ -119,7 +119,7 @@ static struct sway_xdg_shell_view *xdg_shell_view_from_view(
|
|||
static void get_constraints(struct sway_view *view, double *min_width,
|
||||
double *max_width, double *min_height, double *max_height) {
|
||||
struct wlr_xdg_toplevel_state *state =
|
||||
&view->wlr_xdg_surface->toplevel->current;
|
||||
&view->wlr_xdg_toplevel->current;
|
||||
*min_width = state->min_width > 0 ? state->min_width : DBL_MIN;
|
||||
*max_width = state->max_width > 0 ? state->max_width : DBL_MAX;
|
||||
*min_height = state->min_height > 0 ? state->min_height : DBL_MIN;
|
||||
|
|
@ -133,9 +133,9 @@ static const char *get_string_prop(struct sway_view *view,
|
|||
}
|
||||
switch (prop) {
|
||||
case VIEW_PROP_TITLE:
|
||||
return view->wlr_xdg_surface->toplevel->title;
|
||||
return view->wlr_xdg_toplevel->title;
|
||||
case VIEW_PROP_APP_ID:
|
||||
return view->wlr_xdg_surface->toplevel->app_id;
|
||||
return view->wlr_xdg_toplevel->app_id;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -148,50 +148,45 @@ static uint32_t configure(struct sway_view *view, double lx, double ly,
|
|||
if (xdg_shell_view == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
|
||||
return wlr_xdg_toplevel_set_size(view->wlr_xdg_toplevel,
|
||||
width, height);
|
||||
}
|
||||
|
||||
static void set_activated(struct sway_view *view, bool activated) {
|
||||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||
wlr_xdg_toplevel_set_activated(surface, activated);
|
||||
}
|
||||
wlr_xdg_toplevel_set_activated(view->wlr_xdg_toplevel, activated);
|
||||
}
|
||||
|
||||
static void set_tiled(struct sway_view *view, bool tiled) {
|
||||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||
enum wlr_edges edges = WLR_EDGE_NONE;
|
||||
if (tiled) {
|
||||
edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
|
||||
WLR_EDGE_BOTTOM;
|
||||
}
|
||||
wlr_xdg_toplevel_set_tiled(surface, edges);
|
||||
wlr_xdg_toplevel_set_tiled(view->wlr_xdg_toplevel, edges);
|
||||
}
|
||||
|
||||
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
|
||||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||
wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
|
||||
wlr_xdg_toplevel_set_fullscreen(view->wlr_xdg_toplevel, fullscreen);
|
||||
}
|
||||
|
||||
static void set_resizing(struct sway_view *view, bool resizing) {
|
||||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||
wlr_xdg_toplevel_set_resizing(surface, resizing);
|
||||
wlr_xdg_toplevel_set_resizing(view->wlr_xdg_toplevel, resizing);
|
||||
}
|
||||
|
||||
static bool wants_floating(struct sway_view *view) {
|
||||
struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel;
|
||||
struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel;
|
||||
struct wlr_xdg_toplevel_state *state = &toplevel->current;
|
||||
return (state->min_width != 0 && state->min_height != 0
|
||||
&& (state->min_width == state->max_width
|
||||
|
|
@ -204,7 +199,7 @@ static void for_each_surface(struct sway_view *view,
|
|||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
wlr_xdg_surface_for_each_surface(view->wlr_xdg_surface, iterator,
|
||||
wlr_xdg_surface_for_each_surface(view->wlr_xdg_toplevel->base, iterator,
|
||||
user_data);
|
||||
}
|
||||
|
||||
|
|
@ -213,8 +208,8 @@ static void for_each_popup_surface(struct sway_view *view,
|
|||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_surface, iterator,
|
||||
user_data);
|
||||
wlr_xdg_surface_for_each_popup_surface(view->wlr_xdg_toplevel->base,
|
||||
iterator, user_data);
|
||||
}
|
||||
|
||||
static bool is_transient_for(struct sway_view *child,
|
||||
|
|
@ -222,12 +217,12 @@ static bool is_transient_for(struct sway_view *child,
|
|||
if (xdg_shell_view_from_view(child) == NULL) {
|
||||
return false;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = child->wlr_xdg_surface;
|
||||
while (surface && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||
if (surface->toplevel->parent == ancestor->wlr_xdg_surface) {
|
||||
struct wlr_xdg_toplevel *toplevel = child->wlr_xdg_toplevel;
|
||||
while (toplevel) {
|
||||
if (toplevel->parent == ancestor->wlr_xdg_toplevel) {
|
||||
return true;
|
||||
}
|
||||
surface = surface->toplevel->parent;
|
||||
toplevel = toplevel->parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -236,17 +231,13 @@ static void _close(struct sway_view *view) {
|
|||
if (xdg_shell_view_from_view(view) == NULL) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL
|
||||
&& surface->toplevel) {
|
||||
wlr_xdg_toplevel_send_close(surface);
|
||||
}
|
||||
wlr_xdg_toplevel_send_close(view->wlr_xdg_toplevel);
|
||||
}
|
||||
|
||||
static void close_popups(struct sway_view *view) {
|
||||
struct wlr_xdg_popup *popup, *tmp;
|
||||
wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_surface->popups, link) {
|
||||
wlr_xdg_popup_destroy(popup->base);
|
||||
wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_toplevel->base->popups, link) {
|
||||
wlr_xdg_popup_destroy(popup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +271,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
wl_container_of(listener, xdg_shell_view, commit);
|
||||
struct sway_view *view = &xdg_shell_view->view;
|
||||
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
|
||||
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_toplevel->base;
|
||||
|
||||
struct wlr_box new_geo;
|
||||
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
|
||||
|
|
@ -337,23 +328,17 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
|||
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
|
||||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
wl_container_of(listener, xdg_shell_view, request_fullscreen);
|
||||
struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
|
||||
struct wlr_xdg_surface *xdg_surface =
|
||||
xdg_shell_view->view.wlr_xdg_surface;
|
||||
struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel;
|
||||
struct sway_view *view = &xdg_shell_view->view;
|
||||
|
||||
if (!sway_assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL,
|
||||
"xdg_shell requested fullscreen of surface with role %i",
|
||||
xdg_surface->role)) {
|
||||
return;
|
||||
}
|
||||
if (!xdg_surface->mapped) {
|
||||
if (!toplevel->base->mapped) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct sway_container *container = view->container;
|
||||
if (e->fullscreen && e->output && e->output->data) {
|
||||
struct sway_output *output = e->output->data;
|
||||
struct wlr_xdg_toplevel_requested *req = &toplevel->requested;
|
||||
if (req->fullscreen && req->fullscreen_output && req->fullscreen_output->data) {
|
||||
struct sway_output *output = req->fullscreen_output->data;
|
||||
struct sway_workspace *ws = output_get_active_workspace(output);
|
||||
if (ws && !container_is_scratchpad_hidden(container) &&
|
||||
container->pending.workspace != ws) {
|
||||
|
|
@ -365,7 +350,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
container_set_fullscreen(container, e->fullscreen);
|
||||
container_set_fullscreen(container, req->fullscreen);
|
||||
|
||||
arrange_root();
|
||||
transaction_commit_dirty();
|
||||
|
|
@ -375,7 +360,8 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
|||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
wl_container_of(listener, xdg_shell_view, request_move);
|
||||
struct sway_view *view = &xdg_shell_view->view;
|
||||
if (!container_is_floating(view->container)) {
|
||||
if (!container_is_floating(view->container) ||
|
||||
view->container->pending.fullscreen_mode) {
|
||||
return;
|
||||
}
|
||||
struct wlr_xdg_toplevel_move_event *e = data;
|
||||
|
|
@ -423,13 +409,13 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
wl_container_of(listener, xdg_shell_view, map);
|
||||
struct sway_view *view = &xdg_shell_view->view;
|
||||
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
|
||||
struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_toplevel;
|
||||
|
||||
view->natural_width = view->wlr_xdg_surface->current.geometry.width;
|
||||
view->natural_height = view->wlr_xdg_surface->current.geometry.height;
|
||||
view->natural_width = toplevel->base->current.geometry.width;
|
||||
view->natural_height = toplevel->base->current.geometry.height;
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = view->wlr_xdg_surface->surface->current.width;
|
||||
view->natural_height = view->wlr_xdg_surface->surface->current.height;
|
||||
view->natural_width = toplevel->base->surface->current.width;
|
||||
view->natural_height = toplevel->base->surface->current.height;
|
||||
}
|
||||
|
||||
bool csd = false;
|
||||
|
|
@ -440,44 +426,44 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
csd = mode == WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||
} else {
|
||||
struct sway_server_decoration *deco =
|
||||
decoration_from_surface(xdg_surface->surface);
|
||||
decoration_from_surface(toplevel->base->surface);
|
||||
csd = !deco || deco->wlr_server_decoration->mode ==
|
||||
WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT;
|
||||
}
|
||||
|
||||
view_map(view, view->wlr_xdg_surface->surface,
|
||||
xdg_surface->toplevel->requested.fullscreen,
|
||||
xdg_surface->toplevel->requested.fullscreen_output,
|
||||
view_map(view, toplevel->base->surface,
|
||||
toplevel->requested.fullscreen,
|
||||
toplevel->requested.fullscreen_output,
|
||||
csd);
|
||||
|
||||
transaction_commit_dirty();
|
||||
|
||||
xdg_shell_view->commit.notify = handle_commit;
|
||||
wl_signal_add(&xdg_surface->surface->events.commit,
|
||||
wl_signal_add(&toplevel->base->surface->events.commit,
|
||||
&xdg_shell_view->commit);
|
||||
|
||||
xdg_shell_view->new_popup.notify = handle_new_popup;
|
||||
wl_signal_add(&xdg_surface->events.new_popup,
|
||||
wl_signal_add(&toplevel->base->events.new_popup,
|
||||
&xdg_shell_view->new_popup);
|
||||
|
||||
xdg_shell_view->request_fullscreen.notify = handle_request_fullscreen;
|
||||
wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen,
|
||||
wl_signal_add(&toplevel->events.request_fullscreen,
|
||||
&xdg_shell_view->request_fullscreen);
|
||||
|
||||
xdg_shell_view->request_move.notify = handle_request_move;
|
||||
wl_signal_add(&xdg_surface->toplevel->events.request_move,
|
||||
wl_signal_add(&toplevel->events.request_move,
|
||||
&xdg_shell_view->request_move);
|
||||
|
||||
xdg_shell_view->request_resize.notify = handle_request_resize;
|
||||
wl_signal_add(&xdg_surface->toplevel->events.request_resize,
|
||||
wl_signal_add(&toplevel->events.request_resize,
|
||||
&xdg_shell_view->request_resize);
|
||||
|
||||
xdg_shell_view->set_title.notify = handle_set_title;
|
||||
wl_signal_add(&xdg_surface->toplevel->events.set_title,
|
||||
wl_signal_add(&toplevel->events.set_title,
|
||||
&xdg_shell_view->set_title);
|
||||
|
||||
xdg_shell_view->set_app_id.notify = handle_set_app_id;
|
||||
wl_signal_add(&xdg_surface->toplevel->events.set_app_id,
|
||||
wl_signal_add(&toplevel->events.set_app_id,
|
||||
&xdg_shell_view->set_app_id);
|
||||
}
|
||||
|
||||
|
|
@ -491,7 +477,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&xdg_shell_view->destroy.link);
|
||||
wl_list_remove(&xdg_shell_view->map.link);
|
||||
wl_list_remove(&xdg_shell_view->unmap.link);
|
||||
view->wlr_xdg_surface = NULL;
|
||||
view->wlr_xdg_toplevel = NULL;
|
||||
if (view->xdg_decoration) {
|
||||
view->xdg_decoration->view = NULL;
|
||||
}
|
||||
|
|
@ -522,7 +508,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl);
|
||||
xdg_shell_view->view.wlr_xdg_surface = xdg_surface;
|
||||
xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel;
|
||||
|
||||
xdg_shell_view->map.notify = handle_map;
|
||||
wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/xwayland.h>
|
||||
#include <xcb/xcb_icccm.h>
|
||||
#include "log.h"
|
||||
#include "sway/desktop.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
|
|
@ -121,6 +122,20 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
}
|
||||
|
||||
static void unmanaged_handle_request_activate(struct wl_listener *listener, void *data) {
|
||||
struct wlr_xwayland_surface *xsurface = data;
|
||||
if (!xsurface->mapped) {
|
||||
return;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
struct sway_container *focus = seat_get_focused_container(seat);
|
||||
if (focus && focus->view && focus->view->pid != xsurface->pid) {
|
||||
return;
|
||||
}
|
||||
|
||||
seat_set_focus_surface(seat, xsurface->surface, false);
|
||||
}
|
||||
|
||||
static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct sway_xwayland_unmanaged *surface =
|
||||
wl_container_of(listener, surface, destroy);
|
||||
|
|
@ -129,6 +144,7 @@ static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&surface->unmap.link);
|
||||
wl_list_remove(&surface->destroy.link);
|
||||
wl_list_remove(&surface->override_redirect.link);
|
||||
wl_list_remove(&surface->request_activate.link);
|
||||
free(surface);
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +192,8 @@ static struct sway_xwayland_unmanaged *create_unmanaged(
|
|||
surface->destroy.notify = unmanaged_handle_destroy;
|
||||
wl_signal_add(&xsurface->events.set_override_redirect, &surface->override_redirect);
|
||||
surface->override_redirect.notify = unmanaged_handle_override_redirect;
|
||||
wl_signal_add(&xsurface->events.request_activate, &surface->request_activate);
|
||||
surface->request_activate.notify = unmanaged_handle_request_activate;
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
|
@ -294,7 +312,7 @@ static bool wants_floating(struct sway_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints;
|
||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||
if (size_hints != NULL &&
|
||||
size_hints->min_width > 0 && size_hints->min_height > 0 &&
|
||||
(size_hints->max_width == size_hints->min_width ||
|
||||
|
|
@ -348,7 +366,7 @@ static void destroy(struct sway_view *view) {
|
|||
static void get_constraints(struct sway_view *view, double *min_width,
|
||||
double *max_width, double *min_height, double *max_height) {
|
||||
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
|
||||
struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints;
|
||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||
|
||||
if (size_hints == NULL) {
|
||||
*min_width = DBL_MIN;
|
||||
|
|
@ -577,7 +595,8 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
|||
if (!xsurface->mapped) {
|
||||
return;
|
||||
}
|
||||
if (!container_is_floating(view->container)) {
|
||||
if (!container_is_floating(view->container) ||
|
||||
view->container->pending.fullscreen_mode) {
|
||||
return;
|
||||
}
|
||||
struct sway_seat *seat = input_manager_current_seat();
|
||||
|
|
@ -666,14 +685,15 @@ static void handle_set_hints(struct wl_listener *listener, void *data) {
|
|||
if (!xsurface->mapped) {
|
||||
return;
|
||||
}
|
||||
if (!xsurface->hints_urgency && view->urgent_timer) {
|
||||
const bool hints_urgency = xcb_icccm_wm_hints_get_urgency(xsurface->hints);
|
||||
if (!hints_urgency && view->urgent_timer) {
|
||||
// The view is in the timeout period. We'll ignore the request to
|
||||
// unset urgency so that the view remains urgent until the timer clears
|
||||
// it.
|
||||
return;
|
||||
}
|
||||
if (view->allow_request_urgent) {
|
||||
view_set_urgent(view, (bool)xsurface->hints_urgency);
|
||||
view_set_urgent(view, hints_urgency);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue