+
    KiJ  c                   s    R t ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHt ]! RR4      tR tR	 tR
 tR tR t ! R R4      tR# )zXrandR based display managementN)
namedtuple)DEFAULT_RESOLUTION_HEIGHTDEFAULT_RESOLUTION_WIDTH)LINUX_SYSTEM)logger)read_process_outputOutputc                 s    \        \        P                  ! R4      .4      P                  R4      p \        P
                  ! R\        V 4      4       V # )zReturn video modes from XrandRxrandrZ
z%Retrieving %s video modes from XrandR)r   r   getsplitr   debuglen)Zxrandr_output    @/usr/lib/python3.14/site-packages/lutris/util/graphics/xrandr.py_get_vidmodesr      s?    ')9)9()C(DEKKDQM
LL8#m:LM    c                 sL   . p \         P                  ! R4       \        4       pRpRpRpRpV'       g   \         P                  ! R4       . # V EF!  pVP	                  4       pRVR,          9   d   \        V4      ^8  d    VP                  R^4      pVRV p	RP                  V	4      pWx^,           R p
V
^ ,          R8X  d
   V
R,          p
V
vrpVP                  R4      '       d   K  VP                  R4      '       d   R	pVP	                  R
4      w  rpRP                  WR7      pK  RV9   g   K  VvppV F3  pRV9   g   K  VRR pV P                  \        VVVVVVR7      4        EK  	  EK$  	  V #   \         d$   p\         P                  ! RYo4        Rp?EKQ  Rp?ii ; i)ztReturn list of namedtuples containing output 'name', 'geometry',
'rotation' and whether it is the 'primary' display.zRetrieving display outputsNzxrandr didn't return anythingZ	connected:i   NNZ primaryZ(normalZ+z{x_pos}x{y_pos})x_posy_poszSUnhandled xrandr line %s, error: %s. Please send your xrandr output to the dev team*namemodepositionrotationr   ratei)r   r
   r   errorr	   r   ZindexZjoin
startswithZformatZ
ValueErrorappendr   )ZoutputsZ	vid_modesr   Zrotater   r   lineZfieldsZconnected_indexZname_fieldsZdata_fieldsZgeometryZ_r   r   Zexr   Z
frameratesZnumberZhertzs                       r   get_outputsr      s    G
LL-.IHFGD45	&*$V)9"(,,{A">$%5o6xx,$q%8%:;q>Y."-b/K'2$1&&s++$$S))%F"*.."5%,33%3M D[ &D:$&="3BKENN!%!%%-%+$+!&	  %1 L N+  iko 	s%    A%E5'E5>(E55F# FF#c                s   V '       g   \         P                  ! R4       R# \        4        F  pVP                  V 8w  g   K  \         P                  ! RV^ ,          4       \
        P                  ! \        P                  ! R4      RVP                  R.4      ;_uu_ 4       pVP                  4        RRR4       K  	  R#   + '       g   i     K  ; i)zFUse XrandR to turn off displays except the one referenced by `display`z5No active display given, no turning off every displayNzTurning off %sr   --outputz--off)
r   r   r   r   info
subprocessPopenr   r   communicate)displayoutputr   s   &  r   turn_off_exceptr'   L   s    LM-;;'!KK(&)4!!<#3#3H#=z6;;X_"`aaek""$ ba   baas   B>>Cc                 s   . p \         P                  ! R4       \        4        Fc  pVP                  R4      '       g   K  \        P
                  ! RV4      pV'       g   K=  V P                  VP                  4       ^ ,          4       Ke  	  V '       g)   \         P                  ! R4       \        : R\        : 2.# \        \        V 4      R RR7      # )	z0Return the list of supported screen resolutions.zRetrieving resolution list  .*?(\d+x\d+).*z5Unable to generate resolution list from xrandr outputxc                 sD    \        V P                  R 4      ^ ,          4      # r*   )Zintr	   r+      &r   Z<lambda>Z!get_resolutions.<locals>.<lambda>d   s    c!''#,q/6Jr   T)ZkeyZreverse)r   r
   r   r   rematchr   groupsr   r   r   ZsortedZset)Zresolution_listr   resolution_matchs      r   get_resolutionsr1   X   s    O
