1
+ diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
2
+ index e924ac8..7aed647 100644
3
+ --- a/src/Backends/WaylandBackend.cpp
4
+ +++ b/src/Backends/WaylandBackend.cpp
5
+ @@ -73,13 +73,13 @@ static inline uint32_t WaylandScaleToPhysical( uint32_t pValue, uint32_t pFactor
6
+ }
7
+ static inline uint32_t WaylandScaleToLogical( uint32_t pValue, uint32_t pFactor ) {
8
+ return div_roundup( pValue * WL_FRACTIONAL_SCALE_DENOMINATOR, pFactor );
9
+ }
10
+
11
+ static bool IsSurfacePlane( wl_surface *pSurface ) {
12
+ - return wl_proxy_get_tag( (wl_proxy *)pSurface ) == &GAMESCOPE_plane_tag;
13
+ + return pSurface && (wl_proxy_get_tag( (wl_proxy *)pSurface ) == &GAMESCOPE_plane_tag);
14
+ }
15
+
16
+ #define WAYLAND_NULL() []<typename... Args> ( void *pData, Args... args ) { }
17
+ #define WAYLAND_USERDATA_TO_THIS(type, name) []<typename... Args> ( void *pData, Args... args ) { type *pThing = (type *)pData; pThing->name( std::forward<Args>(args)... ); }
18
+
19
+ // Libdecor puts its userdata ptr at the end... how fun! I shouldn't have spent so long writing this total atrocity to mankind.
20
+ @@ -717,13 +717,13 @@ namespace gamescope
21
+ zwp_pointer_constraints_v1 *m_pPointerConstraints = nullptr;
22
+ zwp_relative_pointer_manager_v1 *m_pRelativePointerManager = nullptr;
23
+ wp_fractional_scale_manager_v1 *m_pFractionalScaleManager = nullptr;
24
+ xdg_toplevel_icon_manager_v1 *m_pToplevelIconManager = nullptr;
25
+
26
+ // TODO: Restructure and remove the need for this.
27
+ - std::shared_ptr<CWaylandConnector> m_pFocusConnector;
28
+ + std::weak_ptr<CWaylandConnector> m_pFocusConnector;
29
+
30
+ wl_data_device_manager *m_pDataDeviceManager = nullptr;
31
+ wl_data_device *m_pDataDevice = nullptr;
32
+ std::shared_ptr<std::string> m_pClipboard = nullptr;
33
+
34
+ zwp_primary_selection_device_manager_v1 *m_pPrimarySelectionDeviceManager = nullptr;
35
+ @@ -2038,13 +2038,13 @@ namespace gamescope
36
+
37
+ return std::span<const uint64_t>{ iter->second.begin(), iter->second.end() };
38
+ }
39
+
40
+ IBackendConnector *CWaylandBackend::GetCurrentConnector()
41
+ {
42
+ - return m_pFocusConnector.get();
43
+ + return m_pFocusConnector.lock().get();
44
+ }
45
+ IBackendConnector *CWaylandBackend::GetConnector( GamescopeScreenType eScreenType )
46
+ {
47
+ if ( eScreenType == GAMESCOPE_SCREEN_TYPE_INTERNAL )
48
+ return GetCurrentConnector();
49
+
50
+ @@ -2110,13 +2110,13 @@ namespace gamescope
51
+ {
52
+ return true;
53
+ }
54
+ std::shared_ptr<IBackendConnector> CWaylandBackend::CreateVirtualConnector( uint64_t ulVirtualConnectorKey )
55
+ {
56
+ std::shared_ptr<CWaylandConnector> pConnector = std::make_shared<CWaylandConnector>( this, ulVirtualConnectorKey );
57
+ - if ( !m_pFocusConnector )
58
+ + if ( m_pFocusConnector.expired() )
59
+ m_pFocusConnector = pConnector;
60
+
61
+ if ( !pConnector->Init() )
62
+ {
63
+ return nullptr;
64
+ }
0 commit comments