Skip to content

Commit

Permalink
Make initial output enter work for XWayland views
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Nov 19, 2023
1 parent d039dfe commit 8911cb8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/surface/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,23 @@ void View::set_size(const int new_width, const int new_height) {
impl_set_size(new_width, new_height);
}

void View::update_outputs() const {
void View::update_outputs(const bool ignore_previous) const {
for (auto& output : std::as_const(get_server().outputs)) {
wlr_box output_area = output->full_area;
wlr_box prev_intersect = {}, curr_intersect = {};
wlr_box_intersection(&prev_intersect, &previous, &output_area);
wlr_box_intersection(&curr_intersect, &current, &output_area);

if (wlr_box_empty(&prev_intersect) && !wlr_box_empty(&curr_intersect)) {
if (ignore_previous) {
if (!wlr_box_empty(&curr_intersect)) {
std::printf("Output %p entered\n", (void*) &output);
toplevel_handle->output_enter(*output);
}
} else if (wlr_box_empty(&prev_intersect) && !wlr_box_empty(&curr_intersect)) {
std::printf("Output %p entered\n", (void*) &output);
toplevel_handle->output_enter(*output);
} else if (!wlr_box_empty(&prev_intersect) && wlr_box_empty(&curr_intersect)) {
std::printf("Output %p left\n", (void*) &output);
toplevel_handle->output_leave(*output);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/surface/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct View : Surface {
void begin_interactive(CursorMode mode, uint32_t edges);
void set_position(int new_x, int new_y);
void set_size(int new_width, int new_height);
void update_outputs() const;
void update_outputs(bool ignore_previous = false) const;
void set_activated(bool activated);
void set_placement(ViewPlacement new_placement, bool force = false);
void set_minimized(bool minimized);
Expand Down
2 changes: 2 additions & 0 deletions src/surface/xdg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ void XdgView::map() {
set_placement(VIEW_PLACEMENT_STACKING);
}

update_outputs(true);

server.focus_view(this);
}

Expand Down
10 changes: 6 additions & 4 deletions src/surface/xwayland_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "foreign_toplevel.hpp"
#include "input/seat.hpp"
#include "output.hpp"
#include "server.hpp"
#include "surface.hpp"
#include "types.hpp"
Expand Down Expand Up @@ -45,10 +46,10 @@ static void xwayland_surface_request_configure_notify(wl_listener* listener, voi
const auto* event = static_cast<wlr_xwayland_surface_configure_event*>(data);

wlr_xwayland_surface_configure(&surface, event->x, event->y, event->width, event->height);
view.current = {event->x, event->y, event->width, event->height};
view.set_size(event->width, event->height);

if (surface.mapped) {
wlr_scene_node_set_position(view.scene_node, event->x, event->y);
view.set_position(event->x, event->y);
}
}

Expand All @@ -58,9 +59,9 @@ static void xwayland_surface_set_geometry_notify(wl_listener* listener, void* da

const wlr_xwayland_surface& surface = view.xwayland_surface;

view.current = {surface.x, surface.y, surface.width, surface.height};
view.set_size(surface.width, surface.height);
if (surface.mapped) {
wlr_scene_node_set_position(view.scene_node, view.current.x, view.current.y);
view.set_position(surface.x, surface.y);
}
}

Expand Down Expand Up @@ -232,6 +233,7 @@ void XWaylandView::map() {
}

server.views.insert(server.views.begin(), this);
update_outputs(true);
server.focus_view(this);
}

Expand Down

0 comments on commit 8911cb8

Please sign in to comment.