LL-.??4  !xx(94@&&'7'>'>'@'CD	  
 LM35NOPP#o&,JTXYYr   c                sl   V '       g   \         P                  ! R4       R# \        V \        4      '       d   \         P                  ! RV 4       V \        4       9  d   \         P                  ! RV 4       R# \        4       ^ ,          P                  p\         P                  ! RW4       \        P                  ! R4      RVRV .p\        P                  ! V4      ;_uu_ 4       pVP                  4        RRR4       R# V  EF  p\         P                  ! R	VP                  VP                  4       VP                  e   VP                  R9   d   VP                  pMR
p\         P                  ! RVP                  VP                  4       \        P                  ! \        P                  ! R4      RVP                  RVP                  RVP                   RVRVP"                  .4      ;_uu_ 4       pVP                  4        RRR4       EK  	  R#   + '       g   i     R# ; i  + '       g   i     EK5  ; i)zsChange display resolution.

Takes a string for single monitors or a list of displays as returned
by get_outputs().
zNo resolution providedNzSwitching resolution to %szResolution %s doesn't exist.zChanging resolution on %s to %sr   r    z--modezSwitching to %s on %sr   z Switching resolution of %s to %sz--posz--rotatez--rate)r   ZleftZrightZinverted)r   ZwarningZ
isinstancestrr
   r1   r   r   r!   r   r   r"   r#   r$   r   r   r   r   )
resolutionZoutput_nameZargsr   r%   r   s   &     r   change_resolutionr4   g   s    /0*c""1:>_..NN9:F%-*//KKK9;S $$X.
KS]^D!!$''6""$ (' "GLL0',,M+0@0@ E 1 #++#KK:GLL',,W!! $$X.LLLL$$LL  ""$  " (''   s   !H-H!H	!H3c                   st   a  ] tR t^t o Rt]R 4       t]R 4       t]R 4       t]R 4       t	]R 4       t
RtV tR# )	LegacyDisplayManagerz?Legacy XrandR based display manager.
Does not work on Wayland.
c                 sR    \        4        U u. uF  q P                  NK  	  up # u up i )zReturn output names from XrandR)r   r   )r&   r   r   get_display_namesZ&LegacyDisplayManager.get_display_names   s      +6-8--888s   $c                     \        4       # )zReturn available resolutions)r1    r   r   r1   Z$LegacyDisplayManager.get_resolutions   s       r   c                 s^   \        4        Fl  p V P                  R4      '       g   K  RV 9   g   K%  \        P                  ! RV 4      pV'       g   KF  VP	                  4       ^ ,          P                  R4      u # 	  \        P                  ! R4       \        \        4      \        \        4      3# )z-Return the current resolution for the desktopr(   r   r)   r*   z8Unable to find the current resolution from xrandr output)r   r   r-   r.   r/   r	   r   r   r2   r   r   )r   r0   s     r   get_current_resolutionZ+LegacyDisplayManager.get_current_resolution   s     "ODt$$#%88,=t#D ##+224Q7==cBB	 $
 	OP+,c2K.LLLr   c                s    \        V 4       R# )zChange the current resolutionN)r4   )r3   r,   r   set_resolutionZ#LegacyDisplayManager.set_resolution   s     	*%r   c                 r7   )z(Return the current display configuration)r   r8   r   r   
get_configZLegacyDisplayManager.get_config   s     }r   r8   N)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__Zstaticmethodr6   r1   r9   r:   r;   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r5   r5      sp      9 9 ! ! M M & &  r   r5   r   )r<   r-   r"   Zcollectionsr    Zlutris.settingsr   r   Zlutris.util.linuxr   Zlutris.util.logr   Zlutris.util.systemr   r   r   r   r'   r1   r4   r5   r8   r   r   <module>r=      sP    % 	  " O * " 2	HY	Z3l	%Z1%h" "r   