aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2019-08-20 18:30:09 +0900
committerLibravatar Simon Ser <contact@emersion.fr>2020-06-23 22:26:00 +0200
commit8d5e627bc98f376f84e7f5b0a7caed791351c577 (patch)
tree7d90c18521bfbcc59155a418efbd9b489617086e /sway/tree/view.c
parentinput_cmd_click_method: fix typo in error text (diff)
downloadsway-8d5e627bc98f376f84e7f5b0a7caed791351c577.tar.gz
sway-8d5e627bc98f376f84e7f5b0a7caed791351c577.tar.zst
sway-8d5e627bc98f376f84e7f5b0a7caed791351c577.zip
Implement wlr-foreign-toplevel-management-v1
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e5d3948c..6dccaa2e 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -22,6 +22,7 @@
22#include "sway/ipc-server.h" 22#include "sway/ipc-server.h"
23#include "sway/output.h" 23#include "sway/output.h"
24#include "sway/input/seat.h" 24#include "sway/input/seat.h"
25#include "sway/server.h"
25#include "sway/tree/arrange.h" 26#include "sway/tree/arrange.h"
26#include "sway/tree/container.h" 27#include "sway/tree/container.h"
27#include "sway/tree/view.h" 28#include "sway/tree/view.h"
@@ -329,6 +330,10 @@ void view_set_activated(struct sway_view *view, bool activated) {
329 if (view->impl->set_activated) { 330 if (view->impl->set_activated) {
330 view->impl->set_activated(view, activated); 331 view->impl->set_activated(view, activated);
331 } 332 }
333 if (view->foreign_toplevel) {
334 wlr_foreign_toplevel_handle_v1_set_activated(
335 view->foreign_toplevel, activated);
336 }
332} 337}
333 338
334void view_request_activate(struct sway_view *view) { 339void view_request_activate(struct sway_view *view) {
@@ -589,6 +594,27 @@ static bool should_focus(struct sway_view *view) {
589 return len == 0; 594 return len == 0;
590} 595}
591 596
597static void handle_foreign_activate_request(
598 struct wl_listener *listener, void *data) {
599 struct sway_view *view = wl_container_of(
600 listener, view, foreign_activate_request);
601 struct wlr_foreign_toplevel_handle_v1_activated_event *event = data;
602 struct sway_seat *seat;
603 wl_list_for_each(seat, &server.input->seats, link) {
604 if (seat->wlr_seat == event->seat) {
605 seat_set_focus_container(seat, view->container);
606 break;
607 }
608 }
609}
610
611static void handle_foreign_close_request(
612 struct wl_listener *listener, void *data) {
613 struct sway_view *view = wl_container_of(
614 listener, view, foreign_close_request);
615 view_close(view);
616}
617
592void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, 618void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
593 bool fullscreen, struct wlr_output *fullscreen_output, 619 bool fullscreen, struct wlr_output *fullscreen_output,
594 bool decoration) { 620 bool decoration) {
@@ -617,6 +643,15 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
617 struct sway_container *target_sibling = node->type == N_CONTAINER ? 643 struct sway_container *target_sibling = node->type == N_CONTAINER ?
618 node->sway_container : NULL; 644 node->sway_container : NULL;
619 645
646 view->foreign_toplevel =
647 wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager);
648 view->foreign_activate_request.notify = handle_foreign_activate_request;
649 wl_signal_add(&view->foreign_toplevel->events.request_activate,
650 &view->foreign_activate_request);
651 view->foreign_close_request.notify = handle_foreign_close_request;
652 wl_signal_add(&view->foreign_toplevel->events.request_close,
653 &view->foreign_close_request);
654
620 // If we're about to launch the view into the floating container, then 655 // If we're about to launch the view into the floating container, then
621 // launch it as a tiled view in the root of the workspace instead. 656 // launch it as a tiled view in the root of the workspace instead.
622 if (target_sibling && container_is_floating(target_sibling)) { 657 if (target_sibling && container_is_floating(target_sibling)) {
@@ -679,6 +714,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
679 if (should_focus(view)) { 714 if (should_focus(view)) {
680 input_manager_set_focus(&view->container->node); 715 input_manager_set_focus(&view->container->node);
681 } 716 }
717
718 const char *app_id = view_get_app_id(view);
719 if (app_id != NULL) {
720 wlr_foreign_toplevel_handle_v1_set_app_id(
721 view->foreign_toplevel, app_id);
722 }
682} 723}
683 724
684void view_unmap(struct sway_view *view) { 725void view_unmap(struct sway_view *view) {
@@ -691,6 +732,11 @@ void view_unmap(struct sway_view *view) {
691 view->urgent_timer = NULL; 732 view->urgent_timer = NULL;
692 } 733 }
693 734
735 if (view->foreign_toplevel) {
736 wlr_foreign_toplevel_handle_v1_destroy(view->foreign_toplevel);
737 view->foreign_toplevel = NULL;
738 }
739
694 struct sway_container *parent = view->container->parent; 740 struct sway_container *parent = view->container->parent;
695 struct sway_workspace *ws = view->container->workspace; 741 struct sway_workspace *ws = view->container->workspace;
696 container_begin_destroy(view->container); 742 container_begin_destroy(view->container);
@@ -1097,6 +1143,10 @@ void view_update_title(struct sway_view *view, bool force) {
1097 container_update_title_textures(view->container); 1143 container_update_title_textures(view->container);
1098 1144
1099 ipc_event_window(view->container, "title"); 1145 ipc_event_window(view->container, "title");
1146
1147 if (view->foreign_toplevel) {
1148 wlr_foreign_toplevel_handle_v1_set_title(view->foreign_toplevel, title);
1149 }
1100} 1150}
1101 1151
1102bool view_is_visible(struct sway_view *view) { 1152bool view_is_visible(struct sway_view *view) {