From 5764df22f5726b84bfe0d57c2d15e134fce2c8ca Mon Sep 17 00:00:00 2001 From: Matthew Anderson Date: Mon, 20 May 2024 16:30:47 -0500 Subject: [PATCH] Add verbose panel logs and attempt to address all orientation issues --- src/drm.cpp | 18 ++++++++++++++++-- src/wlserver.cpp | 41 ++++++++++++++++++++++------------------- src/wlserver.hpp | 1 + 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/drm.cpp b/src/drm.cpp index f8decf9a5..4435147c2 100644 --- a/src/drm.cpp +++ b/src/drm.cpp @@ -56,6 +56,7 @@ static constexpr bool k_bUseCursorPlane = false; extern int g_nPreferredOutputWidth; extern int g_nPreferredOutputHeight; +bool panelTypeChanged = false; gamescope::ConVar cv_drm_single_plane_optimizations( "drm_single_plane_optimizations", true, "Whether or not to enable optimizations for single plane usage." ); gamescope::ConVar cv_drm_debug_disable_shaper_and_3dlut( "drm_debug_disable_shaper_and_3dlut", false, "Shaper + 3DLUT chicken bit. (Force disable/DEFAULT, no logic change)" ); @@ -310,6 +311,7 @@ namespace gamescope { if ( g_bExternalForced ) { + panelTypeChanged = true; return g_ForcedScreenType; } else @@ -318,7 +320,7 @@ namespace gamescope } } - + panelTypeChanged = false; return GAMESCOPE_SCREEN_TYPE_EXTERNAL; } @@ -2016,7 +2018,19 @@ namespace gamescope void CDRMConnector::UpdateEffectiveOrientation( const drmModeModeInfo *pMode ) { - if ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_INTERNAL && g_DesiredInternalOrientation != GAMESCOPE_PANEL_ORIENTATION_AUTO ) { + + if ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_EXTERNAL && panelTypeChanged ) + drm_log.infof("Display is internal faked as external"); + if ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_INTERNAL && !panelTypeChanged ) + drm_log.infof("Display is real internal"); + if (panelTypeChanged){ + drm_log.infof("Panel type was changed"); + } + + if (( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_INTERNAL && g_DesiredInternalOrientation != GAMESCOPE_PANEL_ORIENTATION_AUTO ) || + ( this->GetScreenType() == GAMESCOPE_SCREEN_TYPE_EXTERNAL && g_DesiredInternalOrientation != GAMESCOPE_PANEL_ORIENTATION_AUTO + && panelTypeChanged)) { + drm_log.infof("We are rotating the orientation of the internal or faked external display"); m_ChosenOrientation = g_DesiredInternalOrientation; } diff --git a/src/wlserver.cpp b/src/wlserver.cpp index e94fa2753..1c175366a 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -2451,26 +2451,29 @@ static void apply_touchscreen_orientation(double *x, double *y ) { if ( g_ForcedScreenType == gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL ) { - switch (GetBackend()->GetConnector(gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL)->GetCurrentOrientation()) + if(panelTypeChanged) { - default: - case GAMESCOPE_PANEL_ORIENTATION_AUTO: - case GAMESCOPE_PANEL_ORIENTATION_0: - tx = *x; - ty = *y; - break; - case GAMESCOPE_PANEL_ORIENTATION_90: - tx = 1.0 - *y; - ty = *x; - break; - case GAMESCOPE_PANEL_ORIENTATION_180: - tx = 1.0 - *x; - ty = 1.0 - *y; - break; - case GAMESCOPE_PANEL_ORIENTATION_270: - tx = *y; - ty = 1.0 - *x; - break; + switch (GetBackend()->GetConnector(gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL)->GetCurrentOrientation()) + { + default: + case GAMESCOPE_PANEL_ORIENTATION_AUTO: + case GAMESCOPE_PANEL_ORIENTATION_0: + tx = *x; + ty = *y; + break; + case GAMESCOPE_PANEL_ORIENTATION_90: + tx = 1.0 - *y; + ty = *x; + break; + case GAMESCOPE_PANEL_ORIENTATION_180: + tx = 1.0 - *x; + ty = 1.0 - *y; + break; + case GAMESCOPE_PANEL_ORIENTATION_270: + tx = *y; + ty = 1.0 - *x; + break; + } } } else diff --git a/src/wlserver.hpp b/src/wlserver.hpp index f25f6b915..25ae520e6 100644 --- a/src/wlserver.hpp +++ b/src/wlserver.hpp @@ -288,6 +288,7 @@ extern gamescope::ConVar cv_touch_gestures; void wlserver_open_steam_menu( bool qam ); extern void drm_set_orientation( struct drm_t *drm, bool isRotated); extern drm_t g_DRM; +extern bool panelTypeChanged; uint32_t wlserver_make_new_xwayland_server(); void wlserver_destroy_xwayland_server(gamescope_xwayland_server_t *server);