Cleanup: remove 'struct' prefix from GHOST/Wayland types
Move struct members into sub-structs (wl/wp/xdg/xkb) to prevent naming collisions with the types & struct members.
This commit is contained in:
@@ -368,6 +368,15 @@ static void gwl_simple_buffer_set_from_string(GWL_SimpleBuffer *buffer, const ch
|
||||
#define EVDEV_OFFSET 8
|
||||
|
||||
struct GWL_Cursor {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_surface *surface_cursor = nullptr;
|
||||
wl_buffer *buffer = nullptr;
|
||||
wl_cursor_image image = {0};
|
||||
wl_cursor_theme *theme = nullptr;
|
||||
} wl;
|
||||
|
||||
bool visible = false;
|
||||
/**
|
||||
* When false, hide the hardware cursor, while the cursor is still considered to be `visible`,
|
||||
@@ -378,10 +387,6 @@ struct GWL_Cursor {
|
||||
bool is_hardware = true;
|
||||
/** When true, a custom image is used to display the cursor (stored in `wl_image`). */
|
||||
bool is_custom = false;
|
||||
wl_surface *wl_surface_cursor = nullptr;
|
||||
struct wl_buffer *wl_buffer = nullptr;
|
||||
wl_cursor_image wl_image = {0};
|
||||
wl_cursor_theme *wl_theme = nullptr;
|
||||
void *custom_data = nullptr;
|
||||
/** The size of `custom_data` in bytes. */
|
||||
size_t custom_data_size = 0;
|
||||
@@ -405,9 +410,17 @@ struct GWL_Cursor {
|
||||
* Since are no API's to access properties of the tool, store the values here.
|
||||
*/
|
||||
struct GWL_TabletTool {
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
/**
|
||||
* Tablets have a separate cursor to the 'pointer',
|
||||
* this surface is used for cursor drawing.
|
||||
*/
|
||||
wl_surface *surface_cursor = nullptr;
|
||||
} wl;
|
||||
|
||||
GWL_Seat *seat = nullptr;
|
||||
/** Tablets have a separate cursor to the 'pointer', this surface is used for cursor drawing. */
|
||||
wl_surface *wl_surface_cursor = nullptr;
|
||||
/** Used to delay clearing tablet focused wl_surface until the frame is handled. */
|
||||
bool proximity = false;
|
||||
|
||||
@@ -424,7 +437,12 @@ struct GWL_TabletTool {
|
||||
* Data storage used for clipboard paste & drag-and-drop.
|
||||
*/
|
||||
struct GWL_DataOffer {
|
||||
wl_data_offer *id = nullptr;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
wl_data_offer *id = nullptr;
|
||||
} wl;
|
||||
|
||||
std::unordered_set<std::string> types;
|
||||
|
||||
struct {
|
||||
@@ -453,7 +471,12 @@ struct GWL_DataOffer {
|
||||
* \{ */
|
||||
|
||||
struct GWL_DataSource {
|
||||
wl_data_source *wl_source = nullptr;
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_data_source *source = nullptr;
|
||||
} wl;
|
||||
|
||||
GWL_SimpleBuffer buffer_out;
|
||||
};
|
||||
|
||||
@@ -495,6 +518,16 @@ struct GWL_SeatStateGrab {
|
||||
* State of the pointing device (tablet or mouse).
|
||||
*/
|
||||
struct GWL_SeatStatePointer {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
/**
|
||||
* The wl_surface last used with this pointing device
|
||||
* (events with this pointing device will be sent here).
|
||||
*/
|
||||
wl_surface *surface_window = nullptr;
|
||||
} wl;
|
||||
|
||||
/**
|
||||
* High precision coordinates.
|
||||
*
|
||||
@@ -518,12 +551,6 @@ struct GWL_SeatStatePointer {
|
||||
/** The serial of the last used pointer or tablet. */
|
||||
uint32_t serial = 0;
|
||||
|
||||
/**
|
||||
* The wl_surface last used with this pointing device
|
||||
* (events with this pointing device will be sent here).
|
||||
*/
|
||||
wl_surface *wl_surface_window = nullptr;
|
||||
|
||||
GHOST_Buttons buttons = GHOST_Buttons();
|
||||
};
|
||||
|
||||
@@ -579,14 +606,18 @@ struct GWL_SeatStatePointerGesture_Pinch {
|
||||
* State of the keyboard (in #GWL_Seat).
|
||||
*/
|
||||
struct GWL_SeatStateKeyboard {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
/**
|
||||
* The wl_surface last used with this pointing device
|
||||
* (events with this pointing device will be sent here).
|
||||
*/
|
||||
wl_surface *surface_window = nullptr;
|
||||
} wl;
|
||||
|
||||
/** The serial of the last used pointer or tablet. */
|
||||
uint32_t serial = 0;
|
||||
|
||||
/**
|
||||
* The wl_surface last used with this pointing device
|
||||
* (events with this pointing device will be sent here).
|
||||
*/
|
||||
wl_surface *wl_surface_window = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -635,13 +666,22 @@ static void gwl_xdg_decor_system_destroy(GWL_Display *display, GWL_XDG_Decor_Sys
|
||||
}
|
||||
|
||||
struct GWL_PrimarySelection_DataOffer {
|
||||
zwp_primary_selection_offer_v1 *id = nullptr;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
zwp_primary_selection_offer_v1 *id = nullptr;
|
||||
} wp;
|
||||
|
||||
std::unordered_set<std::string> types;
|
||||
};
|
||||
|
||||
struct GWL_PrimarySelection_DataSource {
|
||||
zwp_primary_selection_source_v1 *wp_source = nullptr;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
zwp_primary_selection_source_v1 *source = nullptr;
|
||||
} wp;
|
||||
|
||||
GWL_SimpleBuffer buffer_out;
|
||||
};
|
||||
|
||||
@@ -660,7 +700,7 @@ static void gwl_primary_selection_discard_offer(GWL_PrimarySelection *primary)
|
||||
if (primary->data_offer == nullptr) {
|
||||
return;
|
||||
}
|
||||
zwp_primary_selection_offer_v1_destroy(primary->data_offer->id);
|
||||
zwp_primary_selection_offer_v1_destroy(primary->data_offer->wp.id);
|
||||
delete primary->data_offer;
|
||||
primary->data_offer = nullptr;
|
||||
}
|
||||
@@ -672,35 +712,76 @@ static void gwl_primary_selection_discard_source(GWL_PrimarySelection *primary)
|
||||
return;
|
||||
}
|
||||
gwl_simple_buffer_free_data(&data_source->buffer_out);
|
||||
if (data_source->wp_source) {
|
||||
zwp_primary_selection_source_v1_destroy(data_source->wp_source);
|
||||
if (data_source->wp.source) {
|
||||
zwp_primary_selection_source_v1_destroy(data_source->wp.source);
|
||||
}
|
||||
delete primary->data_source;
|
||||
primary->data_source = nullptr;
|
||||
}
|
||||
|
||||
struct GWL_Seat {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_seat *seat = nullptr;
|
||||
wl_pointer *pointer = nullptr;
|
||||
wl_touch *touch = nullptr;
|
||||
wl_keyboard *keyboard = nullptr;
|
||||
|
||||
wl_surface *surface_window_focus_dnd = nullptr;
|
||||
wl_data_device *data_device = nullptr;
|
||||
} wl;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
zwp_tablet_seat_v2 *tablet_seat = nullptr;
|
||||
|
||||
#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
|
||||
zwp_pointer_gesture_hold_v1 *pointer_gesture_hold = nullptr;
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
|
||||
zwp_pointer_gesture_pinch_v1 *pointer_gesture_pinch = nullptr;
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
|
||||
zwp_pointer_gesture_swipe_v1 *pointer_gesture_swipe = nullptr;
|
||||
#endif
|
||||
|
||||
zwp_relative_pointer_v1 *relative_pointer = nullptr;
|
||||
zwp_locked_pointer_v1 *locked_pointer = nullptr;
|
||||
zwp_confined_pointer_v1 *confined_pointer = nullptr;
|
||||
|
||||
zwp_primary_selection_device_v1 *primary_selection_device = nullptr;
|
||||
|
||||
/** All currently active tablet tools (needed for changing the cursor). */
|
||||
std::unordered_set<zwp_tablet_tool_v2 *> tablet_tools;
|
||||
} wp;
|
||||
|
||||
/** XKB native types. */
|
||||
struct {
|
||||
xkb_context *context = nullptr;
|
||||
|
||||
xkb_state *state = nullptr;
|
||||
/**
|
||||
* Keep a state with no modifiers active, use for symbol lookups.
|
||||
*/
|
||||
xkb_state *state_empty = nullptr;
|
||||
|
||||
/**
|
||||
* Keep a state with shift enabled, use to access predictable number access for AZERTY keymaps.
|
||||
* If shift is not supported by the key-map, this is set to nullptr.
|
||||
*/
|
||||
xkb_state *state_empty_with_shift = nullptr;
|
||||
/**
|
||||
* Keep a state with number-lock enabled, use to access predictable key-pad symbols.
|
||||
* If number-lock is not supported by the key-map, this is set to nullptr.
|
||||
*/
|
||||
xkb_state *state_empty_with_numlock = nullptr;
|
||||
|
||||
} xkb;
|
||||
|
||||
GHOST_SystemWayland *system = nullptr;
|
||||
|
||||
std::string name;
|
||||
struct wl_seat *wl_seat = nullptr;
|
||||
struct wl_pointer *wl_pointer = nullptr;
|
||||
struct wl_touch *wl_touch = nullptr;
|
||||
struct wl_keyboard *wl_keyboard = nullptr;
|
||||
zwp_tablet_seat_v2 *wp_tablet_seat = nullptr;
|
||||
|
||||
#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
|
||||
zwp_pointer_gesture_hold_v1 *wp_pointer_gesture_hold = nullptr;
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
|
||||
zwp_pointer_gesture_pinch_v1 *wp_pointer_gesture_pinch = nullptr;
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
|
||||
zwp_pointer_gesture_swipe_v1 *wp_pointer_gesture_swipe = nullptr;
|
||||
#endif
|
||||
|
||||
/** All currently active tablet tools (needed for changing the cursor). */
|
||||
std::unordered_set<zwp_tablet_tool_v2 *> tablet_tools;
|
||||
|
||||
/** Use to check if the last cursor input was tablet or pointer. */
|
||||
uint32_t cursor_source_serial = 0;
|
||||
@@ -722,29 +803,6 @@ struct GWL_Seat {
|
||||
|
||||
GWL_Cursor cursor;
|
||||
|
||||
zwp_relative_pointer_v1 *wp_relative_pointer = nullptr;
|
||||
zwp_locked_pointer_v1 *wp_locked_pointer = nullptr;
|
||||
zwp_confined_pointer_v1 *wp_confined_pointer = nullptr;
|
||||
|
||||
struct xkb_context *xkb_context = nullptr;
|
||||
|
||||
struct xkb_state *xkb_state = nullptr;
|
||||
/**
|
||||
* Keep a state with no modifiers active, use for symbol lookups.
|
||||
*/
|
||||
struct xkb_state *xkb_state_empty = nullptr;
|
||||
|
||||
/**
|
||||
* Keep a state with shift enabled, use to access predictable number access for AZERTY keymaps.
|
||||
* If shift is not supported by the key-map, this is set to nullptr.
|
||||
*/
|
||||
struct xkb_state *xkb_state_empty_with_shift = nullptr;
|
||||
/**
|
||||
* Keep a state with number-lock enabled, use to access predictable key-pad symbols.
|
||||
* If number-lock is not supported by the key-map, this is set to nullptr.
|
||||
*/
|
||||
struct xkb_state *xkb_state_empty_with_numlock = nullptr;
|
||||
|
||||
#ifdef USE_NON_LATIN_KB_WORKAROUND
|
||||
bool xkb_use_non_latin_workaround = false;
|
||||
#endif
|
||||
@@ -773,9 +831,6 @@ struct GWL_Seat {
|
||||
GHOST_ITimerTask *timer = nullptr;
|
||||
} key_repeat;
|
||||
|
||||
wl_surface *wl_surface_window_focus_dnd = nullptr;
|
||||
|
||||
struct wl_data_device *wl_data_device = nullptr;
|
||||
/** Drag & Drop. */
|
||||
GWL_DataOffer *data_offer_dnd = nullptr;
|
||||
std::mutex data_offer_dnd_mutex;
|
||||
@@ -787,7 +842,6 @@ struct GWL_Seat {
|
||||
GWL_DataSource *data_source = nullptr;
|
||||
std::mutex data_source_mutex;
|
||||
|
||||
zwp_primary_selection_device_v1 *wp_primary_selection_device = nullptr;
|
||||
GWL_PrimarySelection primary_selection;
|
||||
|
||||
/**
|
||||
@@ -868,6 +922,37 @@ static void gwl_seat_key_repeat_timer_remove(GWL_Seat *seat)
|
||||
struct GWL_RegistryEntry;
|
||||
|
||||
struct GWL_Display {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_registry *registry = nullptr;
|
||||
wl_display *display = nullptr;
|
||||
wl_compositor *compositor = nullptr;
|
||||
wl_shm *shm = nullptr;
|
||||
|
||||
/* Managers. */
|
||||
wl_data_device_manager *data_device_manager = nullptr;
|
||||
} wl;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
/* Managers. */
|
||||
zwp_tablet_manager_v2 *tablet_manager = nullptr;
|
||||
zwp_relative_pointer_manager_v1 *relative_pointer_manager = nullptr;
|
||||
zwp_primary_selection_device_manager_v1 *primary_selection_device_manager = nullptr;
|
||||
wp_fractional_scale_manager_v1 *fractional_scale_manager = nullptr;
|
||||
wp_viewporter *viewporter = nullptr;
|
||||
zwp_pointer_constraints_v1 *pointer_constraints = nullptr;
|
||||
zwp_pointer_gestures_v1 *pointer_gestures = nullptr;
|
||||
} wp;
|
||||
|
||||
/** Wayland XDG types. */
|
||||
struct {
|
||||
/* Managers. */
|
||||
zxdg_output_manager_v1 *output_manager = nullptr;
|
||||
xdg_activation_v1 *activation_manager = nullptr;
|
||||
} xdg;
|
||||
|
||||
GHOST_SystemWayland *system = nullptr;
|
||||
|
||||
/**
|
||||
@@ -879,18 +964,12 @@ struct GWL_Display {
|
||||
/** Registry entries, kept to allow updating & removal at run-time. */
|
||||
GWL_RegistryEntry *registry_entry = nullptr;
|
||||
|
||||
struct wl_registry *wl_registry = nullptr;
|
||||
struct wl_display *wl_display = nullptr;
|
||||
struct wl_compositor *wl_compositor = nullptr;
|
||||
|
||||
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
|
||||
GWL_LibDecor_System *libdecor = nullptr;
|
||||
bool libdecor_required = false;
|
||||
#endif
|
||||
GWL_XDG_Decor_System *xdg_decor = nullptr;
|
||||
|
||||
zxdg_output_manager_v1 *xdg_output_manager = nullptr;
|
||||
struct wl_shm *wl_shm = nullptr;
|
||||
std::vector<GWL_Output *> outputs;
|
||||
std::vector<GWL_Seat *> seats;
|
||||
/**
|
||||
@@ -906,17 +985,6 @@ struct GWL_Display {
|
||||
*/
|
||||
int seats_active_index = 0;
|
||||
|
||||
/* Managers. */
|
||||
struct wl_data_device_manager *wl_data_device_manager = nullptr;
|
||||
zwp_tablet_manager_v2 *wp_tablet_manager = nullptr;
|
||||
zwp_relative_pointer_manager_v1 *wp_relative_pointer_manager = nullptr;
|
||||
zwp_primary_selection_device_manager_v1 *wp_primary_selection_device_manager = nullptr;
|
||||
xdg_activation_v1 *xdg_activation_manager = nullptr;
|
||||
wp_fractional_scale_manager_v1 *wp_fractional_scale_manager = nullptr;
|
||||
struct wp_viewporter *wp_viewporter = nullptr;
|
||||
zwp_pointer_constraints_v1 *wp_pointer_constraints = nullptr;
|
||||
zwp_pointer_gestures_v1 *wp_pointer_gestures = nullptr;
|
||||
|
||||
/* Threaded event handling. */
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
/**
|
||||
@@ -958,16 +1026,16 @@ static void gwl_display_destroy(GWL_Display *display)
|
||||
{
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
if (display->events_pthread) {
|
||||
ghost_wl_display_lock_without_input(display->wl_display, display->system->server_mutex);
|
||||
ghost_wl_display_lock_without_input(display->wl.display, display->system->server_mutex);
|
||||
display->events_pthread_is_active = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* For typical WAYLAND use this will always be set.
|
||||
* However when WAYLAND isn't running, this will early-exit and be null. */
|
||||
if (display->wl_registry) {
|
||||
wl_registry_destroy(display->wl_registry);
|
||||
display->wl_registry = nullptr;
|
||||
if (display->wl.registry) {
|
||||
wl_registry_destroy(display->wl.registry);
|
||||
display->wl.registry = nullptr;
|
||||
}
|
||||
|
||||
/* Unregister items in reverse order. */
|
||||
@@ -990,7 +1058,7 @@ static void gwl_display_destroy(GWL_Display *display)
|
||||
}
|
||||
|
||||
if (eglGetDisplay) {
|
||||
::eglTerminate(eglGetDisplay(EGLNativeDisplayType(display->wl_display)));
|
||||
::eglTerminate(eglGetDisplay(EGLNativeDisplayType(display->wl.display)));
|
||||
}
|
||||
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
@@ -1011,8 +1079,8 @@ static void gwl_display_destroy(GWL_Display *display)
|
||||
|
||||
#endif /* USE_EVENT_BACKGROUND_THREAD */
|
||||
|
||||
if (display->wl_display) {
|
||||
wl_display_disconnect(display->wl_display);
|
||||
if (display->wl.display) {
|
||||
wl_display_disconnect(display->wl.display);
|
||||
}
|
||||
|
||||
delete display;
|
||||
@@ -1870,7 +1938,7 @@ static void keyboard_depressed_state_key_event(GWL_Seat *seat,
|
||||
static void keyboard_depressed_state_push_events_from_change(
|
||||
GWL_Seat *seat, const GWL_KeyboardDepressedState &key_depressed_prev)
|
||||
{
|
||||
GHOST_IWindow *win = ghost_wl_surface_user_data(seat->keyboard.wl_surface_window);
|
||||
GHOST_IWindow *win = ghost_wl_surface_user_data(seat->keyboard.wl.surface_window);
|
||||
GHOST_SystemWayland *system = seat->system;
|
||||
|
||||
/* Separate key up and down into separate passes so key down events always come after key up.
|
||||
@@ -1954,7 +2022,7 @@ static void relative_pointer_handle_relative_motion(
|
||||
const wl_fixed_t /*dy_unaccel*/)
|
||||
{
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
CLOG_INFO(LOG, 2, "relative_motion");
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const wl_fixed_t xy_next[2] = {
|
||||
@@ -1986,7 +2054,7 @@ static CLG_LogRef LOG_WL_DATA_SOURCE = {"ghost.wl.handle.data_source"};
|
||||
static void dnd_events(const GWL_Seat *const seat, const GHOST_TEventType event)
|
||||
{
|
||||
/* NOTE: `seat->data_offer_dnd_mutex` must already be locked. */
|
||||
if (wl_surface *wl_surface_focus = seat->wl_surface_window_focus_dnd) {
|
||||
if (wl_surface *wl_surface_focus = seat->wl.surface_window_focus_dnd) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, seat->data_offer_dnd->dnd.xy)};
|
||||
const uint64_t time = seat->system->getMilliSeconds();
|
||||
@@ -2086,7 +2154,7 @@ static char *read_buffer_from_data_offer(GWL_DataOffer *data_offer,
|
||||
int pipefd[2];
|
||||
const bool pipefd_ok = pipe(pipefd) == 0;
|
||||
if (pipefd_ok) {
|
||||
wl_data_offer_receive(data_offer->id, mime_receive, pipefd[1]);
|
||||
wl_data_offer_receive(data_offer->wl.id, mime_receive, pipefd[1]);
|
||||
close(pipefd[1]);
|
||||
}
|
||||
else {
|
||||
@@ -2117,7 +2185,7 @@ static char *read_buffer_from_primary_selection_offer(GWL_PrimarySelection_DataO
|
||||
int pipefd[2];
|
||||
const bool pipefd_ok = pipe(pipefd) == 0;
|
||||
if (pipefd_ok) {
|
||||
zwp_primary_selection_offer_v1_receive(data_offer->id, mime_receive, pipefd[1]);
|
||||
zwp_primary_selection_offer_v1_receive(data_offer->wp.id, mime_receive, pipefd[1]);
|
||||
close(pipefd[1]);
|
||||
}
|
||||
else {
|
||||
@@ -2179,8 +2247,8 @@ static void data_source_handle_cancelled(void *data, wl_data_source *wl_data_sou
|
||||
CLOG_INFO(LOG, 2, "cancelled");
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
GWL_DataSource *data_source = seat->data_source;
|
||||
if (seat->data_source->wl_source == wl_data_source) {
|
||||
data_source->wl_source = nullptr;
|
||||
if (seat->data_source->wl.source == wl_data_source) {
|
||||
data_source->wl.source = nullptr;
|
||||
}
|
||||
|
||||
wl_data_source_destroy(wl_data_source);
|
||||
@@ -2296,7 +2364,7 @@ static void data_device_handle_data_offer(void * /*data*/,
|
||||
CLOG_INFO(LOG, 2, "data_offer");
|
||||
|
||||
GWL_DataOffer *data_offer = new GWL_DataOffer;
|
||||
data_offer->id = id;
|
||||
data_offer->wl.id = id;
|
||||
wl_data_offer_add_listener(id, &data_offer_listener, data_offer);
|
||||
}
|
||||
|
||||
@@ -2335,7 +2403,7 @@ static void data_device_handle_enter(void *data,
|
||||
wl_data_offer_accept(id, serial, type);
|
||||
}
|
||||
|
||||
seat->wl_surface_window_focus_dnd = wl_surface;
|
||||
seat->wl.surface_window_focus_dnd = wl_surface;
|
||||
|
||||
seat->system->seat_active_set(seat);
|
||||
|
||||
@@ -2350,10 +2418,10 @@ static void data_device_handle_leave(void *data, wl_data_device * /*wl_data_devi
|
||||
CLOG_INFO(LOG, 2, "leave");
|
||||
|
||||
dnd_events(seat, GHOST_kEventDraggingExited);
|
||||
seat->wl_surface_window_focus_dnd = nullptr;
|
||||
seat->wl.surface_window_focus_dnd = nullptr;
|
||||
|
||||
if (seat->data_offer_dnd && !seat->data_offer_dnd->dnd.in_use) {
|
||||
wl_data_offer_destroy(seat->data_offer_dnd->id);
|
||||
wl_data_offer_destroy(seat->data_offer_dnd->wl.id);
|
||||
delete seat->data_offer_dnd;
|
||||
seat->data_offer_dnd = nullptr;
|
||||
}
|
||||
@@ -2413,8 +2481,8 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic
|
||||
|
||||
CLOG_INFO(LOG, 2, "drop_read_uris mime_receive=%s, data=%s", mime_receive, data.c_str());
|
||||
|
||||
wl_data_offer_finish(data_offer->id);
|
||||
wl_data_offer_destroy(data_offer->id);
|
||||
wl_data_offer_finish(data_offer->wl.id);
|
||||
wl_data_offer_destroy(data_offer->wl.id);
|
||||
|
||||
if (seat->data_offer_dnd == data_offer) {
|
||||
seat->data_offer_dnd = nullptr;
|
||||
@@ -2484,7 +2552,7 @@ static void data_device_handle_drop(void *data, wl_data_device * /*wl_data_devic
|
||||
/* Pass in `seat->wl_surface_window_focus_dnd` instead of accessing it from `seat` since the
|
||||
* leave callback (#data_device_handle_leave) will clear the value once this function starts. */
|
||||
std::thread read_thread(
|
||||
read_uris_fn, seat, data_offer, seat->wl_surface_window_focus_dnd, mime_receive);
|
||||
read_uris_fn, seat, data_offer, seat->wl.surface_window_focus_dnd, mime_receive);
|
||||
read_thread.detach();
|
||||
}
|
||||
|
||||
@@ -2500,7 +2568,7 @@ static void data_device_handle_selection(void *data,
|
||||
|
||||
/* Delete old data offer. */
|
||||
if (data_offer != nullptr) {
|
||||
wl_data_offer_destroy(data_offer->id);
|
||||
wl_data_offer_destroy(data_offer->wl.id);
|
||||
delete data_offer;
|
||||
data_offer = nullptr;
|
||||
seat->data_offer_copy_paste = nullptr;
|
||||
@@ -2543,9 +2611,9 @@ static void cursor_buffer_handle_release(void *data, wl_buffer *wl_buffer)
|
||||
GWL_Cursor *cursor = static_cast<GWL_Cursor *>(data);
|
||||
wl_buffer_destroy(wl_buffer);
|
||||
|
||||
if (wl_buffer == cursor->wl_buffer) {
|
||||
if (wl_buffer == cursor->wl.buffer) {
|
||||
/* The mapped buffer was from a custom cursor. */
|
||||
cursor->wl_buffer = nullptr;
|
||||
cursor->wl.buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2581,8 +2649,8 @@ static bool update_cursor_scale(GWL_Cursor &cursor,
|
||||
if (!cursor.is_custom) {
|
||||
wl_surface_set_buffer_scale(wl_surface_cursor, scale);
|
||||
}
|
||||
wl_cursor_theme_destroy(cursor.wl_theme);
|
||||
cursor.wl_theme = wl_cursor_theme_load(
|
||||
wl_cursor_theme_destroy(cursor.wl.theme);
|
||||
cursor.wl.theme = wl_cursor_theme_load(
|
||||
cursor.theme_name.c_str(), scale * cursor.theme_size, shm);
|
||||
return true;
|
||||
}
|
||||
@@ -2663,7 +2731,7 @@ static void pointer_handle_enter(void *data,
|
||||
* do this to avoid any possible problems as it's harmless. */
|
||||
seat->pointer_scroll = GWL_SeatStatePointerScroll{};
|
||||
|
||||
seat->pointer.wl_surface_window = wl_surface;
|
||||
seat->pointer.wl.surface_window = wl_surface;
|
||||
|
||||
seat->system->seat_active_set(seat);
|
||||
|
||||
@@ -2683,7 +2751,7 @@ static void pointer_handle_leave(void *data,
|
||||
wl_surface *wl_surface)
|
||||
{
|
||||
/* First clear the `pointer.wl_surface`, since the window won't exist when closing the window. */
|
||||
static_cast<GWL_Seat *>(data)->pointer.wl_surface_window = nullptr;
|
||||
static_cast<GWL_Seat *>(data)->pointer.wl.surface_window = nullptr;
|
||||
if (!ghost_wl_surface_own_with_null_check(wl_surface)) {
|
||||
CLOG_INFO(LOG, 2, "leave (skipped)");
|
||||
return;
|
||||
@@ -2701,7 +2769,7 @@ static void pointer_handle_motion(void *data,
|
||||
seat->pointer.xy[0] = surface_x;
|
||||
seat->pointer.xy[1] = surface_y;
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
CLOG_INFO(LOG, 2, "motion");
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, seat->pointer.xy)};
|
||||
@@ -2764,7 +2832,7 @@ static void pointer_handle_button(void *data,
|
||||
seat->data_source_serial = serial;
|
||||
seat->pointer.buttons.set(ebutton, state == WL_POINTER_BUTTON_STATE_PRESSED);
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventButton(
|
||||
seat->system->getMilliSeconds(), etype, win, ebutton, GHOST_TABLET_DATA_NONE));
|
||||
@@ -2815,7 +2883,7 @@ static void pointer_handle_frame(void *data, wl_pointer * /*wl_pointer*/)
|
||||
|
||||
/* Discrete X axis currently unsupported. */
|
||||
if (seat->pointer_scroll.discrete_xy[1]) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int32_t discrete = seat->pointer_scroll.discrete_xy[1];
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventWheel(
|
||||
@@ -2826,7 +2894,7 @@ static void pointer_handle_frame(void *data, wl_pointer * /*wl_pointer*/)
|
||||
}
|
||||
|
||||
if (seat->pointer_scroll.smooth_xy[0] || seat->pointer_scroll.smooth_xy[1]) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, seat->pointer.xy)};
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventTrackpad(
|
||||
@@ -2988,7 +3056,7 @@ static void gesture_pinch_handle_begin(void *data,
|
||||
seat->pointer_gesture_pinch = GWL_SeatStatePointerGesture_Pinch{};
|
||||
|
||||
GHOST_WindowWayland *win = nullptr;
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
}
|
||||
|
||||
@@ -3049,7 +3117,7 @@ static void gesture_pinch_handle_update(void *data,
|
||||
|
||||
GHOST_WindowWayland *win = nullptr;
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
}
|
||||
|
||||
@@ -3309,10 +3377,10 @@ static void tablet_tool_handle_removed(void *data, zwp_tablet_tool_v2 *zwp_table
|
||||
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
|
||||
GWL_Seat *seat = tablet_tool->seat;
|
||||
|
||||
if (tablet_tool->wl_surface_cursor) {
|
||||
wl_surface_destroy(tablet_tool->wl_surface_cursor);
|
||||
if (tablet_tool->wl.surface_cursor) {
|
||||
wl_surface_destroy(tablet_tool->wl.surface_cursor);
|
||||
}
|
||||
seat->tablet_tools.erase(zwp_tablet_tool_v2);
|
||||
seat->wp.tablet_tools.erase(zwp_tablet_tool_v2);
|
||||
|
||||
delete tablet_tool;
|
||||
}
|
||||
@@ -3333,7 +3401,7 @@ static void tablet_tool_handle_proximity_in(void *data,
|
||||
|
||||
GWL_Seat *seat = tablet_tool->seat;
|
||||
seat->cursor_source_serial = serial;
|
||||
seat->tablet.wl_surface_window = wl_surface;
|
||||
seat->tablet.wl.surface_window = wl_surface;
|
||||
seat->tablet.serial = serial;
|
||||
|
||||
seat->data_source_serial = serial;
|
||||
@@ -3348,7 +3416,7 @@ static void tablet_tool_handle_proximity_in(void *data,
|
||||
/* In case pressure isn't supported. */
|
||||
td.Pressure = 1.0f;
|
||||
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(seat->tablet.wl_surface_window);
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(seat->tablet.wl.surface_window);
|
||||
|
||||
win->activate();
|
||||
|
||||
@@ -3378,7 +3446,7 @@ static void tablet_tool_handle_down(void *data,
|
||||
seat->data_source_serial = serial;
|
||||
seat->tablet.buttons.set(ebutton, true);
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventButton(
|
||||
seat->system->getMilliSeconds(), etype, win, ebutton, tablet_tool->data));
|
||||
@@ -3396,7 +3464,7 @@ static void tablet_tool_handle_up(void *data, zwp_tablet_tool_v2 * /*zwp_tablet_
|
||||
|
||||
seat->tablet.buttons.set(ebutton, false);
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventButton(
|
||||
seat->system->getMilliSeconds(), etype, win, ebutton, tablet_tool->data));
|
||||
@@ -3481,7 +3549,7 @@ static void tablet_tool_handle_wheel(void *data,
|
||||
|
||||
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(data);
|
||||
GWL_Seat *seat = tablet_tool->seat;
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(
|
||||
new GHOST_EventWheel(seat->system->getMilliSeconds(), win, clicks));
|
||||
@@ -3524,7 +3592,7 @@ static void tablet_tool_handle_button(void *data,
|
||||
seat->data_source_serial = serial;
|
||||
seat->tablet.buttons.set(ebutton, state == WL_POINTER_BUTTON_STATE_PRESSED);
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventButton(
|
||||
seat->system->getMilliSeconds(), etype, win, ebutton, tablet_tool->data));
|
||||
@@ -3540,7 +3608,7 @@ static void tablet_tool_handle_frame(void *data,
|
||||
GWL_Seat *seat = tablet_tool->seat;
|
||||
|
||||
/* No need to check the surfaces origin, it's already known to be owned by GHOST. */
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->tablet.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
const int event_xy[2] = {WL_FIXED_TO_INT_FOR_WINDOW_V2(win, seat->tablet.xy)};
|
||||
seat->system->pushEvent_maybe_pending(new GHOST_EventCursor(seat->system->getMilliSeconds(),
|
||||
@@ -3554,7 +3622,7 @@ static void tablet_tool_handle_frame(void *data,
|
||||
}
|
||||
|
||||
if (tablet_tool->proximity == false) {
|
||||
seat->tablet.wl_surface_window = nullptr;
|
||||
seat->tablet.wl.surface_window = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3609,14 +3677,14 @@ static void tablet_seat_handle_tool_added(void *data,
|
||||
tablet_tool->seat = seat;
|
||||
|
||||
/* Every tool has its own cursor wl_surface. */
|
||||
tablet_tool->wl_surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
|
||||
ghost_wl_surface_tag_cursor_tablet(tablet_tool->wl_surface_cursor);
|
||||
tablet_tool->wl.surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
|
||||
ghost_wl_surface_tag_cursor_tablet(tablet_tool->wl.surface_cursor);
|
||||
|
||||
wl_surface_add_listener(tablet_tool->wl_surface_cursor, &cursor_surface_listener, (void *)seat);
|
||||
wl_surface_add_listener(tablet_tool->wl.surface_cursor, &cursor_surface_listener, (void *)seat);
|
||||
|
||||
zwp_tablet_tool_v2_add_listener(id, &tablet_tool_listner, tablet_tool);
|
||||
|
||||
seat->tablet_tools.insert(id);
|
||||
seat->wp.tablet_tools.insert(id);
|
||||
}
|
||||
|
||||
static void tablet_seat_handle_pad_added(void * /*data*/,
|
||||
@@ -3664,7 +3732,7 @@ static void keyboard_handle_keymap(void *data,
|
||||
}
|
||||
|
||||
xkb_keymap *keymap = xkb_keymap_new_from_string(
|
||||
seat->xkb_context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
seat->xkb.context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
munmap(map_str, size);
|
||||
close(fd);
|
||||
|
||||
@@ -3676,46 +3744,46 @@ static void keyboard_handle_keymap(void *data,
|
||||
CLOG_INFO(LOG, 2, "keymap");
|
||||
|
||||
/* In practice we can assume `xkb_state_new` always succeeds. */
|
||||
xkb_state_unref(seat->xkb_state);
|
||||
seat->xkb_state = xkb_state_new(keymap);
|
||||
xkb_state_unref(seat->xkb.state);
|
||||
seat->xkb.state = xkb_state_new(keymap);
|
||||
|
||||
xkb_state_unref(seat->xkb_state_empty);
|
||||
seat->xkb_state_empty = xkb_state_new(keymap);
|
||||
xkb_state_unref(seat->xkb.state_empty);
|
||||
seat->xkb.state_empty = xkb_state_new(keymap);
|
||||
|
||||
for (int i = 0; i < MOD_INDEX_NUM; i++) {
|
||||
const GWL_ModifierInfo &mod_info = g_modifier_info_table[i];
|
||||
seat->xkb_keymap_mod_index[i] = xkb_keymap_mod_get_index(keymap, mod_info.xkb_id);
|
||||
}
|
||||
|
||||
xkb_state_unref(seat->xkb_state_empty_with_shift);
|
||||
seat->xkb_state_empty_with_shift = nullptr;
|
||||
xkb_state_unref(seat->xkb.state_empty_with_shift);
|
||||
seat->xkb.state_empty_with_shift = nullptr;
|
||||
{
|
||||
const xkb_mod_index_t mod_shift = seat->xkb_keymap_mod_index[MOD_INDEX_SHIFT];
|
||||
if (mod_shift != XKB_MOD_INVALID) {
|
||||
seat->xkb_state_empty_with_shift = xkb_state_new(keymap);
|
||||
xkb_state_update_mask(seat->xkb_state_empty_with_shift, (1 << mod_shift), 0, 0, 0, 0, 0);
|
||||
seat->xkb.state_empty_with_shift = xkb_state_new(keymap);
|
||||
xkb_state_update_mask(seat->xkb.state_empty_with_shift, (1 << mod_shift), 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
xkb_state_unref(seat->xkb_state_empty_with_numlock);
|
||||
seat->xkb_state_empty_with_numlock = nullptr;
|
||||
xkb_state_unref(seat->xkb.state_empty_with_numlock);
|
||||
seat->xkb.state_empty_with_numlock = nullptr;
|
||||
{
|
||||
const xkb_mod_index_t mod2 = xkb_keymap_mod_get_index(keymap, XKB_MOD_NAME_NUM);
|
||||
const xkb_mod_index_t num = xkb_keymap_mod_get_index(keymap, "NumLock");
|
||||
if (num != XKB_MOD_INVALID && mod2 != XKB_MOD_INVALID) {
|
||||
seat->xkb_state_empty_with_numlock = xkb_state_new(keymap);
|
||||
seat->xkb.state_empty_with_numlock = xkb_state_new(keymap);
|
||||
xkb_state_update_mask(
|
||||
seat->xkb_state_empty_with_numlock, (1 << mod2), 0, (1 << num), 0, 0, 0);
|
||||
seat->xkb.state_empty_with_numlock, (1 << mod2), 0, (1 << num), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_NON_LATIN_KB_WORKAROUND
|
||||
seat->xkb_use_non_latin_workaround = false;
|
||||
if (seat->xkb_state_empty_with_shift) {
|
||||
if (seat->xkb.state_empty_with_shift) {
|
||||
seat->xkb_use_non_latin_workaround = true;
|
||||
for (xkb_keycode_t key_code = KEY_1 + EVDEV_OFFSET; key_code <= KEY_0 + EVDEV_OFFSET;
|
||||
key_code++) {
|
||||
const xkb_keysym_t sym_test = xkb_state_key_get_one_sym(seat->xkb_state_empty_with_shift,
|
||||
const xkb_keysym_t sym_test = xkb_state_key_get_one_sym(seat->xkb.state_empty_with_shift,
|
||||
key_code);
|
||||
if (!(sym_test >= XKB_KEY_0 && sym_test <= XKB_KEY_9)) {
|
||||
seat->xkb_use_non_latin_workaround = false;
|
||||
@@ -3750,7 +3818,7 @@ static void keyboard_handle_enter(void *data,
|
||||
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
seat->keyboard.serial = serial;
|
||||
seat->keyboard.wl_surface_window = wl_surface;
|
||||
seat->keyboard.wl.surface_window = wl_surface;
|
||||
|
||||
seat->system->seat_active_set(seat);
|
||||
|
||||
@@ -3764,7 +3832,7 @@ static void keyboard_handle_enter(void *data,
|
||||
WL_ARRAY_FOR_EACH (key, keys) {
|
||||
const xkb_keycode_t key_code = *key + EVDEV_OFFSET;
|
||||
CLOG_INFO(LOG, 2, "enter (key_held=%d)", int(key_code));
|
||||
const xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->xkb_state, key_code);
|
||||
const xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->xkb.state, key_code);
|
||||
const GHOST_TKey gkey = xkb_map_gkey_or_scan_code(sym, *key);
|
||||
if (gkey != GHOST_kKeyUnknown) {
|
||||
keyboard_depressed_state_key_event(seat, gkey, GHOST_kEventKeyDown);
|
||||
@@ -3791,7 +3859,7 @@ static void keyboard_handle_leave(void *data,
|
||||
CLOG_INFO(LOG, 2, "leave");
|
||||
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
seat->keyboard.wl_surface_window = nullptr;
|
||||
seat->keyboard.wl.surface_window = nullptr;
|
||||
|
||||
{
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
@@ -3894,9 +3962,9 @@ static void keyboard_handle_key(void *data,
|
||||
const xkb_keycode_t key_code = key + EVDEV_OFFSET;
|
||||
|
||||
const xkb_keysym_t sym = xkb_state_key_get_one_sym_without_modifiers(
|
||||
seat->xkb_state_empty,
|
||||
seat->xkb_state_empty_with_numlock,
|
||||
seat->xkb_state_empty_with_shift,
|
||||
seat->xkb.state_empty,
|
||||
seat->xkb.state_empty_with_numlock,
|
||||
seat->xkb.state_empty_with_shift,
|
||||
#ifdef USE_NON_LATIN_KB_WORKAROUND
|
||||
seat->xkb_use_non_latin_workaround,
|
||||
#else
|
||||
@@ -3940,7 +4008,7 @@ static void keyboard_handle_key(void *data,
|
||||
/* Releasing the key that was held always cancels. */
|
||||
timer_action = CANCEL;
|
||||
}
|
||||
else if (xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb_state), key_code)) {
|
||||
else if (xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb.state), key_code)) {
|
||||
if (etype == GHOST_kEventKeyDown) {
|
||||
/* Any other key-down always cancels (and may start its own repeat timer). */
|
||||
timer_action = CANCEL;
|
||||
@@ -3978,14 +4046,14 @@ static void keyboard_handle_key(void *data,
|
||||
const GHOST_TKey gkey = xkb_map_gkey_or_scan_code(sym, key);
|
||||
char utf8_buf[sizeof(GHOST_TEventKeyData::utf8_buf)] = {'\0'};
|
||||
if (etype == GHOST_kEventKeyDown) {
|
||||
xkb_state_key_get_utf8(seat->xkb_state, key_code, utf8_buf, sizeof(utf8_buf));
|
||||
xkb_state_key_get_utf8(seat->xkb.state, key_code, utf8_buf, sizeof(utf8_buf));
|
||||
}
|
||||
|
||||
seat->data_source_serial = serial;
|
||||
|
||||
keyboard_depressed_state_key_event(seat, gkey, etype);
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat->keyboard.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->keyboard.wl.surface_window) {
|
||||
GHOST_IWindow *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
seat->system->pushEvent_maybe_pending(
|
||||
new GHOST_EventKey(seat->system->getMilliSeconds(), etype, win, gkey, false, utf8_buf));
|
||||
@@ -3995,7 +4063,7 @@ static void keyboard_handle_key(void *data,
|
||||
if (key_repeat_payload == nullptr) {
|
||||
/* Start timer for repeating key, if applicable. */
|
||||
if ((seat->key_repeat.rate > 0) && (etype == GHOST_kEventKeyDown) &&
|
||||
xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb_state), key_code))
|
||||
xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb.state), key_code))
|
||||
{
|
||||
key_repeat_payload = new GWL_KeyRepeatPlayload();
|
||||
key_repeat_payload->seat = seat;
|
||||
@@ -4009,12 +4077,12 @@ static void keyboard_handle_key(void *data,
|
||||
GWL_KeyRepeatPlayload *payload = static_cast<GWL_KeyRepeatPlayload *>(task->getUserData());
|
||||
|
||||
GWL_Seat *seat = payload->seat;
|
||||
if (wl_surface *wl_surface_focus = seat->keyboard.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->keyboard.wl.surface_window) {
|
||||
GHOST_IWindow *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
GHOST_SystemWayland *system = seat->system;
|
||||
/* Calculate this value every time in case modifier keys are pressed. */
|
||||
char utf8_buf[sizeof(GHOST_TEventKeyData::utf8_buf)] = {'\0'};
|
||||
xkb_state_key_get_utf8(seat->xkb_state, payload->key_code, utf8_buf, sizeof(utf8_buf));
|
||||
xkb_state_key_get_utf8(seat->xkb.state, payload->key_code, utf8_buf, sizeof(utf8_buf));
|
||||
system->pushEvent_maybe_pending(new GHOST_EventKey(system->getMilliSeconds(),
|
||||
GHOST_kEventKeyDown,
|
||||
win,
|
||||
@@ -4045,7 +4113,7 @@ static void keyboard_handle_modifiers(void *data,
|
||||
group);
|
||||
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
xkb_state_update_mask(seat->xkb_state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
|
||||
xkb_state_update_mask(seat->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
|
||||
|
||||
/* A modifier changed so reset the timer,
|
||||
* see comment in #keyboard_handle_key regarding this behavior. */
|
||||
@@ -4108,7 +4176,7 @@ static void primary_selection_offer_offer(void *data,
|
||||
const char *type)
|
||||
{
|
||||
GWL_PrimarySelection_DataOffer *data_offer = static_cast<GWL_PrimarySelection_DataOffer *>(data);
|
||||
if (data_offer->id != id) {
|
||||
if (data_offer->wp.id != id) {
|
||||
CLOG_INFO(LOG, 2, "offer: %p: offer for unknown selection %p of %s (skipped)", data, id, type);
|
||||
return;
|
||||
}
|
||||
@@ -4139,7 +4207,7 @@ static void primary_selection_device_handle_data_offer(
|
||||
CLOG_INFO(LOG, 2, "data_offer");
|
||||
|
||||
GWL_PrimarySelection_DataOffer *data_offer = new GWL_PrimarySelection_DataOffer;
|
||||
data_offer->id = id;
|
||||
data_offer->wp.id = id;
|
||||
zwp_primary_selection_offer_v1_add_listener(id, &primary_selection_offer_listener, data_offer);
|
||||
}
|
||||
|
||||
@@ -4215,7 +4283,7 @@ static void primary_selection_source_cancelled(void *data, zwp_primary_selection
|
||||
|
||||
GWL_PrimarySelection *primary = static_cast<GWL_PrimarySelection *>(data);
|
||||
|
||||
if (source == primary->data_source->wp_source) {
|
||||
if (source == primary->data_source->wp.source) {
|
||||
gwl_primary_selection_discard_source(primary);
|
||||
}
|
||||
}
|
||||
@@ -4238,13 +4306,13 @@ static CLG_LogRef LOG_WL_SEAT = {"ghost.wl.handle.seat"};
|
||||
|
||||
static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
|
||||
{
|
||||
if (seat->wl_pointer) {
|
||||
if (seat->wl.pointer) {
|
||||
return;
|
||||
}
|
||||
seat->wl_pointer = wl_seat_get_pointer(seat->wl_seat);
|
||||
seat->cursor.wl_surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
|
||||
seat->wl.pointer = wl_seat_get_pointer(seat->wl.seat);
|
||||
seat->cursor.wl.surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
|
||||
seat->cursor.visible = true;
|
||||
seat->cursor.wl_buffer = nullptr;
|
||||
seat->cursor.wl.buffer = nullptr;
|
||||
if (!get_cursor_settings(seat->cursor.theme_name, seat->cursor.theme_size)) {
|
||||
/* Use environment variables, falling back to defaults.
|
||||
* These environment variables are used by enough WAYLAND applications
|
||||
@@ -4267,10 +4335,10 @@ static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
|
||||
}
|
||||
}
|
||||
}
|
||||
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
|
||||
wl_pointer_add_listener(seat->wl.pointer, &pointer_listener, seat);
|
||||
|
||||
wl_surface_add_listener(seat->cursor.wl_surface_cursor, &cursor_surface_listener, seat);
|
||||
ghost_wl_surface_tag_cursor_pointer(seat->cursor.wl_surface_cursor);
|
||||
wl_surface_add_listener(seat->cursor.wl.surface_cursor, &cursor_surface_listener, seat);
|
||||
ghost_wl_surface_tag_cursor_pointer(seat->cursor.wl.surface_cursor);
|
||||
|
||||
zwp_pointer_gestures_v1 *pointer_gestures = seat->system->wp_pointer_gestures();
|
||||
if (pointer_gestures) {
|
||||
@@ -4279,28 +4347,28 @@ static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
|
||||
if (pointer_gestures_version >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE_SINCE_VERSION)
|
||||
{ /* Hold gesture. */
|
||||
zwp_pointer_gesture_hold_v1 *gesture = zwp_pointer_gestures_v1_get_hold_gesture(
|
||||
pointer_gestures, seat->wl_pointer);
|
||||
pointer_gestures, seat->wl.pointer);
|
||||
zwp_pointer_gesture_hold_v1_set_user_data(gesture, seat);
|
||||
zwp_pointer_gesture_hold_v1_add_listener(gesture, &gesture_hold_listener, seat);
|
||||
seat->wp_pointer_gesture_hold = gesture;
|
||||
seat->wp.pointer_gesture_hold = gesture;
|
||||
}
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
|
||||
{ /* Pinch gesture. */
|
||||
zwp_pointer_gesture_pinch_v1 *gesture = zwp_pointer_gestures_v1_get_pinch_gesture(
|
||||
pointer_gestures, seat->wl_pointer);
|
||||
pointer_gestures, seat->wl.pointer);
|
||||
zwp_pointer_gesture_pinch_v1_set_user_data(gesture, seat);
|
||||
zwp_pointer_gesture_pinch_v1_add_listener(gesture, &gesture_pinch_listener, seat);
|
||||
seat->wp_pointer_gesture_pinch = gesture;
|
||||
seat->wp.pointer_gesture_pinch = gesture;
|
||||
}
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
|
||||
{ /* Swipe gesture. */
|
||||
zwp_pointer_gesture_swipe_v1 *gesture = zwp_pointer_gestures_v1_get_swipe_gesture(
|
||||
pointer_gestures, seat->wl_pointer);
|
||||
pointer_gestures, seat->wl.pointer);
|
||||
zwp_pointer_gesture_swipe_v1_set_user_data(gesture, seat);
|
||||
zwp_pointer_gesture_swipe_v1_add_listener(gesture, &gesture_swipe_listener, seat);
|
||||
seat->wp_pointer_gesture_swipe = gesture;
|
||||
seat->wp.pointer_gesture_swipe = gesture;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -4308,7 +4376,7 @@ static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
|
||||
|
||||
static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
|
||||
{
|
||||
if (!seat->wl_pointer) {
|
||||
if (!seat->wl.pointer) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4316,7 +4384,7 @@ static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
|
||||
if (pointer_gestures) {
|
||||
#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
|
||||
{ /* Hold gesture. */
|
||||
zwp_pointer_gesture_hold_v1 **gesture_p = &seat->wp_pointer_gesture_hold;
|
||||
zwp_pointer_gesture_hold_v1 **gesture_p = &seat->wp.pointer_gesture_hold;
|
||||
if (*gesture_p) {
|
||||
zwp_pointer_gesture_hold_v1_destroy(*gesture_p);
|
||||
*gesture_p = nullptr;
|
||||
@@ -4325,7 +4393,7 @@ static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
|
||||
{ /* Pinch gesture. */
|
||||
zwp_pointer_gesture_pinch_v1 **gesture_p = &seat->wp_pointer_gesture_pinch;
|
||||
zwp_pointer_gesture_pinch_v1 **gesture_p = &seat->wp.pointer_gesture_pinch;
|
||||
if (*gesture_p) {
|
||||
zwp_pointer_gesture_pinch_v1_destroy(*gesture_p);
|
||||
*gesture_p = nullptr;
|
||||
@@ -4334,7 +4402,7 @@ static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
|
||||
#endif
|
||||
#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
|
||||
{ /* Swipe gesture. */
|
||||
zwp_pointer_gesture_swipe_v1 **gesture_p = &seat->wp_pointer_gesture_swipe;
|
||||
zwp_pointer_gesture_swipe_v1 **gesture_p = &seat->wp.pointer_gesture_swipe;
|
||||
if (*gesture_p) {
|
||||
zwp_pointer_gesture_swipe_v1_destroy(*gesture_p);
|
||||
*gesture_p = nullptr;
|
||||
@@ -4343,31 +4411,31 @@ static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (seat->cursor.wl_surface_cursor) {
|
||||
wl_surface_destroy(seat->cursor.wl_surface_cursor);
|
||||
seat->cursor.wl_surface_cursor = nullptr;
|
||||
if (seat->cursor.wl.surface_cursor) {
|
||||
wl_surface_destroy(seat->cursor.wl.surface_cursor);
|
||||
seat->cursor.wl.surface_cursor = nullptr;
|
||||
}
|
||||
if (seat->cursor.wl_theme) {
|
||||
wl_cursor_theme_destroy(seat->cursor.wl_theme);
|
||||
seat->cursor.wl_theme = nullptr;
|
||||
if (seat->cursor.wl.theme) {
|
||||
wl_cursor_theme_destroy(seat->cursor.wl.theme);
|
||||
seat->cursor.wl.theme = nullptr;
|
||||
}
|
||||
|
||||
wl_pointer_destroy(seat->wl_pointer);
|
||||
seat->wl_pointer = nullptr;
|
||||
wl_pointer_destroy(seat->wl.pointer);
|
||||
seat->wl.pointer = nullptr;
|
||||
}
|
||||
|
||||
static void gwl_seat_capability_keyboard_enable(GWL_Seat *seat)
|
||||
{
|
||||
if (seat->wl_keyboard) {
|
||||
if (seat->wl.keyboard) {
|
||||
return;
|
||||
}
|
||||
seat->wl_keyboard = wl_seat_get_keyboard(seat->wl_seat);
|
||||
wl_keyboard_add_listener(seat->wl_keyboard, &keyboard_listener, seat);
|
||||
seat->wl.keyboard = wl_seat_get_keyboard(seat->wl.seat);
|
||||
wl_keyboard_add_listener(seat->wl.keyboard, &keyboard_listener, seat);
|
||||
}
|
||||
|
||||
static void gwl_seat_capability_keyboard_disable(GWL_Seat *seat)
|
||||
{
|
||||
if (!seat->wl_keyboard) {
|
||||
if (!seat->wl.keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4379,27 +4447,27 @@ static void gwl_seat_capability_keyboard_disable(GWL_Seat *seat)
|
||||
keyboard_handle_key_repeat_cancel(seat);
|
||||
}
|
||||
}
|
||||
wl_keyboard_destroy(seat->wl_keyboard);
|
||||
seat->wl_keyboard = nullptr;
|
||||
wl_keyboard_destroy(seat->wl.keyboard);
|
||||
seat->wl.keyboard = nullptr;
|
||||
}
|
||||
|
||||
static void gwl_seat_capability_touch_enable(GWL_Seat *seat)
|
||||
{
|
||||
if (seat->wl_touch) {
|
||||
if (seat->wl.touch) {
|
||||
return;
|
||||
}
|
||||
seat->wl_touch = wl_seat_get_touch(seat->wl_seat);
|
||||
wl_touch_set_user_data(seat->wl_touch, seat);
|
||||
wl_touch_add_listener(seat->wl_touch, &touch_seat_listener, seat);
|
||||
seat->wl.touch = wl_seat_get_touch(seat->wl.seat);
|
||||
wl_touch_set_user_data(seat->wl.touch, seat);
|
||||
wl_touch_add_listener(seat->wl.touch, &touch_seat_listener, seat);
|
||||
}
|
||||
|
||||
static void gwl_seat_capability_touch_disable(GWL_Seat *seat)
|
||||
{
|
||||
if (!seat->wl_touch) {
|
||||
if (!seat->wl.touch) {
|
||||
return;
|
||||
}
|
||||
wl_touch_destroy(seat->wl_touch);
|
||||
seat->wl_touch = nullptr;
|
||||
wl_touch_destroy(seat->wl.touch);
|
||||
seat->wl.touch = nullptr;
|
||||
}
|
||||
|
||||
static void seat_handle_capabilities(void *data,
|
||||
@@ -4415,7 +4483,7 @@ static void seat_handle_capabilities(void *data,
|
||||
(capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0);
|
||||
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(data);
|
||||
GHOST_ASSERT(seat->wl_seat == wl_seat, "Seat mismatch");
|
||||
GHOST_ASSERT(seat->wl.seat == wl_seat, "Seat mismatch");
|
||||
|
||||
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
|
||||
gwl_seat_capability_pointer_enable(seat);
|
||||
@@ -4516,8 +4584,8 @@ static void xdg_output_handle_done(void *data, zxdg_output_v1 * /*xdg_output*/)
|
||||
/* NOTE: `xdg-output.done` events are deprecated and only apply below version 3 of the protocol.
|
||||
* `wl-output.done` event will be emitted in version 3 or higher. */
|
||||
GWL_Output *output = static_cast<GWL_Output *>(data);
|
||||
if (zxdg_output_v1_get_version(output->xdg_output) < 3) {
|
||||
output_handle_done(data, output->wl_output);
|
||||
if (zxdg_output_v1_get_version(output->xdg.output) < 3) {
|
||||
output_handle_done(data, output->wl.output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4727,15 +4795,15 @@ static CLG_LogRef LOG_WL_REGISTRY = {"ghost.wl.handle.registry"};
|
||||
static void gwl_registry_compositor_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wl_compositor = static_cast<wl_compositor *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wl_compositor_interface, 3));
|
||||
display->wl.compositor = static_cast<wl_compositor *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wl_compositor_interface, 3));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_compositor_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
wl_compositor **value_p = &display->wl_compositor;
|
||||
wl_compositor **value_p = &display->wl.compositor;
|
||||
wl_compositor_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -4747,7 +4815,7 @@ static void gwl_registry_xdg_wm_base_add(GWL_Display *display,
|
||||
{
|
||||
GWL_XDG_Decor_System &decor = *display->xdg_decor;
|
||||
decor.shell = static_cast<xdg_wm_base *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &xdg_wm_base_interface, 1));
|
||||
wl_registry_bind(display->wl.registry, params->name, &xdg_wm_base_interface, 1));
|
||||
xdg_wm_base_add_listener(decor.shell, &shell_listener, nullptr);
|
||||
decor.shell_name = params->name;
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
@@ -4771,7 +4839,7 @@ static void gwl_registry_xdg_decoration_manager_add(GWL_Display *display,
|
||||
{
|
||||
GWL_XDG_Decor_System &decor = *display->xdg_decor;
|
||||
decor.manager = static_cast<zxdg_decoration_manager_v1 *>(wl_registry_bind(
|
||||
display->wl_registry, params->name, &zxdg_decoration_manager_v1_interface, 1));
|
||||
display->wl.registry, params->name, &zxdg_decoration_manager_v1_interface, 1));
|
||||
decor.manager_name = params->name;
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
@@ -4792,15 +4860,15 @@ static void gwl_registry_xdg_decoration_manager_remove(GWL_Display *display,
|
||||
static void gwl_registry_xdg_output_manager_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->xdg_output_manager = static_cast<zxdg_output_manager_v1 *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &zxdg_output_manager_v1_interface, 2));
|
||||
display->xdg.output_manager = static_cast<zxdg_output_manager_v1 *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &zxdg_output_manager_v1_interface, 2));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_xdg_output_manager_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zxdg_output_manager_v1 **value_p = &display->xdg_output_manager;
|
||||
zxdg_output_manager_v1 **value_p = &display->xdg.output_manager;
|
||||
zxdg_output_manager_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -4811,28 +4879,28 @@ static void gwl_registry_wl_output_add(GWL_Display *display, const GWL_Registery
|
||||
{
|
||||
GWL_Output *output = new GWL_Output;
|
||||
output->system = display->system;
|
||||
output->wl_output = static_cast<wl_output *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wl_output_interface, 2));
|
||||
ghost_wl_output_tag(output->wl_output);
|
||||
wl_output_set_user_data(output->wl_output, output);
|
||||
output->wl.output = static_cast<wl_output *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wl_output_interface, 2));
|
||||
ghost_wl_output_tag(output->wl.output);
|
||||
wl_output_set_user_data(output->wl.output, output);
|
||||
|
||||
display->outputs.push_back(output);
|
||||
wl_output_add_listener(output->wl_output, &output_listener, output);
|
||||
wl_output_add_listener(output->wl.output, &output_listener, output);
|
||||
gwl_registry_entry_add(display, params, static_cast<void *>(output));
|
||||
}
|
||||
static void gwl_registry_wl_output_update(GWL_Display *display,
|
||||
const GWL_RegisteryUpdate_Params *params)
|
||||
{
|
||||
GWL_Output *output = static_cast<GWL_Output *>(params->user_data);
|
||||
if (display->xdg_output_manager) {
|
||||
if (output->xdg_output == nullptr) {
|
||||
output->xdg_output = zxdg_output_manager_v1_get_xdg_output(display->xdg_output_manager,
|
||||
output->wl_output);
|
||||
zxdg_output_v1_add_listener(output->xdg_output, &xdg_output_listener, output);
|
||||
if (display->xdg.output_manager) {
|
||||
if (output->xdg.output == nullptr) {
|
||||
output->xdg.output = zxdg_output_manager_v1_get_xdg_output(display->xdg.output_manager,
|
||||
output->wl.output);
|
||||
zxdg_output_v1_add_listener(output->xdg.output, &xdg_output_listener, output);
|
||||
}
|
||||
}
|
||||
else {
|
||||
output->xdg_output = nullptr;
|
||||
output->xdg.output = nullptr;
|
||||
}
|
||||
}
|
||||
static void gwl_registry_wl_output_remove(GWL_Display *display,
|
||||
@@ -4849,17 +4917,17 @@ static void gwl_registry_wl_output_remove(GWL_Display *display,
|
||||
|
||||
if (!on_exit) {
|
||||
/* Needed for WLROOTS, does nothing if surface leave callbacks have already run. */
|
||||
if (output->system->output_unref(output->wl_output)) {
|
||||
if (output->system->output_unref(output->wl.output)) {
|
||||
CLOG_WARN(LOG,
|
||||
"mis-behaving compositor failed to call \"surface_listener.leave\" "
|
||||
"window scale may be invalid!");
|
||||
}
|
||||
}
|
||||
|
||||
if (output->xdg_output) {
|
||||
zxdg_output_v1_destroy(output->xdg_output);
|
||||
if (output->xdg.output) {
|
||||
zxdg_output_v1_destroy(output->xdg.output);
|
||||
}
|
||||
wl_output_destroy(output->wl_output);
|
||||
wl_output_destroy(output->wl.output);
|
||||
std::vector<GWL_Output *>::iterator iter = std::find(
|
||||
display->outputs.begin(), display->outputs.end(), output);
|
||||
const int index = (iter != display->outputs.cend()) ?
|
||||
@@ -4877,12 +4945,12 @@ static void gwl_registry_wl_seat_add(GWL_Display *display, const GWL_RegisteryAd
|
||||
{
|
||||
GWL_Seat *seat = new GWL_Seat;
|
||||
seat->system = display->system;
|
||||
seat->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
seat->xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
seat->data_source = new GWL_DataSource;
|
||||
seat->wl_seat = static_cast<wl_seat *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wl_seat_interface, 5));
|
||||
seat->wl.seat = static_cast<wl_seat *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wl_seat_interface, 5));
|
||||
display->seats.push_back(seat);
|
||||
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
||||
wl_seat_add_listener(seat->wl.seat, &seat_listener, seat);
|
||||
gwl_registry_entry_add(display, params, static_cast<void *>(seat));
|
||||
}
|
||||
static void gwl_registry_wl_seat_update(GWL_Display *display,
|
||||
@@ -4891,40 +4959,40 @@ static void gwl_registry_wl_seat_update(GWL_Display *display,
|
||||
GWL_Seat *seat = static_cast<GWL_Seat *>(params->user_data);
|
||||
|
||||
/* Register data device per seat for IPC between WAYLAND clients. */
|
||||
if (display->wl_data_device_manager) {
|
||||
if (seat->wl_data_device == nullptr) {
|
||||
seat->wl_data_device = wl_data_device_manager_get_data_device(
|
||||
display->wl_data_device_manager, seat->wl_seat);
|
||||
wl_data_device_add_listener(seat->wl_data_device, &data_device_listener, seat);
|
||||
if (display->wl.data_device_manager) {
|
||||
if (seat->wl.data_device == nullptr) {
|
||||
seat->wl.data_device = wl_data_device_manager_get_data_device(
|
||||
display->wl.data_device_manager, seat->wl.seat);
|
||||
wl_data_device_add_listener(seat->wl.data_device, &data_device_listener, seat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
seat->wl_data_device = nullptr;
|
||||
seat->wl.data_device = nullptr;
|
||||
}
|
||||
|
||||
if (display->wp_tablet_manager) {
|
||||
if (seat->wp_tablet_seat == nullptr) {
|
||||
seat->wp_tablet_seat = zwp_tablet_manager_v2_get_tablet_seat(display->wp_tablet_manager,
|
||||
seat->wl_seat);
|
||||
zwp_tablet_seat_v2_add_listener(seat->wp_tablet_seat, &tablet_seat_listener, seat);
|
||||
if (display->wp.tablet_manager) {
|
||||
if (seat->wp.tablet_seat == nullptr) {
|
||||
seat->wp.tablet_seat = zwp_tablet_manager_v2_get_tablet_seat(display->wp.tablet_manager,
|
||||
seat->wl.seat);
|
||||
zwp_tablet_seat_v2_add_listener(seat->wp.tablet_seat, &tablet_seat_listener, seat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
seat->wp_tablet_seat = nullptr;
|
||||
seat->wp.tablet_seat = nullptr;
|
||||
}
|
||||
|
||||
if (display->wp_primary_selection_device_manager) {
|
||||
if (seat->wp_primary_selection_device == nullptr) {
|
||||
seat->wp_primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
|
||||
display->wp_primary_selection_device_manager, seat->wl_seat);
|
||||
if (display->wp.primary_selection_device_manager) {
|
||||
if (seat->wp.primary_selection_device == nullptr) {
|
||||
seat->wp.primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
|
||||
display->wp.primary_selection_device_manager, seat->wl.seat);
|
||||
|
||||
zwp_primary_selection_device_v1_add_listener(seat->wp_primary_selection_device,
|
||||
zwp_primary_selection_device_v1_add_listener(seat->wp.primary_selection_device,
|
||||
&primary_selection_device_listener,
|
||||
&seat->primary_selection);
|
||||
}
|
||||
}
|
||||
else {
|
||||
seat->wp_primary_selection_device = nullptr;
|
||||
seat->wp.primary_selection_device = nullptr;
|
||||
}
|
||||
}
|
||||
static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, const bool on_exit)
|
||||
@@ -4937,8 +5005,8 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
std::lock_guard lock{seat->data_source_mutex};
|
||||
if (seat->data_source) {
|
||||
gwl_simple_buffer_free_data(&seat->data_source->buffer_out);
|
||||
if (seat->data_source->wl_source) {
|
||||
wl_data_source_destroy(seat->data_source->wl_source);
|
||||
if (seat->data_source->wl.source) {
|
||||
wl_data_source_destroy(seat->data_source->wl.source);
|
||||
}
|
||||
delete seat->data_source;
|
||||
}
|
||||
@@ -4947,7 +5015,7 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
{
|
||||
std::lock_guard lock{seat->data_offer_dnd_mutex};
|
||||
if (seat->data_offer_dnd) {
|
||||
wl_data_offer_destroy(seat->data_offer_dnd->id);
|
||||
wl_data_offer_destroy(seat->data_offer_dnd->wl.id);
|
||||
delete seat->data_offer_dnd;
|
||||
}
|
||||
}
|
||||
@@ -4955,7 +5023,7 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
{
|
||||
std::lock_guard lock{seat->data_offer_copy_paste_mutex};
|
||||
if (seat->data_offer_copy_paste) {
|
||||
wl_data_offer_destroy(seat->data_offer_copy_paste->id);
|
||||
wl_data_offer_destroy(seat->data_offer_copy_paste->wl.id);
|
||||
delete seat->data_offer_copy_paste;
|
||||
}
|
||||
}
|
||||
@@ -4972,12 +5040,12 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
gwl_primary_selection_discard_source(primary);
|
||||
}
|
||||
|
||||
if (seat->wp_primary_selection_device) {
|
||||
zwp_primary_selection_device_v1_destroy(seat->wp_primary_selection_device);
|
||||
if (seat->wp.primary_selection_device) {
|
||||
zwp_primary_selection_device_v1_destroy(seat->wp.primary_selection_device);
|
||||
}
|
||||
|
||||
if (seat->wl_data_device) {
|
||||
wl_data_device_release(seat->wl_data_device);
|
||||
if (seat->wl.data_device) {
|
||||
wl_data_device_release(seat->wl.data_device);
|
||||
}
|
||||
|
||||
if (seat->cursor.custom_data) {
|
||||
@@ -4994,15 +5062,15 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
gwl_seat_capability_touch_disable(seat);
|
||||
|
||||
/* Un-referencing checks for nullptr case. */
|
||||
xkb_state_unref(seat->xkb_state);
|
||||
xkb_state_unref(seat->xkb_state_empty);
|
||||
xkb_state_unref(seat->xkb_state_empty_with_shift);
|
||||
xkb_state_unref(seat->xkb_state_empty_with_numlock);
|
||||
xkb_state_unref(seat->xkb.state);
|
||||
xkb_state_unref(seat->xkb.state_empty);
|
||||
xkb_state_unref(seat->xkb.state_empty_with_shift);
|
||||
xkb_state_unref(seat->xkb.state_empty_with_numlock);
|
||||
|
||||
xkb_context_unref(seat->xkb_context);
|
||||
xkb_context_unref(seat->xkb.context);
|
||||
|
||||
/* Remove the seat. */
|
||||
wl_seat_destroy(seat->wl_seat);
|
||||
wl_seat_destroy(seat->wl.seat);
|
||||
|
||||
std::vector<GWL_Seat *>::iterator iter = std::find(
|
||||
display->seats.begin(), display->seats.end(), seat);
|
||||
@@ -5023,15 +5091,15 @@ static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, c
|
||||
|
||||
static void gwl_registry_wl_shm_add(GWL_Display *display, const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wl_shm = static_cast<wl_shm *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wl_shm_interface, 1));
|
||||
display->wl.shm = static_cast<wl_shm *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wl_shm_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wl_shm_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
wl_shm **value_p = &display->wl_shm;
|
||||
wl_shm **value_p = &display->wl.shm;
|
||||
wl_shm_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5041,15 +5109,15 @@ static void gwl_registry_wl_shm_remove(GWL_Display *display,
|
||||
static void gwl_registry_wl_data_device_manager_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wl_data_device_manager = static_cast<wl_data_device_manager *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wl_data_device_manager_interface, 3));
|
||||
display->wl.data_device_manager = static_cast<wl_data_device_manager *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wl_data_device_manager_interface, 3));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wl_data_device_manager_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
wl_data_device_manager **value_p = &display->wl_data_device_manager;
|
||||
wl_data_device_manager **value_p = &display->wl.data_device_manager;
|
||||
wl_data_device_manager_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5059,15 +5127,15 @@ static void gwl_registry_wl_data_device_manager_remove(GWL_Display *display,
|
||||
static void gwl_registry_wp_tablet_manager_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_tablet_manager = static_cast<zwp_tablet_manager_v2 *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &zwp_tablet_manager_v2_interface, 1));
|
||||
display->wp.tablet_manager = static_cast<zwp_tablet_manager_v2 *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &zwp_tablet_manager_v2_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wp_tablet_manager_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zwp_tablet_manager_v2 **value_p = &display->wp_tablet_manager;
|
||||
zwp_tablet_manager_v2 **value_p = &display->wp.tablet_manager;
|
||||
zwp_tablet_manager_v2_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5077,16 +5145,16 @@ static void gwl_registry_wp_tablet_manager_remove(GWL_Display *display,
|
||||
static void gwl_registry_wp_relative_pointer_manager_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_relative_pointer_manager = static_cast<zwp_relative_pointer_manager_v1 *>(
|
||||
display->wp.relative_pointer_manager = static_cast<zwp_relative_pointer_manager_v1 *>(
|
||||
wl_registry_bind(
|
||||
display->wl_registry, params->name, &zwp_relative_pointer_manager_v1_interface, 1));
|
||||
display->wl.registry, params->name, &zwp_relative_pointer_manager_v1_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wp_relative_pointer_manager_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zwp_relative_pointer_manager_v1 **value_p = &display->wp_relative_pointer_manager;
|
||||
zwp_relative_pointer_manager_v1 **value_p = &display->wp.relative_pointer_manager;
|
||||
zwp_relative_pointer_manager_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5096,15 +5164,15 @@ static void gwl_registry_wp_relative_pointer_manager_remove(GWL_Display *display
|
||||
static void gwl_registry_wp_pointer_constraints_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_pointer_constraints = static_cast<zwp_pointer_constraints_v1 *>(wl_registry_bind(
|
||||
display->wl_registry, params->name, &zwp_pointer_constraints_v1_interface, 1));
|
||||
display->wp.pointer_constraints = static_cast<zwp_pointer_constraints_v1 *>(wl_registry_bind(
|
||||
display->wl.registry, params->name, &zwp_pointer_constraints_v1_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wp_pointer_constraints_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zwp_pointer_constraints_v1 **value_p = &display->wp_pointer_constraints;
|
||||
zwp_pointer_constraints_v1 **value_p = &display->wp.pointer_constraints;
|
||||
zwp_pointer_constraints_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5114,8 +5182,8 @@ static void gwl_registry_wp_pointer_constraints_remove(GWL_Display *display,
|
||||
static void gwl_registry_wp_pointer_gestures_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_pointer_gestures = static_cast<zwp_pointer_gestures_v1 *>(
|
||||
wl_registry_bind(display->wl_registry,
|
||||
display->wp.pointer_gestures = static_cast<zwp_pointer_gestures_v1 *>(
|
||||
wl_registry_bind(display->wl.registry,
|
||||
params->name,
|
||||
&zwp_pointer_gestures_v1_interface,
|
||||
std::min(params->version, 3u)));
|
||||
@@ -5125,7 +5193,7 @@ static void gwl_registry_wp_pointer_gestures_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zwp_pointer_gestures_v1 **value_p = &display->wp_pointer_gestures;
|
||||
zwp_pointer_gestures_v1 **value_p = &display->wp.pointer_gestures;
|
||||
zwp_pointer_gestures_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5135,15 +5203,15 @@ static void gwl_registry_wp_pointer_gestures_remove(GWL_Display *display,
|
||||
static void gwl_registry_xdg_activation_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->xdg_activation_manager = static_cast<xdg_activation_v1 *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &xdg_activation_v1_interface, 1));
|
||||
display->xdg.activation_manager = static_cast<xdg_activation_v1 *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &xdg_activation_v1_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_xdg_activation_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
xdg_activation_v1 **value_p = &display->xdg_activation_manager;
|
||||
xdg_activation_v1 **value_p = &display->xdg.activation_manager;
|
||||
xdg_activation_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5153,16 +5221,16 @@ static void gwl_registry_xdg_activation_remove(GWL_Display *display,
|
||||
static void gwl_registry_wp_fractional_scale_manager_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_fractional_scale_manager = static_cast<wp_fractional_scale_manager_v1 *>(
|
||||
display->wp.fractional_scale_manager = static_cast<wp_fractional_scale_manager_v1 *>(
|
||||
wl_registry_bind(
|
||||
display->wl_registry, params->name, &wp_fractional_scale_manager_v1_interface, 1));
|
||||
display->wl.registry, params->name, &wp_fractional_scale_manager_v1_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wp_fractional_scale_manager_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
wp_fractional_scale_manager_v1 **value_p = &display->wp_fractional_scale_manager;
|
||||
wp_fractional_scale_manager_v1 **value_p = &display->wp.fractional_scale_manager;
|
||||
wp_fractional_scale_manager_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5172,15 +5240,15 @@ static void gwl_registry_wp_fractional_scale_manager_remove(GWL_Display *display
|
||||
static void gwl_registry_wp_viewporter_add(GWL_Display *display,
|
||||
const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_viewporter = static_cast<wp_viewporter *>(
|
||||
wl_registry_bind(display->wl_registry, params->name, &wp_viewporter_interface, 1));
|
||||
display->wp.viewporter = static_cast<wp_viewporter *>(
|
||||
wl_registry_bind(display->wl.registry, params->name, &wp_viewporter_interface, 1));
|
||||
gwl_registry_entry_add(display, params, nullptr);
|
||||
}
|
||||
static void gwl_registry_wp_viewporter_remove(GWL_Display *display,
|
||||
void * /*user_data*/,
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
wp_viewporter **value_p = &display->wp_viewporter;
|
||||
wp_viewporter **value_p = &display->wp.viewporter;
|
||||
wp_viewporter_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5190,9 +5258,9 @@ static void gwl_registry_wp_viewporter_remove(GWL_Display *display,
|
||||
static void gwl_registry_wp_primary_selection_device_manager_add(
|
||||
GWL_Display *display, const GWL_RegisteryAdd_Params *params)
|
||||
{
|
||||
display->wp_primary_selection_device_manager =
|
||||
display->wp.primary_selection_device_manager =
|
||||
static_cast<zwp_primary_selection_device_manager_v1 *>(
|
||||
wl_registry_bind(display->wl_registry,
|
||||
wl_registry_bind(display->wl.registry,
|
||||
params->name,
|
||||
&zwp_primary_selection_device_manager_v1_interface,
|
||||
1));
|
||||
@@ -5203,7 +5271,7 @@ static void gwl_registry_wp_primary_selection_device_manager_remove(GWL_Display
|
||||
const bool /*on_exit*/)
|
||||
{
|
||||
zwp_primary_selection_device_manager_v1 **value_p =
|
||||
&display->wp_primary_selection_device_manager;
|
||||
&display->wp.primary_selection_device_manager;
|
||||
zwp_primary_selection_device_manager_v1_destroy(*value_p);
|
||||
*value_p = nullptr;
|
||||
}
|
||||
@@ -5362,7 +5430,7 @@ static void global_handle_add(void *data,
|
||||
{
|
||||
/* Log last since it's useful to know if the interface was handled or not. */
|
||||
GWL_Display *display = static_cast<GWL_Display *>(data);
|
||||
GHOST_ASSERT(display->wl_registry == wl_registry, "Registry argument must match!");
|
||||
GHOST_ASSERT(display->wl.registry == wl_registry, "Registry argument must match!");
|
||||
|
||||
const int interface_slot = gwl_registry_handler_interface_slot_from_string(interface);
|
||||
bool added = false;
|
||||
@@ -5423,7 +5491,7 @@ static void global_handle_remove(void *data,
|
||||
const uint32_t name)
|
||||
{
|
||||
GWL_Display *display = static_cast<GWL_Display *>(data);
|
||||
GHOST_ASSERT(display->wl_registry == wl_registry, "Registry argument must match!");
|
||||
GHOST_ASSERT(display->wl.registry == wl_registry, "Registry argument must match!");
|
||||
|
||||
int interface_slot = 0;
|
||||
const bool removed = gwl_registry_entry_remove_by_name(display, name, &interface_slot);
|
||||
@@ -5460,11 +5528,11 @@ static const wl_registry_listener registry_listener = {
|
||||
static void *gwl_display_event_thread_fn(void *display_voidp)
|
||||
{
|
||||
GWL_Display *display = static_cast<GWL_Display *>(display_voidp);
|
||||
const int fd = wl_display_get_fd(display->wl_display);
|
||||
const int fd = wl_display_get_fd(display->wl.display);
|
||||
while (display->events_pthread_is_active) {
|
||||
/* Wait for an event, this thread is dedicated to event handling. */
|
||||
if (ghost_wl_display_event_pump_from_thread(
|
||||
display->wl_display, fd, display->system->server_mutex) == -1)
|
||||
display->wl.display, fd, display->system->server_mutex) == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -5517,8 +5585,8 @@ GHOST_SystemWayland::GHOST_SystemWayland(bool background)
|
||||
|
||||
display_->system = this;
|
||||
/* Connect to the Wayland server. */
|
||||
display_->wl_display = wl_display_connect(nullptr);
|
||||
if (!display_->wl_display) {
|
||||
display_->wl.display = wl_display_connect(nullptr);
|
||||
if (!display_->wl.display) {
|
||||
display_destroy_and_free_all();
|
||||
throw std::runtime_error("Wayland: unable to connect to display!");
|
||||
}
|
||||
@@ -5529,13 +5597,13 @@ GHOST_SystemWayland::GHOST_SystemWayland(bool background)
|
||||
/* Register interfaces. */
|
||||
{
|
||||
display_->registry_skip_update_all = true;
|
||||
wl_registry *registry = wl_display_get_registry(display_->wl_display);
|
||||
display_->wl_registry = registry;
|
||||
wl_registry *registry = wl_display_get_registry(display_->wl.display);
|
||||
display_->wl.registry = registry;
|
||||
wl_registry_add_listener(registry, ®istry_listener, display_);
|
||||
/* First round-trip to receive all registry objects. */
|
||||
wl_display_roundtrip(display_->wl_display);
|
||||
wl_display_roundtrip(display_->wl.display);
|
||||
/* Second round-trip to receive all output events. */
|
||||
wl_display_roundtrip(display_->wl_display);
|
||||
wl_display_roundtrip(display_->wl.display);
|
||||
|
||||
/* Account for dependencies between interfaces. */
|
||||
gwl_registry_entry_update_all(display_, -1);
|
||||
@@ -5585,7 +5653,7 @@ GHOST_SystemWayland::GHOST_SystemWayland(bool background)
|
||||
if (use_libdecor) {
|
||||
display_->libdecor = new GWL_LibDecor_System;
|
||||
GWL_LibDecor_System &decor = *display_->libdecor;
|
||||
decor.context = libdecor_new(display_->wl_display, &libdecor_interface);
|
||||
decor.context = libdecor_new(display_->wl.display, &libdecor_interface);
|
||||
if (!decor.context) {
|
||||
display_destroy_and_free_all();
|
||||
throw std::runtime_error("Wayland: unable to create window decorations!");
|
||||
@@ -5714,8 +5782,8 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent)
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
std::lock_guard lock_server_guard{*server_mutex};
|
||||
#endif
|
||||
if (wl_display_dispatch(display_->wl_display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl_display);
|
||||
if (wl_display_dispatch(display_->wl.display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl.display);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -5723,14 +5791,14 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent)
|
||||
/* NOTE: this works, but as the events are being read in a thread,
|
||||
* this could be removed and event handling still works.. */
|
||||
if (server_mutex->try_lock()) {
|
||||
if (ghost_wl_display_event_pump(display_->wl_display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl_display);
|
||||
if (ghost_wl_display_event_pump(display_->wl.display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl.display);
|
||||
}
|
||||
server_mutex->unlock();
|
||||
}
|
||||
#else
|
||||
if (ghost_wl_display_event_pump(display_->wl_display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl_display);
|
||||
if (ghost_wl_display_event_pump(display_->wl.display) == -1) {
|
||||
ghost_wl_display_report_error(display_->wl.display);
|
||||
}
|
||||
#endif /* !USE_EVENT_BACKGROUND_THREAD */
|
||||
}
|
||||
@@ -5774,9 +5842,9 @@ GHOST_TSuccess GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
|
||||
* handler runs. This means the result of `getModifierKeys` may be momentarily incorrect
|
||||
* however it's corrected once #wl_keyboard_listener::enter runs.
|
||||
*/
|
||||
const bool is_keyboard_active = seat->keyboard.wl_surface_window != nullptr;
|
||||
const bool is_keyboard_active = seat->keyboard.wl.surface_window != nullptr;
|
||||
const xkb_mod_mask_t state = is_keyboard_active ?
|
||||
xkb_state_serialize_mods(seat->xkb_state,
|
||||
xkb_state_serialize_mods(seat->xkb.state,
|
||||
XKB_STATE_MODS_DEPRESSED) :
|
||||
0;
|
||||
|
||||
@@ -5903,7 +5971,7 @@ static char *system_clipboard_get_primary_selection(GWL_Display *display)
|
||||
read_thread.detach();
|
||||
|
||||
while (!thread_result.done) {
|
||||
wl_display_roundtrip(display->wl_display);
|
||||
wl_display_roundtrip(display->wl.display);
|
||||
}
|
||||
data = thread_result.data;
|
||||
|
||||
@@ -5952,7 +6020,7 @@ static char *system_clipboard_get(GWL_Display *display)
|
||||
read_thread.detach();
|
||||
|
||||
while (!thread_result.done) {
|
||||
wl_display_roundtrip(display->wl_display);
|
||||
wl_display_roundtrip(display->wl.display);
|
||||
}
|
||||
data = thread_result.data;
|
||||
|
||||
@@ -5984,7 +6052,7 @@ char *GHOST_SystemWayland::getClipboard(bool selection) const
|
||||
|
||||
static void system_clipboard_put_primary_selection(GWL_Display *display, const char *buffer)
|
||||
{
|
||||
if (!display->wp_primary_selection_device_manager) {
|
||||
if (!display->wp.primary_selection_device_manager) {
|
||||
return;
|
||||
}
|
||||
GWL_Seat *seat = gwl_display_seat_active_get(display);
|
||||
@@ -6003,25 +6071,25 @@ static void system_clipboard_put_primary_selection(GWL_Display *display, const c
|
||||
/* Copy buffer. */
|
||||
gwl_simple_buffer_set_from_string(&data_source->buffer_out, buffer);
|
||||
|
||||
data_source->wp_source = zwp_primary_selection_device_manager_v1_create_source(
|
||||
display->wp_primary_selection_device_manager);
|
||||
data_source->wp.source = zwp_primary_selection_device_manager_v1_create_source(
|
||||
display->wp.primary_selection_device_manager);
|
||||
|
||||
zwp_primary_selection_source_v1_add_listener(
|
||||
data_source->wp_source, &primary_selection_source_listener, primary);
|
||||
data_source->wp.source, &primary_selection_source_listener, primary);
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(ghost_wl_mime_send); i++) {
|
||||
zwp_primary_selection_source_v1_offer(data_source->wp_source, ghost_wl_mime_send[i]);
|
||||
zwp_primary_selection_source_v1_offer(data_source->wp.source, ghost_wl_mime_send[i]);
|
||||
}
|
||||
|
||||
if (seat->wp_primary_selection_device) {
|
||||
if (seat->wp.primary_selection_device) {
|
||||
zwp_primary_selection_device_v1_set_selection(
|
||||
seat->wp_primary_selection_device, data_source->wp_source, seat->data_source_serial);
|
||||
seat->wp.primary_selection_device, data_source->wp.source, seat->data_source_serial);
|
||||
}
|
||||
}
|
||||
|
||||
static void system_clipboard_put(GWL_Display *display, const char *buffer)
|
||||
{
|
||||
if (!display->wl_data_device_manager) {
|
||||
if (!display->wl.data_device_manager) {
|
||||
return;
|
||||
}
|
||||
GWL_Seat *seat = gwl_display_seat_active_get(display);
|
||||
@@ -6035,18 +6103,18 @@ static void system_clipboard_put(GWL_Display *display, const char *buffer)
|
||||
/* Copy buffer. */
|
||||
gwl_simple_buffer_set_from_string(&data_source->buffer_out, buffer);
|
||||
|
||||
data_source->wl_source = wl_data_device_manager_create_data_source(
|
||||
display->wl_data_device_manager);
|
||||
data_source->wl.source = wl_data_device_manager_create_data_source(
|
||||
display->wl.data_device_manager);
|
||||
|
||||
wl_data_source_add_listener(data_source->wl_source, &data_source_listener, seat);
|
||||
wl_data_source_add_listener(data_source->wl.source, &data_source_listener, seat);
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(ghost_wl_mime_send); i++) {
|
||||
wl_data_source_offer(data_source->wl_source, ghost_wl_mime_send[i]);
|
||||
wl_data_source_offer(data_source->wl.source, ghost_wl_mime_send[i]);
|
||||
}
|
||||
|
||||
if (seat->wl_data_device) {
|
||||
if (seat->wl.data_device) {
|
||||
wl_data_device_set_selection(
|
||||
seat->wl_data_device, data_source->wl_source, seat->data_source_serial);
|
||||
seat->wl.data_device, data_source->wl.source, seat->data_source_serial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6119,7 +6187,7 @@ static GHOST_TSuccess setCursorPositionClientRelative_impl(GWL_Seat *seat,
|
||||
/* NOTE: WAYLAND doesn't support warping the cursor.
|
||||
* However when grab is enabled, we already simulate a cursor location
|
||||
* so that can be set to a new location. */
|
||||
if (!seat->wp_relative_pointer) {
|
||||
if (!seat->wp.relative_pointer) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
const wl_fixed_t xy_next[2]{
|
||||
@@ -6146,7 +6214,7 @@ GHOST_TSuccess GHOST_SystemWayland::getCursorPositionClientRelative(const GHOST_
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
GWL_SeatStatePointer *seat_state_pointer = gwl_seat_state_pointer_active(seat);
|
||||
if (!seat_state_pointer || !seat_state_pointer->wl_surface_window) {
|
||||
if (!seat_state_pointer || !seat_state_pointer->wl.surface_window) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
const GHOST_WindowWayland *win = static_cast<const GHOST_WindowWayland *>(window);
|
||||
@@ -6184,7 +6252,7 @@ GHOST_TSuccess GHOST_SystemWayland::getCursorPosition(int32_t &x, int32_t &y) co
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
if (wl_surface *wl_surface_focus = seat_state_pointer->wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat_state_pointer->wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
return getCursorPositionClientRelative_impl(seat_state_pointer, win, x, y);
|
||||
}
|
||||
@@ -6204,7 +6272,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorPosition(const int32_t x, const int
|
||||
|
||||
/* Intentionally different from `getCursorPosition` which supports both tablet & pointer.
|
||||
* In the case of setting the cursor location, tablets don't support this. */
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl_surface_window) {
|
||||
if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) {
|
||||
GHOST_WindowWayland *win = ghost_wl_surface_user_data(wl_surface_focus);
|
||||
return setCursorPositionClientRelative_impl(seat, win, x, y);
|
||||
}
|
||||
@@ -6301,7 +6369,7 @@ GHOST_IContext *GHOST_SystemWayland::createOffscreenContext(GHOST_GPUSettings gp
|
||||
GHOST_Context *context = new GHOST_ContextEGL(this,
|
||||
false,
|
||||
EGLNativeWindowType(egl_window),
|
||||
EGLNativeDisplayType(display_->wl_display),
|
||||
EGLNativeDisplayType(display_->wl.display),
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||
4,
|
||||
minor,
|
||||
@@ -6404,30 +6472,30 @@ static void cursor_buffer_show(const GWL_Seat *seat)
|
||||
{
|
||||
const GWL_Cursor *cursor = &seat->cursor;
|
||||
|
||||
if (seat->wl_pointer) {
|
||||
if (seat->wl.pointer) {
|
||||
const int scale = cursor->is_custom ? cursor->custom_scale : seat->pointer.theme_scale;
|
||||
const int32_t hotspot_x = int32_t(cursor->wl_image.hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(cursor->wl_image.hotspot_y) / scale;
|
||||
if (seat->wl_pointer) {
|
||||
const int32_t hotspot_x = int32_t(cursor->wl.image.hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(cursor->wl.image.hotspot_y) / scale;
|
||||
if (seat->wl.pointer) {
|
||||
wl_pointer_set_cursor(
|
||||
seat->wl_pointer, seat->pointer.serial, cursor->wl_surface_cursor, hotspot_x, hotspot_y);
|
||||
seat->wl.pointer, seat->pointer.serial, cursor->wl.surface_cursor, hotspot_x, hotspot_y);
|
||||
}
|
||||
}
|
||||
|
||||
if (!seat->tablet_tools.empty()) {
|
||||
if (!seat->wp.tablet_tools.empty()) {
|
||||
const int scale = cursor->is_custom ? cursor->custom_scale : seat->tablet.theme_scale;
|
||||
const int32_t hotspot_x = int32_t(cursor->wl_image.hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(cursor->wl_image.hotspot_y) / scale;
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->tablet_tools) {
|
||||
const int32_t hotspot_x = int32_t(cursor->wl.image.hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(cursor->wl.image.hotspot_y) / scale;
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->wp.tablet_tools) {
|
||||
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(
|
||||
zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
|
||||
zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2,
|
||||
seat->tablet.serial,
|
||||
tablet_tool->wl_surface_cursor,
|
||||
tablet_tool->wl.surface_cursor,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
#ifdef USE_KDE_TABLET_HIDDEN_CURSOR_HACK
|
||||
wl_surface_commit(tablet_tool->wl_surface_cursor);
|
||||
wl_surface_commit(tablet_tool->wl.surface_cursor);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -6441,8 +6509,8 @@ static void cursor_buffer_show(const GWL_Seat *seat)
|
||||
*/
|
||||
static void cursor_buffer_hide(const GWL_Seat *seat)
|
||||
{
|
||||
wl_pointer_set_cursor(seat->wl_pointer, seat->pointer.serial, nullptr, 0, 0);
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->tablet_tools) {
|
||||
wl_pointer_set_cursor(seat->wl.pointer, seat->pointer.serial, nullptr, 0, 0);
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->wp.tablet_tools) {
|
||||
zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2, seat->tablet.serial, nullptr, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -6468,7 +6536,7 @@ static void cursor_buffer_set_surface_impl(const GWL_Seat *seat,
|
||||
wl_surface *wl_surface,
|
||||
const int scale)
|
||||
{
|
||||
const wl_cursor_image *wl_image = &seat->cursor.wl_image;
|
||||
const wl_cursor_image *wl_image = &seat->cursor.wl.image;
|
||||
const int32_t image_size_x = int32_t(wl_image->width);
|
||||
const int32_t image_size_y = int32_t(wl_image->height);
|
||||
GHOST_ASSERT((image_size_x % scale) == 0 && (image_size_y % scale) == 0,
|
||||
@@ -6483,37 +6551,37 @@ static void cursor_buffer_set_surface_impl(const GWL_Seat *seat,
|
||||
static void cursor_buffer_set(const GWL_Seat *seat, wl_buffer *buffer)
|
||||
{
|
||||
const GWL_Cursor *cursor = &seat->cursor;
|
||||
const wl_cursor_image *wl_image = &seat->cursor.wl_image;
|
||||
const wl_cursor_image *wl_image = &seat->cursor.wl.image;
|
||||
const bool visible = (cursor->visible && cursor->is_hardware);
|
||||
|
||||
/* This is a requirement of WAYLAND, when this isn't the case,
|
||||
* it causes Blender's window to close intermittently. */
|
||||
if (seat->wl_pointer) {
|
||||
if (seat->wl.pointer) {
|
||||
const int scale = cursor_buffer_compatible_scale_from_image(
|
||||
wl_image, cursor->is_custom ? cursor->custom_scale : seat->pointer.theme_scale);
|
||||
const int32_t hotspot_x = int32_t(wl_image->hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(wl_image->hotspot_y) / scale;
|
||||
cursor_buffer_set_surface_impl(seat, buffer, cursor->wl_surface_cursor, scale);
|
||||
wl_pointer_set_cursor(seat->wl_pointer,
|
||||
cursor_buffer_set_surface_impl(seat, buffer, cursor->wl.surface_cursor, scale);
|
||||
wl_pointer_set_cursor(seat->wl.pointer,
|
||||
seat->pointer.serial,
|
||||
visible ? cursor->wl_surface_cursor : nullptr,
|
||||
visible ? cursor->wl.surface_cursor : nullptr,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
}
|
||||
|
||||
/* Set the cursor for all tablet tools as well. */
|
||||
if (!seat->tablet_tools.empty()) {
|
||||
if (!seat->wp.tablet_tools.empty()) {
|
||||
const int scale = cursor_buffer_compatible_scale_from_image(
|
||||
wl_image, cursor->is_custom ? cursor->custom_scale : seat->tablet.theme_scale);
|
||||
const int32_t hotspot_x = int32_t(wl_image->hotspot_x) / scale;
|
||||
const int32_t hotspot_y = int32_t(wl_image->hotspot_y) / scale;
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->tablet_tools) {
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->wp.tablet_tools) {
|
||||
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(
|
||||
zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
|
||||
cursor_buffer_set_surface_impl(seat, buffer, tablet_tool->wl_surface_cursor, scale);
|
||||
cursor_buffer_set_surface_impl(seat, buffer, tablet_tool->wl.surface_cursor, scale);
|
||||
zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2,
|
||||
seat->tablet.serial,
|
||||
visible ? tablet_tool->wl_surface_cursor : nullptr,
|
||||
visible ? tablet_tool->wl.surface_cursor : nullptr,
|
||||
hotspot_x,
|
||||
hotspot_y);
|
||||
}
|
||||
@@ -6595,13 +6663,13 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_shape_set(const GHOST_TStandardCursor
|
||||
|
||||
GWL_Cursor *cursor = &seat->cursor;
|
||||
|
||||
if (!cursor->wl_theme) {
|
||||
if (!cursor->wl.theme) {
|
||||
/* The cursor wl_surface hasn't entered an output yet. Initialize theme with scale 1. */
|
||||
cursor->wl_theme = wl_cursor_theme_load(
|
||||
cursor->wl.theme = wl_cursor_theme_load(
|
||||
cursor->theme_name.c_str(), cursor->theme_size, wl_shm());
|
||||
}
|
||||
|
||||
wl_cursor *wl_cursor = wl_cursor_theme_get_cursor(cursor->wl_theme, cursor_name);
|
||||
wl_cursor *wl_cursor = wl_cursor_theme_get_cursor(cursor->wl.theme, cursor_name);
|
||||
|
||||
if (!wl_cursor) {
|
||||
GHOST_PRINT("cursor '" << cursor_name << "' does not exist" << std::endl);
|
||||
@@ -6616,8 +6684,8 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_shape_set(const GHOST_TStandardCursor
|
||||
|
||||
cursor->visible = true;
|
||||
cursor->is_custom = false;
|
||||
cursor->wl_buffer = buffer;
|
||||
cursor->wl_image = *image;
|
||||
cursor->wl.buffer = buffer;
|
||||
cursor->wl.image = *image;
|
||||
|
||||
cursor_buffer_set(seat, buffer);
|
||||
|
||||
@@ -6660,7 +6728,7 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_shape_custom_set(uint8_t *bitmap,
|
||||
}
|
||||
|
||||
const int32_t size_xy[2] = {sizex, sizey};
|
||||
wl_buffer *buffer = ghost_wl_buffer_create_for_image(display_->wl_shm,
|
||||
wl_buffer *buffer = ghost_wl_buffer_create_for_image(display_->wl.shm,
|
||||
size_xy,
|
||||
WL_SHM_FORMAT_ARGB8888,
|
||||
&cursor->custom_data,
|
||||
@@ -6703,11 +6771,11 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_shape_custom_set(uint8_t *bitmap,
|
||||
cursor->visible = true;
|
||||
cursor->is_custom = true;
|
||||
cursor->custom_scale = 1; /* TODO: support Hi-DPI custom cursors. */
|
||||
cursor->wl_buffer = buffer;
|
||||
cursor->wl_image.width = uint32_t(sizex);
|
||||
cursor->wl_image.height = uint32_t(sizey);
|
||||
cursor->wl_image.hotspot_x = uint32_t(hotX);
|
||||
cursor->wl_image.hotspot_y = uint32_t(hotY);
|
||||
cursor->wl.buffer = buffer;
|
||||
cursor->wl.image.width = uint32_t(sizex);
|
||||
cursor->wl.image.height = uint32_t(sizey);
|
||||
cursor->wl.image.hotspot_x = uint32_t(hotX);
|
||||
cursor->wl.image.hotspot_y = uint32_t(hotY);
|
||||
|
||||
cursor_buffer_set(seat, buffer);
|
||||
|
||||
@@ -6730,11 +6798,11 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_bitmap_get(GHOST_CursorBitmapRef *bit
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
bitmap->data_size[0] = cursor->wl_image.width;
|
||||
bitmap->data_size[1] = cursor->wl_image.height;
|
||||
bitmap->data_size[0] = cursor->wl.image.width;
|
||||
bitmap->data_size[1] = cursor->wl.image.height;
|
||||
|
||||
bitmap->hot_spot[0] = cursor->wl_image.hotspot_x;
|
||||
bitmap->hot_spot[1] = cursor->wl_image.hotspot_y;
|
||||
bitmap->hot_spot[0] = cursor->wl.image.hotspot_x;
|
||||
bitmap->hot_spot[1] = cursor->wl.image.hotspot_y;
|
||||
|
||||
bitmap->data = (uint8_t *)static_cast<void *>(cursor->custom_data);
|
||||
|
||||
@@ -6899,36 +6967,36 @@ void ghost_wl_surface_tag_cursor_tablet(wl_surface *wl_surface)
|
||||
|
||||
wl_display *GHOST_SystemWayland::wl_display()
|
||||
{
|
||||
return display_->wl_display;
|
||||
return display_->wl.display;
|
||||
}
|
||||
|
||||
wl_compositor *GHOST_SystemWayland::wl_compositor()
|
||||
{
|
||||
return display_->wl_compositor;
|
||||
return display_->wl.compositor;
|
||||
}
|
||||
|
||||
zwp_primary_selection_device_manager_v1 *GHOST_SystemWayland::wp_primary_selection_manager()
|
||||
{
|
||||
return display_->wp_primary_selection_device_manager;
|
||||
return display_->wp.primary_selection_device_manager;
|
||||
}
|
||||
|
||||
xdg_activation_v1 *GHOST_SystemWayland::xdg_activation_manager()
|
||||
{
|
||||
return display_->xdg_activation_manager;
|
||||
return display_->xdg.activation_manager;
|
||||
}
|
||||
|
||||
wp_fractional_scale_manager_v1 *GHOST_SystemWayland::wp_fractional_scale_manager()
|
||||
{
|
||||
return display_->wp_fractional_scale_manager;
|
||||
return display_->wp.fractional_scale_manager;
|
||||
}
|
||||
wp_viewporter *GHOST_SystemWayland::wp_viewporter()
|
||||
{
|
||||
return display_->wp_viewporter;
|
||||
return display_->wp.viewporter;
|
||||
}
|
||||
|
||||
zwp_pointer_gestures_v1 *GHOST_SystemWayland::wp_pointer_gestures()
|
||||
{
|
||||
return display_->wp_pointer_gestures;
|
||||
return display_->wp.pointer_gestures;
|
||||
}
|
||||
|
||||
/* This value is expected to match the base name of the `.desktop` file. see #101805.
|
||||
@@ -6979,7 +7047,7 @@ const std::vector<GWL_Output *> &GHOST_SystemWayland::outputs() const
|
||||
|
||||
wl_shm *GHOST_SystemWayland::wl_shm() const
|
||||
{
|
||||
return display_->wl_shm;
|
||||
return display_->wl.shm;
|
||||
}
|
||||
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
@@ -7042,7 +7110,7 @@ wl_seat *GHOST_SystemWayland::wl_seat_active_get_with_input_serial(uint32_t &ser
|
||||
GWL_Seat *seat = gwl_display_seat_active_get(display_);
|
||||
if (seat) {
|
||||
serial = seat->data_source_serial;
|
||||
return seat->wl_seat;
|
||||
return seat->wl.seat;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -7059,10 +7127,10 @@ bool GHOST_SystemWayland::window_surface_unref(const wl_surface *wl_surface)
|
||||
|
||||
/* Only clear window surfaces (not cursors, off-screen surfaces etc). */
|
||||
for (GWL_Seat *seat : display_->seats) {
|
||||
SURFACE_CLEAR_PTR(seat->pointer.wl_surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->tablet.wl_surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->keyboard.wl_surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->wl_surface_window_focus_dnd);
|
||||
SURFACE_CLEAR_PTR(seat->pointer.wl.surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->tablet.wl.surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->keyboard.wl.surface_window);
|
||||
SURFACE_CLEAR_PTR(seat->wl.surface_window_focus_dnd);
|
||||
}
|
||||
#undef SURFACE_CLEAR_PTR
|
||||
|
||||
@@ -7115,21 +7183,21 @@ void GHOST_SystemWayland::output_scale_update(GWL_Output *output)
|
||||
|
||||
for (GWL_Seat *seat : display_->seats) {
|
||||
if (seat->pointer.outputs.count(output)) {
|
||||
if (seat->cursor.wl_surface_cursor != nullptr) {
|
||||
if (seat->cursor.wl.surface_cursor != nullptr) {
|
||||
update_cursor_scale(
|
||||
seat->cursor, seat->system->wl_shm(), &seat->pointer, seat->cursor.wl_surface_cursor);
|
||||
seat->cursor, seat->system->wl_shm(), &seat->pointer, seat->cursor.wl.surface_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
if (seat->tablet.outputs.count(output)) {
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->tablet_tools) {
|
||||
for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->wp.tablet_tools) {
|
||||
GWL_TabletTool *tablet_tool = static_cast<GWL_TabletTool *>(
|
||||
zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
|
||||
if (tablet_tool->wl_surface_cursor != nullptr) {
|
||||
if (tablet_tool->wl.surface_cursor != nullptr) {
|
||||
update_cursor_scale(seat->cursor,
|
||||
seat->system->wl_shm(),
|
||||
&seat->pointer,
|
||||
tablet_tool->wl_surface_cursor);
|
||||
tablet_tool->wl.surface_cursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7147,7 +7215,7 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
/* Caller must lock `server_mutex`. */
|
||||
|
||||
/* Ignore, if the required protocols are not supported. */
|
||||
if (UNLIKELY(!display_->wp_relative_pointer_manager || !display_->wp_pointer_constraints)) {
|
||||
if (UNLIKELY(!display_->wp.relative_pointer_manager || !display_->wp.pointer_constraints)) {
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
@@ -7184,11 +7252,11 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
* in this case disable the current locks as it makes logic confusing,
|
||||
* postpone changing the cursor to avoid flickering. */
|
||||
if (!grab_state_next.use_lock) {
|
||||
if (seat->wp_relative_pointer) {
|
||||
zwp_relative_pointer_v1_destroy(seat->wp_relative_pointer);
|
||||
seat->wp_relative_pointer = nullptr;
|
||||
if (seat->wp.relative_pointer) {
|
||||
zwp_relative_pointer_v1_destroy(seat->wp.relative_pointer);
|
||||
seat->wp.relative_pointer = nullptr;
|
||||
}
|
||||
if (seat->wp_locked_pointer) {
|
||||
if (seat->wp.locked_pointer) {
|
||||
/* Potentially add a motion event so the application has updated X/Y coordinates. */
|
||||
int32_t xy_motion[2] = {0, 0};
|
||||
bool xy_motion_create_event = false;
|
||||
@@ -7221,7 +7289,7 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
seat->pointer.xy[0] = xy_next[0];
|
||||
seat->pointer.xy[1] = xy_next[1];
|
||||
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp_locked_pointer, UNPACK2(xy_next));
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp.locked_pointer, UNPACK2(xy_next));
|
||||
wl_surface_commit(wl_surface);
|
||||
}
|
||||
else if (mode_current == GHOST_kGrabHide) {
|
||||
@@ -7231,7 +7299,7 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
gwl_window_scale_wl_fixed_from(scale_params, wl_fixed_from_int(init_grab_xy[0])),
|
||||
gwl_window_scale_wl_fixed_from(scale_params, wl_fixed_from_int(init_grab_xy[1])),
|
||||
};
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp_locked_pointer,
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp.locked_pointer,
|
||||
UNPACK2(xy_next));
|
||||
wl_surface_commit(wl_surface);
|
||||
|
||||
@@ -7246,7 +7314,7 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
#ifdef USE_GNOME_CONFINE_HACK
|
||||
else if (mode_current == GHOST_kGrabNormal) {
|
||||
if (was_software_confine) {
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp_locked_pointer,
|
||||
zwp_locked_pointer_v1_set_cursor_position_hint(seat->wp.locked_pointer,
|
||||
UNPACK2(seat->pointer.xy));
|
||||
wl_surface_commit(wl_surface);
|
||||
}
|
||||
@@ -7263,15 +7331,15 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
GHOST_TABLET_DATA_NONE));
|
||||
}
|
||||
|
||||
zwp_locked_pointer_v1_destroy(seat->wp_locked_pointer);
|
||||
seat->wp_locked_pointer = nullptr;
|
||||
zwp_locked_pointer_v1_destroy(seat->wp.locked_pointer);
|
||||
seat->wp.locked_pointer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!grab_state_next.use_confine) {
|
||||
if (seat->wp_confined_pointer) {
|
||||
zwp_confined_pointer_v1_destroy(seat->wp_confined_pointer);
|
||||
seat->wp_confined_pointer = nullptr;
|
||||
if (seat->wp.confined_pointer) {
|
||||
zwp_confined_pointer_v1_destroy(seat->wp.confined_pointer);
|
||||
seat->wp.confined_pointer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7282,14 +7350,14 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
* possible to support #GHOST_kGrabWrap by pragmatically settings it's coordinates.
|
||||
* An alternative could be to draw the cursor in software (and hide the real cursor),
|
||||
* or just accept a locked cursor on WAYLAND. */
|
||||
seat->wp_relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
|
||||
display_->wp_relative_pointer_manager, seat->wl_pointer);
|
||||
seat->wp.relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
|
||||
display_->wp.relative_pointer_manager, seat->wl.pointer);
|
||||
zwp_relative_pointer_v1_add_listener(
|
||||
seat->wp_relative_pointer, &relative_pointer_listener, seat);
|
||||
seat->wp_locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
|
||||
display_->wp_pointer_constraints,
|
||||
seat->wp.relative_pointer, &relative_pointer_listener, seat);
|
||||
seat->wp.locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
|
||||
display_->wp.pointer_constraints,
|
||||
wl_surface,
|
||||
seat->wl_pointer,
|
||||
seat->wl.pointer,
|
||||
nullptr,
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
|
||||
}
|
||||
@@ -7306,10 +7374,10 @@ bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mod
|
||||
}
|
||||
else if (grab_state_next.use_confine) {
|
||||
if (!grab_state_prev.use_confine) {
|
||||
seat->wp_confined_pointer = zwp_pointer_constraints_v1_confine_pointer(
|
||||
display_->wp_pointer_constraints,
|
||||
seat->wp.confined_pointer = zwp_pointer_constraints_v1_confine_pointer(
|
||||
display_->wp.pointer_constraints,
|
||||
wl_surface,
|
||||
seat->wl_pointer,
|
||||
seat->wl.pointer,
|
||||
nullptr,
|
||||
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
|
||||
}
|
||||
|
||||
@@ -89,10 +89,19 @@ void ghost_wl_dynload_libraries_exit();
|
||||
#endif
|
||||
|
||||
struct GWL_Output {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_output *output = nullptr;
|
||||
} wl;
|
||||
|
||||
/** XDG native types. */
|
||||
struct {
|
||||
struct zxdg_output_v1 *output = nullptr;
|
||||
} xdg;
|
||||
|
||||
GHOST_SystemWayland *system = nullptr;
|
||||
|
||||
struct wl_output *wl_output = nullptr;
|
||||
struct zxdg_output_v1 *xdg_output = nullptr;
|
||||
/** Dimensions in pixels. */
|
||||
int32_t size_native[2] = {0, 0};
|
||||
/** Dimensions in millimeter. */
|
||||
|
||||
@@ -212,9 +212,33 @@ struct GWL_WindowFrame {
|
||||
};
|
||||
|
||||
struct GWL_Window {
|
||||
|
||||
/** Wayland core types. */
|
||||
struct {
|
||||
wl_surface *surface = nullptr;
|
||||
|
||||
wl_egl_window *egl_window = nullptr;
|
||||
} wl;
|
||||
|
||||
/** Wayland native types. */
|
||||
struct {
|
||||
wp_viewport *viewport = nullptr;
|
||||
|
||||
/**
|
||||
* When set, only respond to the #wp_fractional_scale_v1_listener::preferred_scale callback
|
||||
* and ignore updated scale based on #wl_surface_listener::enter & exit events.
|
||||
*/
|
||||
wp_fractional_scale_v1 *fractional_scale_handle = nullptr;
|
||||
} wp;
|
||||
|
||||
/** XDG native types. */
|
||||
struct {
|
||||
/** A temporary token used for the window to be notified of it's activation. */
|
||||
xdg_activation_token_v1 *activation_token = nullptr;
|
||||
} xdg;
|
||||
|
||||
GHOST_WindowWayland *ghost_window = nullptr;
|
||||
GHOST_SystemWayland *ghost_system = nullptr;
|
||||
struct wl_surface *wl_surface = nullptr;
|
||||
/**
|
||||
* Outputs on which the window is currently shown on.
|
||||
*
|
||||
@@ -223,16 +247,6 @@ struct GWL_Window {
|
||||
*/
|
||||
std::vector<GWL_Output *> outputs;
|
||||
|
||||
/** A temporary token used for the window to be notified of it's activation. */
|
||||
xdg_activation_token_v1 *xdg_activation_token = nullptr;
|
||||
|
||||
wp_viewport *viewport = nullptr;
|
||||
/**
|
||||
* When set, only respond to the #wp_fractional_scale_v1_listener::preferred_scale callback
|
||||
* and ignore updated scale based on #wl_surface_listener::enter & exit events.
|
||||
*/
|
||||
wp_fractional_scale_v1 *fractional_scale_handle = nullptr;
|
||||
|
||||
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
|
||||
WGL_LibDecor_Window *libdecor = nullptr;
|
||||
#endif
|
||||
@@ -253,8 +267,6 @@ struct GWL_Window {
|
||||
std::mutex frame_pending_mutex;
|
||||
#endif
|
||||
|
||||
wl_egl_window *egl_window = nullptr;
|
||||
|
||||
std::string title;
|
||||
|
||||
bool is_dialog = false;
|
||||
@@ -447,15 +459,15 @@ static bool gwl_window_viewport_set(GWL_Window *win,
|
||||
bool *r_surface_needs_commit,
|
||||
bool *r_surface_needs_buffer_scale)
|
||||
{
|
||||
if (win->viewport != nullptr) {
|
||||
if (win->wp.viewport != nullptr) {
|
||||
return false;
|
||||
}
|
||||
wp_viewporter *viewporter = win->ghost_system->wp_viewporter();
|
||||
if (viewporter == nullptr) {
|
||||
return false;
|
||||
}
|
||||
win->viewport = wp_viewporter_get_viewport(viewporter, win->wl_surface);
|
||||
if (win->viewport == nullptr) {
|
||||
win->wp.viewport = wp_viewporter_get_viewport(viewporter, win->wl.surface);
|
||||
if (win->wp.viewport == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -467,14 +479,14 @@ static bool gwl_window_viewport_set(GWL_Window *win,
|
||||
*r_surface_needs_buffer_scale = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_set_buffer_scale(win->wl_surface, win->frame.buffer_scale);
|
||||
wl_surface_set_buffer_scale(win->wl.surface, win->frame.buffer_scale);
|
||||
}
|
||||
|
||||
if (r_surface_needs_commit) {
|
||||
*r_surface_needs_commit = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_commit(win->wl_surface);
|
||||
wl_surface_commit(win->wl.surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,12 +497,12 @@ static bool gwl_window_viewport_unset(GWL_Window *win,
|
||||
bool *r_surface_needs_commit,
|
||||
bool *r_surface_needs_buffer_scale)
|
||||
{
|
||||
if (win->viewport == nullptr) {
|
||||
if (win->wp.viewport == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wp_viewport_destroy(win->viewport);
|
||||
win->viewport = nullptr;
|
||||
wp_viewport_destroy(win->wp.viewport);
|
||||
win->wp.viewport = nullptr;
|
||||
|
||||
GHOST_ASSERT(win->frame.buffer_scale == 1, "Unexpected scale!");
|
||||
if (win->frame_pending.buffer_scale != win->frame.buffer_scale) {
|
||||
@@ -500,14 +512,14 @@ static bool gwl_window_viewport_unset(GWL_Window *win,
|
||||
*r_surface_needs_buffer_scale = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_set_buffer_scale(win->wl_surface, win->frame.buffer_scale);
|
||||
wl_surface_set_buffer_scale(win->wl.surface, win->frame.buffer_scale);
|
||||
}
|
||||
|
||||
if (r_surface_needs_commit) {
|
||||
*r_surface_needs_commit = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_commit(win->wl_surface);
|
||||
wl_surface_commit(win->wl.surface);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -515,16 +527,16 @@ static bool gwl_window_viewport_unset(GWL_Window *win,
|
||||
|
||||
static bool gwl_window_viewport_size_update(GWL_Window *win)
|
||||
{
|
||||
if (win->viewport == nullptr) {
|
||||
if (win->wp.viewport == nullptr) {
|
||||
return false;
|
||||
}
|
||||
wp_viewport_set_source(win->viewport,
|
||||
wp_viewport_set_source(win->wp.viewport,
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(win->frame.size[0]),
|
||||
wl_fixed_from_int(win->frame.size[1]));
|
||||
wp_viewport_set_destination(
|
||||
win->viewport,
|
||||
win->wp.viewport,
|
||||
gwl_window_fractional_from_viewport_round(win->frame, win->frame.size[0]),
|
||||
gwl_window_fractional_from_viewport_round(win->frame, win->frame.size[1]));
|
||||
return true;
|
||||
@@ -550,23 +562,23 @@ static void gwl_window_activate(GWL_Window *win)
|
||||
return;
|
||||
}
|
||||
|
||||
if (win->xdg_activation_token) {
|
||||
if (win->xdg.activation_token) {
|
||||
/* We're about to overwrite this with a new request. */
|
||||
xdg_activation_token_v1_destroy(win->xdg_activation_token);
|
||||
xdg_activation_token_v1_destroy(win->xdg.activation_token);
|
||||
}
|
||||
win->xdg_activation_token = xdg_activation_v1_get_activation_token(activation_manager);
|
||||
win->xdg.activation_token = xdg_activation_v1_get_activation_token(activation_manager);
|
||||
|
||||
xdg_activation_token_v1_add_listener(
|
||||
win->xdg_activation_token, xdg_activation_listener_get(), win);
|
||||
win->xdg.activation_token, xdg_activation_listener_get(), win);
|
||||
|
||||
xdg_activation_token_v1_set_app_id(win->xdg_activation_token, GHOST_SystemWayland::xdg_app_id());
|
||||
xdg_activation_token_v1_set_app_id(win->xdg.activation_token, GHOST_SystemWayland::xdg_app_id());
|
||||
|
||||
/* The serial of the input device requesting activation. */
|
||||
{
|
||||
uint32_t serial = 0;
|
||||
wl_seat *seat = system->wl_seat_active_get_with_input_serial(serial);
|
||||
if (seat) {
|
||||
xdg_activation_token_v1_set_serial(win->xdg_activation_token, serial, seat);
|
||||
xdg_activation_token_v1_set_serial(win->xdg.activation_token, serial, seat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,12 +589,12 @@ static void gwl_window_activate(GWL_Window *win)
|
||||
if (ghost_window_active) {
|
||||
wl_surface *surface = ghost_window_active->wl_surface();
|
||||
if (surface) {
|
||||
xdg_activation_token_v1_set_surface(win->xdg_activation_token, surface);
|
||||
xdg_activation_token_v1_set_surface(win->xdg.activation_token, surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xdg_activation_token_v1_commit(win->xdg_activation_token);
|
||||
xdg_activation_token_v1_commit(win->xdg.activation_token);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -607,7 +619,7 @@ static void gwl_window_frame_pending_fractional_scale_set(GWL_Window *win,
|
||||
gwl_window_viewport_size_update(win);
|
||||
}
|
||||
else {
|
||||
if (win->viewport) {
|
||||
if (win->wp.viewport) {
|
||||
gwl_window_viewport_unset(win, r_surface_needs_commit, r_surface_needs_buffer_scale);
|
||||
}
|
||||
else {
|
||||
@@ -616,13 +628,13 @@ static void gwl_window_frame_pending_fractional_scale_set(GWL_Window *win,
|
||||
*r_surface_needs_buffer_scale = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_set_buffer_scale(win->wl_surface, win->frame.buffer_scale);
|
||||
wl_surface_set_buffer_scale(win->wl.surface, win->frame.buffer_scale);
|
||||
}
|
||||
if (r_surface_needs_commit) {
|
||||
*r_surface_needs_commit = true;
|
||||
}
|
||||
else {
|
||||
wl_surface_commit(win->wl_surface);
|
||||
wl_surface_commit(win->wl.surface);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -654,7 +666,7 @@ static void gwl_window_frame_pending_size_set(GWL_Window *win,
|
||||
*r_surface_needs_egl_resize = true;
|
||||
}
|
||||
else {
|
||||
wl_egl_window_resize(win->egl_window, UNPACK2(win->frame.size), 0, 0);
|
||||
wl_egl_window_resize(win->wl.egl_window, UNPACK2(win->frame.size), 0, 0);
|
||||
}
|
||||
|
||||
win->ghost_window->notify_size();
|
||||
@@ -703,7 +715,7 @@ static void gwl_window_pending_actions_handle(GWL_Window *win)
|
||||
win->ghost_window->outputs_changed_update_scale();
|
||||
}
|
||||
if (actions[PENDING_WINDOW_SURFACE_COMMIT]) {
|
||||
wl_surface_commit(win->wl_surface);
|
||||
wl_surface_commit(win->wl.surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,11 +759,11 @@ static void gwl_window_frame_update_from_pending_no_lock(GWL_Window *win)
|
||||
}
|
||||
|
||||
if (surface_needs_egl_resize) {
|
||||
wl_egl_window_resize(win->egl_window, UNPACK2(win->frame.size), 0, 0);
|
||||
wl_egl_window_resize(win->wl.egl_window, UNPACK2(win->frame.size), 0, 0);
|
||||
}
|
||||
|
||||
if (surface_needs_buffer_scale) {
|
||||
wl_surface_set_buffer_scale(win->wl_surface, win->frame.buffer_scale);
|
||||
wl_surface_set_buffer_scale(win->wl.surface, win->frame.buffer_scale);
|
||||
}
|
||||
|
||||
if (win->xdg_decor) {
|
||||
@@ -771,7 +783,7 @@ static void gwl_window_frame_update_from_pending_no_lock(GWL_Window *win)
|
||||
/* Postponing the commit avoids flickering when moving between monitors of different scale. */
|
||||
gwl_window_pending_actions_tag(win, PENDING_WINDOW_SURFACE_COMMIT);
|
||||
#else
|
||||
wl_surface_commit(win->wl_surface);
|
||||
wl_surface_commit(win->wl.surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -979,15 +991,15 @@ static void xdg_activation_handle_done(void *data,
|
||||
const char *token)
|
||||
{
|
||||
GWL_Window *win = static_cast<GWL_Window *>(data);
|
||||
if (xdg_activation_token_v1 != win->xdg_activation_token) {
|
||||
if (xdg_activation_token_v1 != win->xdg.activation_token) {
|
||||
return;
|
||||
}
|
||||
|
||||
GHOST_SystemWayland *system = win->ghost_system;
|
||||
xdg_activation_v1 *activation_manager = system->xdg_activation_manager();
|
||||
xdg_activation_v1_activate(activation_manager, token, win->wl_surface);
|
||||
xdg_activation_token_v1_destroy(win->xdg_activation_token);
|
||||
win->xdg_activation_token = nullptr;
|
||||
xdg_activation_v1_activate(activation_manager, token, win->wl.surface);
|
||||
xdg_activation_token_v1_destroy(win->xdg.activation_token);
|
||||
win->xdg.activation_token = nullptr;
|
||||
}
|
||||
|
||||
static const xdg_activation_token_v1_listener xdg_activation_listener = {
|
||||
@@ -1338,22 +1350,22 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
|
||||
window_->is_dialog = is_dialog;
|
||||
|
||||
/* Window surfaces. */
|
||||
window_->wl_surface = wl_compositor_create_surface(system_->wl_compositor());
|
||||
ghost_wl_surface_tag(window_->wl_surface);
|
||||
window_->wl.surface = wl_compositor_create_surface(system_->wl_compositor());
|
||||
ghost_wl_surface_tag(window_->wl.surface);
|
||||
|
||||
wl_surface_set_buffer_scale(window_->wl_surface, window_->frame.buffer_scale);
|
||||
wl_surface_set_buffer_scale(window_->wl.surface, window_->frame.buffer_scale);
|
||||
|
||||
wl_surface_add_listener(window_->wl_surface, &wl_surface_listener, window_);
|
||||
wl_surface_add_listener(window_->wl.surface, &wl_surface_listener, window_);
|
||||
|
||||
window_->egl_window = wl_egl_window_create(
|
||||
window_->wl_surface, int(window_->frame.size[0]), int(window_->frame.size[1]));
|
||||
window_->wl.egl_window = wl_egl_window_create(
|
||||
window_->wl.surface, int(window_->frame.size[0]), int(window_->frame.size[1]));
|
||||
|
||||
wp_fractional_scale_manager_v1 *fractional_scale_manager = system->wp_fractional_scale_manager();
|
||||
if (fractional_scale_manager) {
|
||||
window_->fractional_scale_handle = wp_fractional_scale_manager_v1_get_fractional_scale(
|
||||
fractional_scale_manager, window_->wl_surface);
|
||||
window_->wp.fractional_scale_handle = wp_fractional_scale_manager_v1_get_fractional_scale(
|
||||
fractional_scale_manager, window_->wl.surface);
|
||||
wp_fractional_scale_v1_add_listener(
|
||||
window_->fractional_scale_handle, &wp_fractional_scale_listener, window_);
|
||||
window_->wp.fractional_scale_handle, &wp_fractional_scale_listener, window_);
|
||||
}
|
||||
|
||||
/* NOTE: The limit is in points (not pixels) so Hi-DPI will limit to larger number of pixels.
|
||||
@@ -1371,7 +1383,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
|
||||
|
||||
/* create window decorations */
|
||||
decor.frame = libdecor_decorate(
|
||||
system_->libdecor_context(), window_->wl_surface, &libdecor_frame_iface, window_);
|
||||
system_->libdecor_context(), window_->wl.surface, &libdecor_frame_iface, window_);
|
||||
libdecor_frame_map(window_->libdecor->frame);
|
||||
|
||||
libdecor_frame_set_min_content_size(decor.frame, UNPACK2(size_min));
|
||||
@@ -1388,7 +1400,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
|
||||
{
|
||||
window_->xdg_decor = new WGL_XDG_Decor_Window;
|
||||
WGL_XDG_Decor_Window &decor = *window_->xdg_decor;
|
||||
decor.surface = xdg_wm_base_get_xdg_surface(system_->xdg_decor_shell(), window_->wl_surface);
|
||||
decor.surface = xdg_wm_base_get_xdg_surface(system_->xdg_decor_shell(), window_->wl.surface);
|
||||
decor.toplevel = xdg_surface_get_toplevel(decor.surface);
|
||||
|
||||
xdg_toplevel_set_min_size(decor.toplevel, UNPACK2(size_min));
|
||||
@@ -1415,10 +1427,10 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
|
||||
|
||||
gwl_window_title_set(window_, title);
|
||||
|
||||
wl_surface_set_user_data(window_->wl_surface, this);
|
||||
wl_surface_set_user_data(window_->wl.surface, this);
|
||||
|
||||
/* Call top-level callbacks. */
|
||||
wl_surface_commit(window_->wl_surface);
|
||||
wl_surface_commit(window_->wl.surface);
|
||||
wl_display_roundtrip(system_->wl_display());
|
||||
|
||||
#ifdef GHOST_OPENGL_ALPHA
|
||||
@@ -1480,7 +1492,7 @@ GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mo
|
||||
m_cursorGrabInitPos,
|
||||
bounds,
|
||||
m_cursorGrabAxis,
|
||||
window_->wl_surface,
|
||||
window_->wl.surface,
|
||||
this->scale_params()))
|
||||
{
|
||||
return GHOST_kSuccess;
|
||||
@@ -1599,21 +1611,21 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
|
||||
|
||||
releaseNativeHandles();
|
||||
|
||||
wl_egl_window_destroy(window_->egl_window);
|
||||
wl_egl_window_destroy(window_->wl.egl_window);
|
||||
|
||||
if (window_->xdg_activation_token) {
|
||||
xdg_activation_token_v1_destroy(window_->xdg_activation_token);
|
||||
window_->xdg_activation_token = nullptr;
|
||||
if (window_->xdg.activation_token) {
|
||||
xdg_activation_token_v1_destroy(window_->xdg.activation_token);
|
||||
window_->xdg.activation_token = nullptr;
|
||||
}
|
||||
|
||||
if (window_->fractional_scale_handle) {
|
||||
wp_fractional_scale_v1_destroy(window_->fractional_scale_handle);
|
||||
window_->fractional_scale_handle = nullptr;
|
||||
if (window_->wp.fractional_scale_handle) {
|
||||
wp_fractional_scale_v1_destroy(window_->wp.fractional_scale_handle);
|
||||
window_->wp.fractional_scale_handle = nullptr;
|
||||
}
|
||||
|
||||
if (window_->viewport) {
|
||||
wp_viewport_destroy(window_->viewport);
|
||||
window_->viewport = nullptr;
|
||||
if (window_->wp.viewport) {
|
||||
wp_viewport_destroy(window_->wp.viewport);
|
||||
window_->wp.viewport = nullptr;
|
||||
}
|
||||
|
||||
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
|
||||
@@ -1628,9 +1640,9 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
|
||||
|
||||
/* Clear any pointers to this window. This is needed because there are no guarantees
|
||||
* that flushing the display will the "leave" handlers before handling events. */
|
||||
system_->window_surface_unref(window_->wl_surface);
|
||||
system_->window_surface_unref(window_->wl.surface);
|
||||
|
||||
wl_surface_destroy(window_->wl_surface);
|
||||
wl_surface_destroy(window_->wl.surface);
|
||||
|
||||
/* NOTE(@ideasman42): Flushing will often run the appropriate handlers event
|
||||
* (#wl_surface_listener.leave in particular) to avoid attempted access to the freed surfaces.
|
||||
@@ -1744,7 +1756,7 @@ void GHOST_WindowWayland::setOpaque() const
|
||||
/* Make the window opaque. */
|
||||
region = wl_compositor_create_region(system_->wl_compositor());
|
||||
wl_region_add(region, 0, 0, UNPACK2(window_->size));
|
||||
wl_surface_set_opaque_region(window_->wl_surface, region);
|
||||
wl_surface_set_opaque_region(window_->wl.surface, region);
|
||||
wl_region_destroy(region);
|
||||
}
|
||||
#endif
|
||||
@@ -1763,8 +1775,8 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
|
||||
GHOST_kVulkanPlatformWayland,
|
||||
0,
|
||||
nullptr,
|
||||
window_->wl_surface,
|
||||
system_->wl_display(),
|
||||
window_->wl.surface,
|
||||
system_->wl.display(),
|
||||
1,
|
||||
2,
|
||||
true);
|
||||
@@ -1781,7 +1793,7 @@ GHOST_Context *GHOST_WindowWayland::newDrawingContext(GHOST_TDrawingContextType
|
||||
for (int minor = 6; minor >= 3; --minor) {
|
||||
GHOST_Context *context = new GHOST_ContextEGL(system_,
|
||||
m_wantStereoVisual,
|
||||
EGLNativeWindowType(window_->egl_window),
|
||||
EGLNativeWindowType(window_->wl.egl_window),
|
||||
EGLNativeDisplayType(system_->wl_display()),
|
||||
EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||
4,
|
||||
@@ -1847,7 +1859,7 @@ wl_fixed_t GHOST_WindowWayland::wl_fixed_to_window(wl_fixed_t value) const
|
||||
|
||||
wl_surface *GHOST_WindowWayland::wl_surface() const
|
||||
{
|
||||
return window_->wl_surface;
|
||||
return window_->wl.surface;
|
||||
}
|
||||
|
||||
const std::vector<GWL_Output *> &GHOST_WindowWayland::outputs()
|
||||
@@ -1980,7 +1992,7 @@ bool GHOST_WindowWayland::outputs_changed_update_scale()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (window_->fractional_scale_handle) {
|
||||
if (window_->wp.fractional_scale_handle) {
|
||||
#ifdef USE_EVENT_BACKGROUND_THREAD
|
||||
std::lock_guard lock_frame_guard{window_->frame_pending_mutex};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user