summaryrefslogtreecommitdiff
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 272967f4..bd2268fd 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -25,6 +25,7 @@
#include "sway/output.h"
#include "sway/input/seat.h"
#include "sway/server.h"
+#include "sway/surface.h"
#include "sway/tree/arrange.h"
#include "sway/tree/container.h"
#include "sway/tree/view.h"
@@ -366,16 +367,15 @@ void view_set_activated(struct sway_view *view, bool activated) {
}
}
-void view_request_activate(struct sway_view *view) {
+void view_request_activate(struct sway_view *view, struct sway_seat *seat) {
struct sway_workspace *ws = view->container->pending.workspace;
- if (!ws) { // hidden scratchpad container
- return;
+ if (!seat) {
+ seat = input_manager_current_seat();
}
- struct sway_seat *seat = input_manager_current_seat();
switch (config->focus_on_window_activation) {
case FOWA_SMART:
- if (workspace_is_visible(ws)) {
+ if (ws && workspace_is_visible(ws)) {
seat_set_focus_container(seat, view->container);
container_raise_floating(view->container);
} else {
@@ -386,8 +386,12 @@ void view_request_activate(struct sway_view *view) {
view_set_urgent(view, true);
break;
case FOWA_FOCUS:
- seat_set_focus_container(seat, view->container);
- container_raise_floating(view->container);
+ if (container_is_scratchpad_hidden_or_child(view->container)) {
+ root_scratchpad_show(view->container);
+ } else {
+ seat_set_focus_container(seat, view->container);
+ container_raise_floating(view->container);
+ }
break;
case FOWA_NONE:
break;
@@ -395,6 +399,12 @@ void view_request_activate(struct sway_view *view) {
transaction_commit_dirty();
}
+void view_request_urgent(struct sway_view *view) {
+ if (config->focus_on_window_activation != FOWA_NONE) {
+ view_set_urgent(view, true);
+ }
+}
+
void view_set_csd_from_server(struct sway_view *view, bool enabled) {
sway_log(SWAY_DEBUG, "Telling view %p to set CSD to %i", view, enabled);
if (view->xdg_decoration) {
@@ -526,7 +536,7 @@ static void view_populate_pid(struct sway_view *view) {
#if HAVE_XWAYLAND
case SWAY_VIEW_XWAYLAND:;
struct wlr_xwayland_surface *surf =
- wlr_xwayland_surface_from_wlr_surface(view->surface);
+ wlr_xwayland_surface_try_from_wlr_surface(view->surface);
pid = surf->pid;
break;
#endif
@@ -885,9 +895,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool set_focus = should_focus(view);
#if HAVE_XWAYLAND
- if (wlr_surface_is_xwayland_surface(wlr_surface)) {
- struct wlr_xwayland_surface *xsurface =
- wlr_xwayland_surface_from_wlr_surface(wlr_surface);
+ struct wlr_xwayland_surface *xsurface;
+ if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface))) {
set_focus &= wlr_xwayland_icccm_input_model(xsurface) !=
WLR_ICCCM_INPUT_MODEL_NONE;
}
@@ -911,6 +920,8 @@ void view_unmap(struct sway_view *view) {
wl_list_remove(&view->surface_new_subsurface.link);
+ view->executed_criteria->length = 0;
+
if (view->urgent_timer) {
wl_event_source_remove(view->urgent_timer);
view->urgent_timer = NULL;
@@ -984,7 +995,7 @@ static void subsurface_get_view_coords(struct sway_view_child *child,
*sx = *sy = 0;
}
struct wlr_subsurface *subsurface =
- wlr_subsurface_from_wlr_surface(surface);
+ wlr_subsurface_try_from_wlr_surface(surface);
*sx += subsurface->current.x;
*sy += subsurface->current.y;
}
@@ -1179,7 +1190,7 @@ void view_child_init(struct sway_view_child *child,
if (container != NULL) {
struct sway_workspace *workspace = container->pending.workspace;
if (workspace) {
- wlr_surface_send_enter(child->surface, workspace->output->wlr_output);
+ surface_enter_output(child->surface, workspace->output);
}
}
@@ -1220,33 +1231,21 @@ void view_child_destroy(struct sway_view_child *child) {
}
struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {
- if (wlr_surface_is_xdg_surface(wlr_surface)) {
- struct wlr_xdg_surface *xdg_surface =
- wlr_xdg_surface_from_wlr_surface(wlr_surface);
- if (xdg_surface == NULL) {
- return NULL;
- }
+ struct wlr_xdg_surface *xdg_surface;
+ if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface))) {
return view_from_wlr_xdg_surface(xdg_surface);
}
#if HAVE_XWAYLAND
- if (wlr_surface_is_xwayland_surface(wlr_surface)) {
- struct wlr_xwayland_surface *xsurface =
- wlr_xwayland_surface_from_wlr_surface(wlr_surface);
- if (xsurface == NULL) {
- return NULL;
- }
+ struct wlr_xwayland_surface *xsurface;
+ if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface))) {
return view_from_wlr_xwayland_surface(xsurface);
}
#endif
- if (wlr_surface_is_subsurface(wlr_surface)) {
- struct wlr_subsurface *subsurface =
- wlr_subsurface_from_wlr_surface(wlr_surface);
- if (subsurface == NULL) {
- return NULL;
- }
+ struct wlr_subsurface *subsurface;
+ if ((subsurface = wlr_subsurface_try_from_wlr_surface(wlr_surface))) {
return view_from_wlr_surface(subsurface->parent);
}
- if (wlr_surface_is_layer_surface(wlr_surface)) {
+ if (wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) {
return NULL;
}
@@ -1463,7 +1462,7 @@ static void view_save_buffer_iterator(struct wlr_surface *surface,
int sx, int sy, void *data) {
struct sway_view *view = data;
- if (surface && wlr_surface_has_buffer(surface)) {
+ if (surface && surface->buffer) {
wlr_buffer_lock(&surface->buffer->base);
struct sway_saved_buffer *saved_buffer = calloc(1, sizeof(struct sway_saved_buffer));
saved_buffer->buffer = surface->buffer;