Skip to content

Commit

Permalink
Merge #1173 #1182
Browse files Browse the repository at this point in the history
1173: XWayland: create scene surface only when needed r=AlanGriffiths a=wmww

XWayland: create scene surface only when needed. (Fixes: #1172)

1182: Wayland: don't assume PixelSource::read() will execute the do_with_pixels functor r=wmww a=AlanGriffiths

Wayland: (cursor code) don't assume PixelSource::read() will execute the do_with_pixels functor. (Fixes: #1180)

Co-authored-by: William Wold <wm@wmww.sh>
Co-authored-by: Alan Griffiths <alan@octopull.co.uk>
  • Loading branch information
3 people committed Jan 9, 2020
3 parents 322f84d + b980862 + 3d2ed4f commit 62eb452
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/server/frontend_wayland/window_wl_surface_role.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void mf::WindowWlSurfaceRole::set_fullscreen(std::experimental::optional<struct
params->state = mir_window_state_fullscreen;
if (output)
params->output_id = output_manager->output_id_for(client, output.value());
create_mir_window();
create_scene_surface();
}
}

Expand All @@ -299,7 +299,7 @@ void mf::WindowWlSurfaceRole::set_state_now(MirWindowState state)
else
{
params->state = state;
create_mir_window();
create_scene_surface();
}
}

Expand Down Expand Up @@ -386,7 +386,7 @@ void mf::WindowWlSurfaceRole::commit(WlSurfaceState const& state)
}
else
{
create_mir_window();
create_scene_surface();
}

committed_size = size;
Expand Down Expand Up @@ -427,8 +427,11 @@ mir::shell::SurfaceSpecification& mf::WindowWlSurfaceRole::spec()
return *pending_changes;
}

void mf::WindowWlSurfaceRole::create_mir_window()
void mf::WindowWlSurfaceRole::create_scene_surface()
{
if (weak_scene_surface.lock())
return;

params->size = pending_size();
params->streams = std::vector<shell::StreamSpecification>{};
params->input_shape = std::vector<geom::Rectangle>{};
Expand Down
2 changes: 1 addition & 1 deletion src/server/frontend_wayland/window_wl_surface_role.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class WindowWlSurfaceRole : public WlSurfaceRole
void set_server_side_decorated(bool server_side_decorated);

void set_state_now(MirWindowState state);
void create_scene_surface();

/// Gets called after the surface has committed (so current_size() may return the committed buffer size) but before
/// the Mir window is modified (so if a pending size is set or a spec is applied those changes will take effect)
Expand Down Expand Up @@ -153,7 +154,6 @@ class WindowWlSurfaceRole : public WlSurfaceRole
void visiblity(bool visible) override;

shell::SurfaceSpecification& spec();
void create_mir_window();
};

}
Expand Down
11 changes: 5 additions & 6 deletions src/server/frontend_wayland/wl_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ class BufferCursorImage : public mg::CursorImage
auto pixel_source = dynamic_cast<mrs::PixelSource*>(buffer.native_buffer_base());
if (pixel_source)
{
pixel_source->read([&](unsigned char const* buffer_pixels)
size_t const buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int()
* MIR_BYTES_PER_PIXEL(buffer.pixel_format());
pixels = std::unique_ptr<unsigned char[]>(new unsigned char[buffer_size_bytes]);

pixel_source->read([this, buffer_size_bytes](unsigned char const* buffer_pixels)
{
size_t buffer_size_bytes = buffer_size.width.as_int() * buffer_size.height.as_int()
* MIR_BYTES_PER_PIXEL(buffer.pixel_format());
pixels = std::unique_ptr<unsigned char[]>(
new unsigned char[buffer_size_bytes]
);
memcpy(pixels.get(), buffer_pixels, buffer_size_bytes);
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/server/frontend_xwayland/xwayland_wm_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ void mf::XWaylandWMSurface::set_surface(WlSurface *wls)
if (!properties.title.empty())
shell_surface->set_title(properties.title);

shell_surface->set_state_now(mir_window_state_restored);
// If a buffer has alread been committed, we need to create the scene::Surface without waiting for next commit
if (wls->buffer_size())
shell_surface->create_scene_surface();

xcb_flush(xwm->get_xcb_connection());
}

Expand Down

0 comments on commit 62eb452

Please sign in to comment.