Skip to content

Commit

Permalink
core: enable primary selection support
Browse files Browse the repository at this point in the history
Fixes #447
  • Loading branch information
ammen99 committed Apr 8, 2020
1 parent 3f932b1 commit 708b7aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/api/wayfire/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extern "C"
struct wlr_cursor;
struct wlr_data_device_manager;
struct wlr_data_control_manager_v1;
struct wlr_linux_dmabuf_v1;
struct wlr_gamma_control_manager_v1;
struct wlr_xdg_output_manager_v1;
struct wlr_export_dmabuf_manager_v1;
Expand All @@ -36,6 +35,8 @@ extern "C"
struct wlr_pointer_constraints_v1;
struct wlr_tablet_manager_v2;
struct wlr_presentation;
struct wlr_gtk_primary_selection_device_manager;
struct wlr_primary_selection_v1_device_manager;

#include <wayland-server.h>
}
Expand Down Expand Up @@ -86,7 +87,6 @@ class compositor_core_t : public wf::object_base_t
wlr_data_control_manager_v1 *data_control;
wlr_gamma_control_manager_v1 *gamma_v1;
wlr_screencopy_manager_v1 *screencopy;
wlr_linux_dmabuf_v1 *linux_dmabuf;
wlr_export_dmabuf_manager_v1 *export_dmabuf;
wlr_server_decoration_manager *decorator_manager;
wlr_xdg_decoration_manager_v1 *xdg_decorator;
Expand All @@ -102,6 +102,8 @@ class compositor_core_t : public wf::object_base_t
wlr_pointer_constraints_v1 *pointer_constraints;
wlr_tablet_manager_v2 *tablet_v2;
wlr_presentation *presentation;
wlr_gtk_primary_selection_device_manager *gtk_primary_selection;
wlr_primary_selection_v1_device_manager *primary_selection_v1;
} protocols;

std::string to_string() const { return "wayfire-core"; }
Expand Down
20 changes: 13 additions & 7 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ extern "C"
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_input_inhibitor.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
Expand All @@ -21,6 +20,8 @@ extern "C"
#include <wlr/types/wlr_pointer_constraints_v1.h>
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/types/wlr_gtk_primary_selection.h>
#include <wlr/types/wlr_primary_selection_v1.h>

#define static
#include <wlr/render/wlr_renderer.h>
Expand Down Expand Up @@ -167,28 +168,33 @@ struct wf_pointer_constraint

void wf::compositor_core_impl_t::init()
{
protocols.data_device = wlr_data_device_manager_create(display);
protocols.data_control = wlr_data_control_manager_v1_create(display);
wlr_renderer_init_wl_display(renderer, display);

/* Order here is important:
* 1. init_desktop_apis() must come after wlr_compositor_create(),
* since Xwayland initialization depends on the compositor
* 2. input depends on output-layout
* 3. weston toy clients expect xdg-shell before wl_seat, i.e
* init_desktop_apis() should come before input */
output_layout = std::make_unique<wf::output_layout_t> (backend);
* init_desktop_apis() should come before input.
* 4. GTK expects primary selection early. */
compositor = wlr_compositor_create(display, renderer);

protocols.data_device = wlr_data_device_manager_create(display);
protocols.gtk_primary_selection =
wlr_gtk_primary_selection_device_manager_create(display);
protocols.primary_selection_v1 =
wlr_primary_selection_v1_device_manager_create(display);
protocols.data_control = wlr_data_control_manager_v1_create(display);

output_layout = std::make_unique<wf::output_layout_t> (backend);
init_desktop_apis();

/* Somehow GTK requires the tablet_v2 to be advertised pretty early */
protocols.tablet_v2 = wlr_tablet_v2_create(display);

input = std::make_unique<input_manager>();

protocols.screencopy = wlr_screencopy_manager_v1_create(display);
protocols.gamma_v1 = wlr_gamma_control_manager_v1_create(display);
protocols.linux_dmabuf = wlr_linux_dmabuf_v1_create(display, renderer);
protocols.export_dmabuf = wlr_export_dmabuf_manager_v1_create(display);
protocols.output_manager = wlr_xdg_output_manager_v1_create(display,
output_layout->get_handle());
Expand Down

0 comments on commit 708b7aa

Please sign in to comment.