Bug 1706624 [Wayland] Use wl_seat0 from Gtk, r=jhorak

Differential Revision: https://phabricator.services.mozilla.com/D112965
This commit is contained in:
stransky 2021-04-21 17:29:21 +00:00
parent 6a9dcf098b
commit 33c1175041
2 changed files with 25 additions and 10 deletions

View File

@ -13,6 +13,9 @@
#include "mozilla/StaticPrefs_widget.h"
#include "WidgetUtilsGtk.h"
struct _GdkSeat;
typedef struct _GdkSeat GdkSeat;
namespace mozilla {
namespace widget {
@ -98,7 +101,27 @@ void nsWaylandDisplay::SetDataDeviceManager(
mDataDeviceManager = aDataDeviceManager;
}
void nsWaylandDisplay::SetSeat(wl_seat* aSeat) { mSeat = aSeat; }
wl_seat* nsWaylandDisplay::GetSeat() {
GdkDisplay* gdkDisplay = gdk_display_get_default();
if (!gdkDisplay) {
return nullptr;
}
static auto sGdkDisplayGetDefaultSeat = (GdkSeat * (*)(GdkDisplay*))
dlsym(RTLD_DEFAULT, "gdk_display_get_default_seat");
if (!sGdkDisplayGetDefaultSeat) {
return nullptr;
}
static auto sGdkWaylandSeatGetWlSeat = (struct wl_seat * (*)(GdkSeat*))
dlsym(RTLD_DEFAULT, "gdk_wayland_seat_get_wl_seat");
if (!sGdkWaylandSeatGetWlSeat) {
return nullptr;
}
GdkSeat* gdkSeat = sGdkDisplayGetDefaultSeat(gdkDisplay);
return sGdkWaylandSeatGetWlSeat(gdkSeat);
}
void nsWaylandDisplay::SetPrimarySelectionDeviceManager(
gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager) {
@ -139,11 +162,6 @@ static void global_registry_handler(void* data, wl_registry* registry,
wl_proxy_set_queue((struct wl_proxy*)data_device_manager,
display->GetEventQueue());
display->SetDataDeviceManager(data_device_manager);
} else if (strcmp(interface, "wl_seat") == 0) {
auto* seat =
WaylandRegistryBind<wl_seat>(registry, id, &wl_seat_interface, 1);
wl_proxy_set_queue((struct wl_proxy*)seat, display->GetEventQueue());
display->SetSeat(seat);
} else if (strcmp(interface, "gtk_primary_selection_device_manager") == 0) {
auto* primary_selection_device_manager =
WaylandRegistryBind<gtk_primary_selection_device_manager>(
@ -279,7 +297,6 @@ nsWaylandDisplay::nsWaylandDisplay(wl_display* aDisplay, bool aLighWrapper)
mDataDeviceManager(nullptr),
mCompositor(nullptr),
mSubcompositor(nullptr),
mSeat(nullptr),
mShm(nullptr),
mSyncCallback(nullptr),
mPrimarySelectionDeviceManagerGtk(nullptr),

View File

@ -49,7 +49,7 @@ class nsWaylandDisplay {
wl_data_device_manager* GetDataDeviceManager(void) {
return mDataDeviceManager;
};
wl_seat* GetSeat(void) { return mSeat; };
wl_seat* GetSeat(void);
wl_shm* GetShm(void) { return mShm; };
gtk_primary_selection_device_manager* GetPrimarySelectionDeviceManagerGtk(
void) {
@ -70,7 +70,6 @@ class nsWaylandDisplay {
void SetCompositor(wl_compositor* aCompositor);
void SetSubcompositor(wl_subcompositor* aSubcompositor);
void SetDataDeviceManager(wl_data_device_manager* aDataDeviceManager);
void SetSeat(wl_seat* aSeat);
void SetPrimarySelectionDeviceManager(
gtk_primary_selection_device_manager* aPrimarySelectionDeviceManager);
void SetPrimarySelectionDeviceManager(
@ -89,7 +88,6 @@ class nsWaylandDisplay {
wl_data_device_manager* mDataDeviceManager;
wl_compositor* mCompositor;
wl_subcompositor* mSubcompositor;
wl_seat* mSeat;
wl_shm* mShm;
wl_callback* mSyncCallback;
gtk_primary_selection_device_manager* mPrimarySelectionDeviceManagerGtk;