Skip to content

Commit

Permalink
Add verbose panel logs and attempt to address all orientation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ruineka authored and BoukeHaarsma23 committed May 28, 2024
1 parent 9b81344 commit 5764df2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
18 changes: 16 additions & 2 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static constexpr bool k_bUseCursorPlane = false;

extern int g_nPreferredOutputWidth;
extern int g_nPreferredOutputHeight;
bool panelTypeChanged = false;

gamescope::ConVar<bool> cv_drm_single_plane_optimizations( "drm_single_plane_optimizations", true, "Whether or not to enable optimizations for single plane usage." );
gamescope::ConVar<bool> cv_drm_debug_disable_shaper_and_3dlut( "drm_debug_disable_shaper_and_3dlut", false, "Shaper + 3DLUT chicken bit. (Force disable/DEFAULT, no logic change)" );
Expand Down Expand Up @@ -310,6 +311,7 @@ namespace gamescope
{
if ( g_bExternalForced )
{
panelTypeChanged = true;
return g_ForcedScreenType;
}
else
Expand All @@ -318,7 +320,7 @@ namespace gamescope
}
}


panelTypeChanged = false;
return GAMESCOPE_SCREEN_TYPE_EXTERNAL;
}

Expand Down Expand Up @@ -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;
}
Expand Down
41 changes: 22 additions & 19 deletions src/wlserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/wlserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ extern gamescope::ConVar<bool> 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);

Expand Down

0 comments on commit 5764df2

Please sign in to comment.