mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-10-06 07:00:16 +08:00
Add support for using XDG toplevel drag protocol
Check for the necessary compile- and run-time support and implement the new wxTLWDragSession class, allowing to start a TLW drag and notifying a wxTLWDragHandler about its progress and result, if both are available. This is not used just yet but will be in the upcoming commits.
This commit is contained in:
@@ -502,9 +502,10 @@ if(wxUSE_GUI)
|
||||
|
||||
wx_generate_wayland_protocol(${wx_protocols_input_dir} pointer-warp-v1)
|
||||
|
||||
# Check if we have GTK new enough to allow using XDG
|
||||
# session management protocol: 3.24.53 is the earliest one
|
||||
# with gdk_wayland_window_get_xdg_toplevel() that we need.
|
||||
# Check if we have GTK new enough to allow using the
|
||||
# XDG protocols requiring access to xdg_toplevel: we
|
||||
# need gdk_wayland_window_get_xdg_toplevel() which was
|
||||
# added in 3.24.53.
|
||||
if(GTK3_VERSION VERSION_GREATER_EQUAL 3.24.53)
|
||||
# We also need wayland-protocols as this protocol
|
||||
# depends on xdg-shell one.
|
||||
@@ -514,10 +515,12 @@ if(wxUSE_GUI)
|
||||
|
||||
wx_generate_wayland_protocol(${wx_protocols_input_dir} xdg-session-management-v1)
|
||||
wx_generate_wayland_protocol(${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell xdg-shell)
|
||||
wx_generate_wayland_protocol(${WAYLAND_PROTOCOLS_DIR}/staging/xdg-toplevel-drag xdg-toplevel-drag-v1)
|
||||
|
||||
set(wxHAVE_WAYLAND_SESSION_MANAGEMENT ON)
|
||||
set(wxHAVE_WAYLAND_TOPLEVEL_DRAG ON)
|
||||
else()
|
||||
message(WARNING "wayland-protocols not found, xdg-session-management protocol won't be used")
|
||||
message(WARNING "wayland-protocols package not found, Wayland-specific functionality will be disabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -637,6 +637,13 @@
|
||||
*/
|
||||
#cmakedefine wxHAVE_WAYLAND_SESSION_MANAGEMENT 1
|
||||
|
||||
/*
|
||||
Use Wayland xdg-toplevel-drag protocol.
|
||||
|
||||
This is defined if GTK is new enough to support it.
|
||||
*/
|
||||
#cmakedefine wxHAVE_WAYLAND_TOPLEVEL_DRAG 1
|
||||
|
||||
/*
|
||||
Use XTest extension to implement wxUIActionSimulator?
|
||||
|
||||
|
||||
@@ -28498,9 +28498,9 @@ $as_echo "$wx_cv_wayland_scanner" >&6; }
|
||||
fi
|
||||
|
||||
if test -n "$WAYLAND_SCANNER" ; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for support of the Wayland session management protocol" >&5
|
||||
$as_echo_n "checking for support of the Wayland session management protocol... " >&6; }
|
||||
if ${wx_cv_gtk_wayland_sm+:} false; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for support of getting xdg_toplevel from GDK" >&5
|
||||
$as_echo_n "checking for support of getting xdg_toplevel from GDK... " >&6; }
|
||||
if ${wx_cv_gtk_xdg_toplevel+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
@@ -28510,17 +28510,17 @@ as_arg_v2=3.24.52
|
||||
awk "$as_awk_strverscmp" v1="$as_arg_v1" v2="$as_arg_v2" /dev/null
|
||||
case $? in #(
|
||||
1) :
|
||||
wx_cv_gtk_wayland_sm=no ;; #(
|
||||
wx_cv_gtk_xdg_toplevel=no ;; #(
|
||||
0) :
|
||||
wx_cv_gtk_wayland_sm=maybe ;; #(
|
||||
wx_cv_gtk_xdg_toplevel=maybe ;; #(
|
||||
2) :
|
||||
wx_cv_gtk_wayland_sm=yes
|
||||
wx_cv_gtk_xdg_toplevel=yes
|
||||
;; #(
|
||||
*) :
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$wx_cv_gtk_wayland_sm" = "maybe"; then
|
||||
if test "$wx_cv_gtk_xdg_toplevel" = "maybe"; then
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LIBS=$LIBS
|
||||
CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
|
||||
@@ -28539,9 +28539,9 @@ main ()
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
wx_cv_gtk_wayland_sm=yes
|
||||
wx_cv_gtk_xdg_toplevel=yes
|
||||
else
|
||||
wx_cv_gtk_wayland_sm=no
|
||||
wx_cv_gtk_xdg_toplevel=no
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
@@ -28552,10 +28552,10 @@ rm -f core conftest.err conftest.$ac_objext \
|
||||
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_gtk_wayland_sm" >&5
|
||||
$as_echo "$wx_cv_gtk_wayland_sm" >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_gtk_xdg_toplevel" >&5
|
||||
$as_echo "$wx_cv_gtk_xdg_toplevel" >&6; }
|
||||
|
||||
if test "$wx_cv_gtk_wayland_sm" = "yes"; then
|
||||
if test "$wx_cv_gtk_xdg_toplevel" = "yes"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wayland-protocols data directory" >&5
|
||||
$as_echo_n "checking for wayland-protocols data directory... " >&6; }
|
||||
if ${wx_cv_wayland_protocols_dir+:} false; then :
|
||||
@@ -28574,13 +28574,15 @@ $as_echo "$wx_cv_wayland_protocols_dir" >&6; }
|
||||
-f "$WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml"; then
|
||||
$as_echo "#define wxHAVE_WAYLAND_SESSION_MANAGEMENT 1" >>confdefs.h
|
||||
|
||||
$as_echo "#define wxHAVE_WAYLAND_TOPLEVEL_DRAG 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: wayland-protocols package not found, Wayland session management support will be disabled" >&5
|
||||
$as_echo "$as_me: WARNING: wayland-protocols package not found, Wayland session management support will be disabled" >&2;}
|
||||
WAYLAND_SM_SUPPORT=':'
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: wayland-protocols package not found, Wayland-specific functionality will be disabled" >&5
|
||||
$as_echo "$as_me: WARNING: wayland-protocols package not found, Wayland-specific functionality will be disabled" >&2;}
|
||||
WAYLAND_XDG_SUPPORT=':'
|
||||
fi
|
||||
else
|
||||
WAYLAND_SM_SUPPORT=':'
|
||||
WAYLAND_XDG_SUPPORT=':'
|
||||
fi
|
||||
|
||||
$as_echo "#define wxHAVE_WAYLAND_CLIENT 1" >>confdefs.h
|
||||
@@ -46265,7 +46267,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
#
|
||||
|
||||
WAYLAND_SCANNER=$WAYLAND_SCANNER
|
||||
WAYLAND_SM_SUPPORT=$WAYLAND_SM_SUPPORT
|
||||
WAYLAND_XDG_SUPPORT=$WAYLAND_XDG_SUPPORT
|
||||
WAYLAND_PROTOCOLS_DIR=$WAYLAND_PROTOCOLS_DIR
|
||||
|
||||
|
||||
@@ -46858,10 +46860,12 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
|
||||
mkdir -p lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols
|
||||
$WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/pointer-warp-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/pointer-warp-v1-client-protocol.h
|
||||
$WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/pointer-warp-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/pointer-warp-v1-client-protocol.c
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.h
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.c
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.h
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-toplevel-drag-v1-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-toplevel-drag-v1-client-protocol.c
|
||||
;;
|
||||
"rcdefs.h":C)
|
||||
mkdir -p $outdir &&
|
||||
|
||||
+27
-22
@@ -3128,21 +3128,23 @@ installed, where VER is 2, 3 or 4.
|
||||
fi
|
||||
|
||||
if test -n "$WAYLAND_SCANNER" ; then
|
||||
dnl Check if we can use the session management protocol which
|
||||
dnl normally requires GTK >= 3.24.53 but allow using it with
|
||||
dnl the versions of 3.24.52 that already have the support
|
||||
dnl required for it, at least until 3.24.53 is released.
|
||||
AC_CACHE_CHECK([for support of the Wayland session management protocol],
|
||||
wx_cv_gtk_wayland_sm,
|
||||
dnl Check if we can get xdg_toplevel from GDK, as this is
|
||||
dnl required by both the session management and the toplevel
|
||||
dnl drag protocols used below: this normally requires GTK
|
||||
dnl >= 3.24.53 but allow using it with the versions of 3.24.52
|
||||
dnl that already have the support required for it, at least
|
||||
dnl until 3.24.53 is released.
|
||||
AC_CACHE_CHECK([for support of getting xdg_toplevel from GDK],
|
||||
wx_cv_gtk_xdg_toplevel,
|
||||
[
|
||||
GTK_VERSION=`$PKG_CONFIG --modversion gtk+-3.0`
|
||||
AS_VERSION_COMPARE([$GTK_VERSION], [3.24.52],
|
||||
wx_cv_gtk_wayland_sm=no,
|
||||
wx_cv_gtk_wayland_sm=maybe,
|
||||
wx_cv_gtk_wayland_sm=yes
|
||||
wx_cv_gtk_xdg_toplevel=no,
|
||||
wx_cv_gtk_xdg_toplevel=maybe,
|
||||
wx_cv_gtk_xdg_toplevel=yes
|
||||
)
|
||||
|
||||
if test "$wx_cv_gtk_wayland_sm" = "maybe"; then
|
||||
if test "$wx_cv_gtk_xdg_toplevel" = "maybe"; then
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_LIBS=$LIBS
|
||||
CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
|
||||
@@ -3151,8 +3153,8 @@ installed, where VER is 2, 3 or 4.
|
||||
[
|
||||
gdk_wayland_window_get_xdg_toplevel(0)
|
||||
])],
|
||||
wx_cv_gtk_wayland_sm=yes,
|
||||
wx_cv_gtk_wayland_sm=no
|
||||
wx_cv_gtk_xdg_toplevel=yes,
|
||||
wx_cv_gtk_xdg_toplevel=no
|
||||
)
|
||||
LIBS=$save_LIBS
|
||||
CFLAGS=$save_CFLAGS
|
||||
@@ -3160,7 +3162,7 @@ installed, where VER is 2, 3 or 4.
|
||||
]
|
||||
)
|
||||
|
||||
if test "$wx_cv_gtk_wayland_sm" = "yes"; then
|
||||
if test "$wx_cv_gtk_xdg_toplevel" = "yes"; then
|
||||
dnl wayland-protocols is normally a dependency of
|
||||
dnl libgtk-3-dev or similar, but it's not always pulled in
|
||||
dnl automatically, so still check that it's really there.
|
||||
@@ -3175,13 +3177,14 @@ installed, where VER is 2, 3 or 4.
|
||||
if test -n "$WAYLAND_PROTOCOLS_DIR" -a \
|
||||
-f "$WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml"; then
|
||||
AC_DEFINE(wxHAVE_WAYLAND_SESSION_MANAGEMENT)
|
||||
AC_DEFINE(wxHAVE_WAYLAND_TOPLEVEL_DRAG)
|
||||
else
|
||||
AC_MSG_WARN([wayland-protocols package not found, Wayland session management support will be disabled])
|
||||
WAYLAND_SM_SUPPORT=':'
|
||||
AC_MSG_WARN([wayland-protocols package not found, Wayland-specific functionality will be disabled])
|
||||
WAYLAND_XDG_SUPPORT=':'
|
||||
fi
|
||||
else
|
||||
dnl Don't bother running wayland-scanner for this protocol.
|
||||
WAYLAND_SM_SUPPORT=':'
|
||||
dnl Don't bother running wayland-scanner for these protocols.
|
||||
WAYLAND_XDG_SUPPORT=':'
|
||||
fi
|
||||
|
||||
AC_DEFINE(wxHAVE_WAYLAND_CLIENT)
|
||||
@@ -3190,14 +3193,16 @@ installed, where VER is 2, 3 or 4.
|
||||
mkdir -p lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols
|
||||
$WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/pointer-warp-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/pointer-warp-v1-client-protocol.h
|
||||
$WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/pointer-warp-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/pointer-warp-v1-client-protocol.c
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.h
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.c
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.h
|
||||
$WAYLAND_SM_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $srcdir/src/unix/protocols/xdg-session-management-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-session-management-v1-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/stable/xdg-shell/xdg-shell.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-shell-client-protocol.c
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER client-header $WAYLAND_PROTOCOLS_DIR/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-toplevel-drag-v1-client-protocol.h
|
||||
$WAYLAND_XDG_SUPPORT $WAYLAND_SCANNER private-code $WAYLAND_PROTOCOLS_DIR/staging/xdg-toplevel-drag/xdg-toplevel-drag-v1.xml lib/wx/include/${TOOLCHAIN_FULLNAME}/wx/protocols/xdg-toplevel-drag-v1-client-protocol.c
|
||||
],
|
||||
[
|
||||
WAYLAND_SCANNER=$WAYLAND_SCANNER
|
||||
WAYLAND_SM_SUPPORT=$WAYLAND_SM_SUPPORT
|
||||
WAYLAND_XDG_SUPPORT=$WAYLAND_XDG_SUPPORT
|
||||
WAYLAND_PROTOCOLS_DIR=$WAYLAND_PROTOCOLS_DIR
|
||||
]
|
||||
)
|
||||
|
||||
@@ -31,12 +31,29 @@
|
||||
|
||||
#include "wx/protocols/pointer-warp-v1-client-protocol.h"
|
||||
|
||||
#ifdef wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
wxGCC_WARNING_SUPPRESS(cast-qual)
|
||||
|
||||
#ifdef wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
#include "wx/protocols/xdg-session-management-v1-client-protocol.h"
|
||||
wxGCC_WARNING_RESTORE()
|
||||
#endif // wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
|
||||
// This one is different from wxHAVE_WAYLAND_XXX because it's always supported
|
||||
// and hence there is no need to detect it in the build system.
|
||||
//
|
||||
// But we only need it when using the toplevel drag protocol, so we define it
|
||||
// ourselves, as either 0 or 1.
|
||||
#ifdef wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
#include "wx/protocols/xdg-toplevel-drag-v1-client-protocol.h"
|
||||
|
||||
#define wxUSE_WAYLAND_DATA_DEVICE_MANAGER 1
|
||||
#endif // wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
|
||||
wxGCC_WARNING_RESTORE()
|
||||
|
||||
#ifndef wxUSE_WAYLAND_DATA_DEVICE_MANAGER
|
||||
#define wxUSE_WAYLAND_DATA_DEVICE_MANAGER 0
|
||||
#endif
|
||||
|
||||
namespace wxWayland
|
||||
{
|
||||
|
||||
@@ -53,6 +70,12 @@ struct wl_deleter;
|
||||
} \
|
||||
}
|
||||
|
||||
#if wxUSE_WAYLAND_DATA_DEVICE_MANAGER
|
||||
wxDEFINE_WL_DELETER(wl_data_device, wl_data_device_release);
|
||||
wxDEFINE_WL_DELETER(wl_data_device_manager, wl_data_device_manager_destroy);
|
||||
wxDEFINE_WL_DELETER(wl_data_offer, wl_data_offer_destroy);
|
||||
#endif // wxUSE_WAYLAND_DATA_DEVICE_MANAGER
|
||||
wxDEFINE_WL_DELETER(wl_data_source, wl_data_source_destroy);
|
||||
wxDEFINE_WL_DELETER(wl_pointer, wl_pointer_release);
|
||||
wxDEFINE_WL_DELETER(wl_registry, wl_registry_destroy);
|
||||
wxDEFINE_WL_DELETER(wl_seat, wl_seat_release);
|
||||
@@ -62,6 +85,10 @@ wxDEFINE_WL_DELETER(xdg_session_manager_v1, xdg_session_manager_v1_destroy);
|
||||
wxDEFINE_WL_DELETER(xdg_session_v1, xdg_session_v1_destroy);
|
||||
wxDEFINE_WL_DELETER(xdg_toplevel_session_v1, xdg_toplevel_session_v1_destroy);
|
||||
#endif // wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
#ifdef wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
wxDEFINE_WL_DELETER(xdg_toplevel_drag_manager_v1, xdg_toplevel_drag_manager_v1_destroy);
|
||||
wxDEFINE_WL_DELETER(xdg_toplevel_drag_v1, xdg_toplevel_drag_v1_destroy);
|
||||
#endif // wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
|
||||
template <typename T>
|
||||
using wl_unique_ptr = std::unique_ptr<T, wl_deleter<T>>;
|
||||
@@ -85,6 +112,10 @@ public:
|
||||
|
||||
void UpdateCapabilities(int capabilities);
|
||||
|
||||
// Return the data device for this seat, creating it on demand, or null if
|
||||
// the data device manager global is not available.
|
||||
wl_data_device* GetDataDevice();
|
||||
|
||||
|
||||
// Most members are const after they're first set, but can't be really
|
||||
// const because we need to be able to move Seat objects.
|
||||
@@ -102,6 +133,22 @@ public:
|
||||
// which surface it happened for, we just need a valid serial to pass to
|
||||
// wp_pointer_warp_v1_warp_pointer().
|
||||
uint32_t lastEnterSerial = 0;
|
||||
|
||||
#ifdef wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
// Last serial of a "pointer button pressed" event for this seat: this is
|
||||
// the serial of the implicit grab which must be passed to
|
||||
// wl_data_device_start_drag().
|
||||
uint32_t lastButtonSerial = 0;
|
||||
|
||||
// The data device for this seat: only created if it's actually needed,
|
||||
// i.e. if we start a drag using it, see GetDataDevice().
|
||||
wl_unique_ptr<wl_data_device> data_device;
|
||||
|
||||
// The last data offer we were given: we don't use it at all, but it must
|
||||
// be destroyed to avoid memory leaks, so we need to store it as it's not
|
||||
// clear if we can destroy it immediately when it's offered.
|
||||
wl_unique_ptr<wl_data_offer> last_data_offer;
|
||||
#endif // wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
};
|
||||
|
||||
|
||||
@@ -127,6 +174,18 @@ struct Globals
|
||||
// Optional pointer to the global pointer warp protocol object.
|
||||
wl_unique_ptr<wp_pointer_warp_v1> pointer_warp;
|
||||
|
||||
#if wxUSE_WAYLAND_DATA_DEVICE_MANAGER
|
||||
// Optional pointer to the global data device manager object: this one is
|
||||
// always supported, but we only bind it if we need it, i.e. if we can also
|
||||
// use the toplevel drag protocol below.
|
||||
wl_unique_ptr<wl_data_device_manager> data_device_manager;
|
||||
#endif // wxUSE_WAYLAND_DATA_DEVICE_MANAGER
|
||||
|
||||
#ifdef wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
// Optional pointer to the global toplevel drag protocol object.
|
||||
wl_unique_ptr<xdg_toplevel_drag_manager_v1> toplevel_drag_manager;
|
||||
#endif // wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
|
||||
#ifdef wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
// Optional pointer to the global session manager protocol object.
|
||||
wl_unique_ptr<xdg_session_manager_v1> session_manager;
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/private/tlwdrag.h
|
||||
// Purpose: wxTLWDragSession: drag a TLW using the system drag machinery
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2026-08-25
|
||||
// Copyright: (c) 2026 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_PRIVATE_TLWDRAG_H_
|
||||
#define _WX_PRIVATE_TLWDRAG_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxWindow;
|
||||
|
||||
// Only wxGTK provides an implementation of this class for now and even there
|
||||
// it may not be available, see wxTLWDragSession::Create().
|
||||
#ifdef __WXGTK3__
|
||||
#define wxHAS_TLW_DRAG_SESSION
|
||||
#endif
|
||||
|
||||
#ifdef wxHAS_TLW_DRAG_SESSION
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTLWDragHandler: receives the notifications during wxTLWDragSession
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxTLWDragHandler
|
||||
{
|
||||
public:
|
||||
virtual ~wxTLWDragHandler() = default;
|
||||
|
||||
// Called whenever the pointer moves during the drag.
|
||||
//
|
||||
// "win" is the window the drag originated from if the pointer is currently
|
||||
// over it or null if it is not, and "pt" is the pointer position in screen
|
||||
// coordinates. Note that we can only detect being over the origin window
|
||||
// itself, drags over the other windows of this application, or of the
|
||||
// other applications, are indistinguishable from being outside of them.
|
||||
//
|
||||
// Note that under Wayland the screen coordinates are not really global,
|
||||
// but they are still consistent with the coordinates used by the windows
|
||||
// inside "win", which is all we need here.
|
||||
virtual void OnDragOver(wxWindow* win, const wxPoint& pt) = 0;
|
||||
|
||||
// Called when the drag ends with a drop.
|
||||
//
|
||||
// If this function is not called, the drag was cancelled and OnCancel()
|
||||
// is called instead.
|
||||
//
|
||||
// The arguments are the same as for OnDragOver().
|
||||
//
|
||||
// The handler, and the session owning it, may be destroyed from here.
|
||||
virtual void OnDragDrop(wxWindow* win, const wxPoint& pt) = 0;
|
||||
|
||||
// Called when the drag was cancelled.
|
||||
virtual void OnDragCancel() = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTLWDragSession: represents a drag moving a TLW with the pointer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// This class encapsulates a drag operation during which a TLW follows the
|
||||
// mouse pointer until the drag ends.
|
||||
//
|
||||
// Currently it's only implemented in wxGTK3 when using Wayland and the
|
||||
// appropriate build-time support is available, but we still use a base class
|
||||
// for it to avoid exposing the implementation details in this header and to
|
||||
// allow for future implementations for other ports.
|
||||
class WXDLLIMPEXP_CORE wxTLWDragSession
|
||||
{
|
||||
public:
|
||||
// Creating a drag session starts a drag originating from the given window,
|
||||
// which must be shown and must be the window currently having the pointer
|
||||
// grab, i.e. this can only be called while handling a mouse event for it.
|
||||
//
|
||||
// Returns null if starting the drag is not supported, in which case the
|
||||
// caller has to fall back to moving the window on its own.
|
||||
static std::unique_ptr<wxTLWDragSession>
|
||||
Create(wxWindow* origin, std::unique_ptr<wxTLWDragHandler> handler);
|
||||
|
||||
// Ask the system to move the given TLW with the pointer for the rest of
|
||||
// the drag. The window must be already shown and "offset" is the position
|
||||
// of the pointer inside it, used as a hint for its initial position.
|
||||
//
|
||||
// This can only be called once for any given session.
|
||||
virtual bool AttachWindow(wxWindow* tlw, const wxPoint& offset) = 0;
|
||||
|
||||
// Virtual dtor for any base class used polymorphically.
|
||||
virtual ~wxTLWDragSession() = default;
|
||||
};
|
||||
|
||||
#else // !wxHAS_TLW_DRAG_SESSION
|
||||
|
||||
// Define a stub just to allow to refer to it in the headers without checking
|
||||
// for wxHAS_TLW_DRAG_SESSION first.
|
||||
class wxTLWDragSession
|
||||
{
|
||||
};
|
||||
|
||||
#endif // wxHAS_TLW_DRAG_SESSION/!wxHAS_TLW_DRAG_SESSION
|
||||
|
||||
#endif // _WX_PRIVATE_TLWDRAG_H_
|
||||
@@ -636,6 +636,13 @@
|
||||
*/
|
||||
#undef wxHAVE_WAYLAND_SESSION_MANAGEMENT
|
||||
|
||||
/*
|
||||
Use Wayland xdg-toplevel-drag protocol.
|
||||
|
||||
This is defined if GTK is new enough to support it.
|
||||
*/
|
||||
#undef wxHAVE_WAYLAND_TOPLEVEL_DRAG
|
||||
|
||||
/*
|
||||
Use XTest extension to implement wxUIActionSimulator?
|
||||
|
||||
|
||||
+706
-9
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user