Skip to content

Commit

Permalink
Track wlroots 0.17 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau committed Nov 17, 2023
1 parent 3f1ad7b commit 5be54cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
21 changes: 8 additions & 13 deletions src/background-view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,21 @@ class wayfire_background_view : public wf::plugin_interface_t
void set_view_for_output(wayfire_toplevel_view view, wlr_surface *surface, wf::output_t *o)
{
std::shared_ptr<unmappable_view_t> new_view;
if (wlr_surface_is_xdg_surface(surface))
if (wlr_xdg_surface *surf = wlr_xdg_surface_try_from_wlr_surface(surface))
{
auto toplevel = wlr_xdg_surface_from_wlr_surface(surface)->toplevel;
auto toplevel = surf->toplevel;
wlr_xdg_toplevel_set_size(toplevel, o->get_screen_size().width, o->get_screen_size().height);
new_view = unmappable_view_t::create<wayfire_background_view_xdg>(toplevel, o);
new_view->on_unmap.connect(&toplevel->base->events.unmap);
new_view->on_unmap.connect(&toplevel->base->surface->events.unmap);
}

#if WF_HAS_XWAYLAND
else if (wlr_surface_is_xwayland_surface(surface))
else if (wlr_xwayland_surface *surf = wlr_xwayland_surface_try_from_wlr_surface(surface))
{
auto xw = wlr_xwayland_surface_from_wlr_surface(surface);
wlr_xwayland_surface_configure(xw, o->get_layout_geometry().x, o->get_layout_geometry().y,
wlr_xwayland_surface_configure(surf, o->get_layout_geometry().x, o->get_layout_geometry().y,
o->get_layout_geometry().width, o->get_layout_geometry().height);
new_view = unmappable_view_t::create<wayfire_background_view_xwl>(xw, o);
new_view->on_unmap.connect(&xw->events.unmap);
new_view = unmappable_view_t::create<wayfire_background_view_xwl>(surf, o);
new_view->on_unmap.connect(&surf->surface->events.unmap);
}
#endif
else
Expand Down Expand Up @@ -391,11 +390,7 @@ class wayfire_background_view : public wf::plugin_interface_t

#if WF_HAS_XWAYLAND
wlr_surface *wlr_surface = ev->surface;
wlr_xwayland_surface *xwayland_surface = nullptr;
if (wlr_surface && wlr_surface_is_xwayland_surface(wlr_surface))
{
xwayland_surface = wlr_xwayland_surface_from_wlr_surface(wlr_surface);
}
wlr_xwayland_surface *xwayland_surface = wlr_xwayland_surface_try_from_wlr_surface(wlr_surface);

if (xwayland_surface)
{
Expand Down
15 changes: 6 additions & 9 deletions src/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class wayfire_bench_screen : public wf::per_output_plugin_instance_t
double max_fps = 0;
double widget_xc;
uint32_t last_time = wf::get_current_time();
double current_fps;
double widget_radius;
wf::wl_timer<false> timer;
wf::simple_texture_t bench_tex;
Expand Down Expand Up @@ -83,9 +82,9 @@ class wayfire_bench_screen : public wf::per_output_plugin_instance_t

last_frame_times.push_back(elapsed);

render_bench();

reset_timeout();

render_bench();
}

void reset_timeout()
Expand Down Expand Up @@ -118,7 +117,7 @@ class wayfire_bench_screen : public wf::per_output_plugin_instance_t
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, font_size);

cairo_text_extents(cr, "234.5", &text_extents);
cairo_text_extents(cr, "1000.0", &text_extents);

widget_xc = text_extents.width / 2 + text_extents.x_bearing + WIDGET_PADDING;
text_y = text_extents.height + WIDGET_PADDING;
Expand Down Expand Up @@ -230,14 +229,11 @@ class wayfire_bench_screen : public wf::per_output_plugin_instance_t
last_frame_times.begin(), last_frame_times.end(), 0.0);
average /= last_frame_times.size();

current_fps = 1000 / average;
double current_fps = 1000 / average;

if (current_fps > max_fps)
{
max_fps = current_fps;
} else
{
max_fps -= 1;
}

sprintf(fps_buf, "%.1f", current_fps);
Expand Down Expand Up @@ -295,9 +291,10 @@ class wayfire_bench_screen : public wf::per_output_plugin_instance_t
{
if (!output->render->get_scheduled_damage().empty())
{
output->render->damage(cairo_geometry);
compute_timing();
}

output->render->damage(cairo_geometry, false);
};

wf::effect_hook_t overlay_hook = [=] ()
Expand Down
8 changes: 8 additions & 0 deletions src/water.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class wayfire_water_screen : public wf::per_output_plugin_instance_t, public wf:

if (!hook_set)
{
output->render->add_effect(&damage_hook, wf::OUTPUT_EFFECT_DAMAGE);
output->render->add_post(&render);
hook_set = true;
}
Expand All @@ -266,6 +267,11 @@ class wayfire_water_screen : public wf::per_output_plugin_instance_t, public wf:
animation.animate(animation, 0);
};

wf::effect_hook_t damage_hook = [=] ()
{
output->render->damage_whole();
};

wf::post_hook_t render = [=] (const wf::framebuffer_t& source,
const wf::framebuffer_t& destination)
{
Expand Down Expand Up @@ -396,6 +402,7 @@ class wayfire_water_screen : public wf::per_output_plugin_instance_t, public wf:
if (!button_down && !timer.is_connected() && !animation.running())
{
hook_set = false;
output->render->rem_effect(&damage_hook);
output->render->rem_post(&render);
OpenGL::render_begin();
buffer[0].release();
Expand All @@ -414,6 +421,7 @@ class wayfire_water_screen : public wf::per_output_plugin_instance_t, public wf:
timer.disconnect();
if (hook_set)
{
output->render->rem_effect(&damage_hook);
output->render->rem_post(&render);
}

Expand Down

0 comments on commit 5be54cf

Please sign in to comment.