
    Egm                     (   d dl Z  e j                  dd       d dlmZmZmZmZmZmZ d dl	Z	d dl
Z
d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZm Z m!Z! d dl"m#Z# d dl$m%Z%  G d dejL                        Z'y)    NCDesktopEnumsz3.0)GLibGtkGdkCScreensaverr   GObject)MonitorView)UnlockDialog)ClockWidget)AlbumArt)
AudioPanel)	InfoPanel)OnScreenKeyboard)
ALIGNMENTS)utilstrackerssettings)EventHandler)DEBUGc                   Z   e Zd ZdZdej
                  j                  ddfiZd Zd Z	d1dZ
d1dZd1d	Zd1d
Zd Zd Zd Zd Zd Zd Zd1dZd Zd Zd Zd Zd1dZd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%d# Z&d$ Z'd% Z(d& Z)d' Z*d( Z+d) Z,d* Z-d+ Z.d, Z/d- Z0d. Z1d/ Z2d0 Z3y)2Stagea  
    The Stage is the toplevel window of the entire screensaver while
    in Active mode.

    It's the first thing made, the last thing destroyed, and all other
    widgets live inside of it (or rather, inside the GtkOverlay below)

    It is Gtk.WindowType.POPUP to avoid being managed/composited by muffin,
    and to prevent animation during its creation and destruction.

    The Stage responds pretty much only to the instructions of the
    ScreensaverManager.
    needs-refreshN c                 `
   t         j                  r<t        j                  j	                  | t        j
                  j                  dd       n;t        j                  j	                  | t        j
                  j                  dd       | j                         j                  d       t        j                         j                  t        j                  d| j                         d| _        || _        || _        d | _        g | _        d| _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        g | _        t=        |      | _        | j                         jA                  d       | jC                  | jE                         tF        jH                  jJ                  z  tF        jH                  jL                  z  tF        jH                  jN                  z  tF        jH                  jP                  z  tF        jH                  jR                  z  tF        jH                  jT                  z  tF        jH                  jV                  z  tF        jH                  jX                  z  tF        jH                  jZ                  z  tF        jH                  j\                  z         tG        j^                  dddd      }| ja                  t        jb                  jd                  |       | jg                          t        jh                         | _        t        j                         j                  | j,                  d	| jj                         t        j                         j                  | j,                  d
| jl                         | j,                  jo                          | jq                  | j,                         t        jr                  | _:        t        j                         j                  | jt                  d| jv                         tx        jz                  j}                  | d      | _?        t        j                         j                  t         j                  d| j                         t        j                         j                  t         j                  d| j                         t        j                         j                  t         j                  d| j                         t        j                         j                  | d| j                         t         j                  r| j                  d       y y )NTF)type	decoratedskip_taskbar_hintcsstagechanged
backgroundr   realizeget-child-positionpower-state-changedsize-changedmonitors-changedzcomposited-changedgrab-broken-event)FstatusInteractiveDebugr   Window__init__
WindowTypeTOPLEVELPOPUPget_style_context	add_classr   con_tracker_getconnect
singletonsBackgroundson_bg_changed
destroyingmanageraway_messageactivate_callbackmonitorslast_focus_monitoroverlayclock_widgetalbumart_widgetunlock_dialogaudio_panel
info_paneloskfloatersr   event_handlerremove_class
set_events
get_eventsr   	EventMaskPOINTER_MOTION_MASKBUTTON_PRESS_MASKBUTTON_RELEASE_MASKKEY_PRESS_MASKKEY_RELEASE_MASKEXPOSURE_MASKVISIBILITY_NOTIFY_MASKENTER_NOTIFY_MASKLEAVE_NOTIFY_MASKFOCUS_CHANGE_MASKRGBAoverride_background_color
StateFlagsNORMALupdate_geometryOverlayon_realizedposition_overlay_childshow_alladdUPowerClientpower_clienton_power_state_changedr   GdkEventFilternew
gdk_filterscreenon_screen_size_changedon_monitors_changedon_composited_changedon_grab_broken_eventset_interactive_debugging)selfr7   r8   cs       (/usr/share/cinnamon-screensaver/stage.pyr+   zStage.__init__*   s   ""JJ%(^^%<%<*.27   9
 JJ%(^^%9%9*/26   8
 	 **95  "**:+A+A+4+/+=+=	?  (!%"$ #!)'2 --l;)99:778 99: 44	5
 667 334 <<= 778 77	8 77
8 
	9 HHQ1a &&s~~'<'<a@{{}  "**4<<+4+/+;+;	= 	  "**4<<+?+/+F+F	H 	 '33  "**4+<+<+@+/+F+F	H '5599$B  "**6==+9+/+F+F	H 	  "**6==+=+/+C+C	E 	  "**6==+?+/+E+E	G 	  "**4+>+/+D+D	F ""**40 #    c                     | j                          	 | j                          | j                  D ]  }| j                  |        y # t        $ r!}t        dt        |      z         Y d }~y d }~ww xY w)Nz(Problem updating monitor views views: %s)destroy_monitor_viewssetup_monitorsr:   sink_child_widget	Exceptionprintstr)ri   monitores      rk   update_monitorszStage.update_monitors   sh    ""$	G!== 0&&w/0 	G<s1vEFF	Gs   2A 	A/A**A/c                 <    t        d       | j                  d       y)z
        The screen changing size should be acted upon immediately, to ensure coverage.
        Wallpapers are secondary.
        z<Stage: Received screen size-changed signal, refreshing stager   Nr   emitri   rc   datas      rk   rd   zStage.on_screen_size_changed   s     	LM		/"rl   c                 <    t        d       | j                  d       y)z
        Updating monitors also will trigger an immediate stage coverage update (same
        as on_screen_size_changed), and follow up at idle with actual monitor view
        refreshes (wallpapers.)
        z@Stage: Received screen monitors-changed signal, refreshing stager   Nrx   rz   s      rk   re   zStage.on_monitors_changed   s     	PQ		/"rl   c                 ^    | j                         rt        d       | j                  d       y y )NzBStage: Received screen composited-changed signal, refreshing stager   )get_realizedr   ry   rz   s      rk   rf   zStage.on_composited_changed   s(    VWIIo& rl   c                 V    t        j                  | j                  j                         yNF)r   idle_addr7   
grab_stage)ri   widgeteventr{   s       rk   rg   zStage.on_grab_broken_event   s    001rl   c                     | j                  d       | j                          | j                          | j                         r |        y|| _        y)zF
        This is the primary way of making the Stage visible.
        g      ?N)set_opacitymove_onscreenshowr~   r9   ri   callbacks     rk   activatezStage.activate   s@    
 			J%-D"rl   c                 2    | j                           |        y)zB
        This is the primary way of destroying the stage.
        N)hider   s     rk   
deactivatezStage.deactivate   s     			
rl   c                    | j                         }t        j                  |       t        j                  j                  |d       | j                          | j                  j                  t        j                  j                         t        j                         t        j                         j!                  | j"                  d| j$                         | j&                  | j'                          yy)a  
        Repositions the window when it is realized, to cover the entire
        GdkScreen (a rectangle exactly encompassing all monitors.)

        From here we also proceed to construct all overlay children and
        activate our window suppressor.
        zcinnamon-screensaver-windowr"   N)
get_windowr   override_user_timer   Screenset_net_wm_namesetup_childrenrb   startr3   MuffinClientget_using_fractional_scalingr(   Debugr   r1   
disconnectr<   rY   r9   )ri   r   windows      rk   rY   zStage.on_realized   s     "  (++F4QRj55RRTV\VbVbc  "--dll.7.2.>.>	@ !!-""$ .rl   c                    | j                         }|rd|j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                         | j                  | j                  j                  | j                  j                         | j                  | j                  j
                  | j                  j                         y N)	r   move_resizerectxywidthheightmoveresize)ri   ws     rk   r   zStage.move_onscreen   s    OOMM$))++))++))//))**,
 			$))++tyy{{+DIIOOTYY%5%56rl   c                 :    | j                   j                  d       y r   )r7   
set_activeri   s    rk   deactivate_after_timeoutzStage.deactivate_after_timeout   s    &rl   c                    d}	 | j                          	 | j	                          |sR	 | j                          	 | j                          t        j                         j                  dd	| j                         yt        d
       t        j                  | j                         y# t        $ r#}t        dt        |      z         d}Y d}~d}~ww xY w# t        $ r#}t        dt        |      z         d}Y d}~d}~ww xY w# t        $ r(}t        dt        |      z         d| _        Y d}~d}~ww xY w# t        $ r)}t        dt        |      z         d| _        Y d}~d}~ww xY w)z
        Creates all of our overlay children.  If a new 'widget' gets added,
        this should be the setup point for it.

        We bail if something goes wrong on a critical widget - a monitor view or
        unlock widget.
        Fz$Problem setting up monitor views: %sTNz$Problem setting up unlock dialog: %sz#Problem setting up clock widget: %sz)Problem setting up on-screen keyboard: %ssetup-delayed-componentsi  z2Total failure somewhere, deactivating screensaver.)ro   rq   rr   rs   setup_unlocksetup_clockr=   	setup_oskrB   r   timer_tracker_getr   setup_delayed_componentsr   r   r   )ri   total_failureru   s      rk   r   zStage.setup_children   sC    	!!
	!
 )  "
  
 &&(../I/3/3/L/LN FGT::;9  	!83q6AB M	!  	!83q6AB M	!  );c!fDE$(!!)   ACFJK s\   B$ C D D6 $	C-CC	C?C::C?	D3D..D36	E(?E##E(c                 &   	 | j                          	 | j                          y # t        $ r(}t        dt        |      z         d | _        Y d }~>d }~ww xY w# t        $ r/}t        dt        |      z         d | _        d | _        Y d }~y d }~ww xY w)Nz&Problem setting up albumart widget: %sz"Problem setting up status bars: %s)setup_albumartrq   rr   rs   r>   setup_status_barsr@   rA   )ri   r{   ru   s      rk   r   zStage.setup_delayed_components   s    	(!	#""$	  	(:SVCD#'D  	(
  	#6Q?@#D"DOO	#s+   $ A 	AAA	B!%BBc                    	 | j                          	 | j                  | j                  j	                          	 | j
                  4| j
                  j                          | j
                  j	                          	 | j                  4| j                  j                          | j                  j	                          	 | j                  | j                  j	                          	 | j                  | j                  j	                          	 | j                  | j                  j	                          d | _        d | _        d | _        d | _        d | _	        d | _
        d | _        g | _        g | _        y # t        $ r}t        |       Y d }~xd }~ww xY w# t        $ r}t        |       Y d }~sd }~ww xY w# t        $ r}t        |       Y d }~Td }~ww xY w# t        $ r}t        |       Y d }~5d }~ww xY w# t        $ r}t        |       Y d }~0d }~ww xY w# t        $ r}t        |       Y d }~+d }~ww xY w# t        $ r}t        |       Y d }~&d }~ww xY wr   )rn   rq   rr   r?   destroyr=   stop_positioningr>   rA   r@   rB   r8   r:   rC   )ri   ru   s     rk   destroy_childrenzStage.destroy_children-  s   	&&(	!!-""**,	  ,!!224!!))+	##/$$557$$,,.	*'')	*  ((*	xx#  " " # e  	!HH	  	!HH	  	!HH	  	!HH	  	!HH	  	!HH	  	!HH	s   E0 &F A F4 ;A G <&G8 #&H 
&H< 0	F9F

F	F1F,,F14	G=GG	G5G00G58	HHH	H9#H44H9<	IIIc                    t        j                         j                  | j                  d| j                         t        j                         j                  | j                  d| j                         t        j                         j                  | j                  d| j
                         t        j                         j                  | j                  d| j
                         t        j                         j                  | j                  d| j                         t        j                         j                  t        j                  d| j                         t        j                         j                  | j                  d| j                         t        j                         j                  | d| j                         | j	                  d	d
       t        j                         j                  d       | j                          | j                   j#                          d	| _        t        j                         j                  t$        j&                  d| j(                         t        j                         j                  t$        j&                  d| j*                         t        j                         j                  | j,                  d| j.                         | j1                          y	)z
        Performs all tear-down necessary to destroy the Stage, destroying
        all children in the process, and finally destroying itself.
        inhibit-timeoutuninhibit-timeoutauthenticate-successauthenticate-failureauthenticate-cancelr   r$   r'   NFr   r%   r&   r#   )r   r1   r   r?   set_timeout_activeauthentication_result_callbackauthentication_cancel_callbackr3   r4   r5   r^   r_   rg   r   cancelr   rb   stopr(   rc   rd   re   r<   rZ   r   r   s    rk   destroy_stagezStage.destroy_staged  sF    	  "--d.@.@.?.2.E.E	G 	  "--d.@.@.A.2.E.E	G 	  "--d.@.@.D.2.Q.Q	S 	  "--d.@.@.D.2.Q.Q	S 	  "--d.@.@.C.2.Q.Q	S 	  "--j.D.D.7.2.@.@	B 	  "--d.?.?.C.2.I.I	K 	  "--d.A.2.G.G	I 	e,""$++,FG  "--fmm.<.2.I.I	K 	  "--fmm.@.2.F.F	H 	  "--dll.B.2.I.I	K 	rl   c                    g | _         t        j                  j                  d      t        j
                  j                  k(  t        _        t        j                  st        j                  r t        j                  j                         f}n6t        j                  j                         }d}t        |      D ]  }||fz  }
 |D ]  }t        |      }t        j                          }t"        j$                  j'                  ||j(                  j*                  |j(                  j,                         |j/                  |       | j                   j1                  |       | j3                  |        | j5                          y)zk
        Iterate through the monitors, and create MonitorViews for each one
        to cover them.
        zpicture-optionsr   N)r:   r   bg_settingsget_enumr   BackgroundStyleSPANNEDr(   Spannedr)   rc   get_primary_monitorget_n_monitorsranger	   r   Imager3   r4   create_and_set_gtk_imager   r   r   set_next_wallpaper_imageappendadd_child_widgetupdate_monitor_views)ri   r:   niindexrt   images          rk   ro   zStage.setup_monitors  s$   
 !--667HI]MjMjMrMrr""fnn99;=H,,.AH1X !QD !  	+E!%(GIIKE"";;U=D\\=O=O=D\\=P=PR ,,U3MM  )!!'*	+ 	!!#rl   c                    | j                   D ]p  }t        j                         }t        j                  j                  ||j                  j                  |j                  j                         |j                  |       r y)z
        Callback for our GnomeBackground instance, this tells us when
        the background settings have changed, so we can update our wallpaper.
        N)
r:   r   r   r3   r4   r   r   r   r   r   )ri   bgrt   r   s       rk   r5   zStage.on_bg_changed  sc    
 }} 	4GIIKE"";;U=D\\=O=O=D\\=P=PR ,,U3	4rl   c                 h    t        d       | j                  | j                  j                          yy)z
        Callback for UPower changes, this will make our MonitorViews update
        themselves according to user setting and power state.
        z/stage: Power state changed, updating info panelN)r   rA   update_visibility)ri   clientr{   s      rk   r_   zStage.on_power_state_changed  s,    
 	?@??&OO--/ 'rl   c                    t        | j                  t        j                  j	                         t        j                  j                               | _        | j                  | j                         | j                  j                  | j                         t        j                         r| j                  j                          yy)a-  
        Construct the clock widget and add it to the overlay, but only actually
        show it if we're a) Not running a plug-in, and b) The user wants it via
        preferences.

        Initially invisible, regardless - its visibility is controlled via its
        own positioning timer.
        N)r   r8   r(   rc   get_mouse_monitorget_low_res_moder=   r   rC   r   r   get_show_clockstart_positioningr   s    rk   r   zStage.setup_clock  s     ((9(96==;Z;Z;\^d^k^k^|^|^~d//0T../""$//1 %rl   c                 <   t        dt        j                  j                               | _        | j                  | j                         | j                  j                  | j                         t        j                         r| j                  j                          yy)a0  
        Construct the AlbumArt widget and add it to the overlay, but only actually
        show it if we're a) Not running a plug-in, and b) The user wants it via
        preferences.

        Initially invisible, regardless - its visibility is controlled via its
        own positioning timer.
        N)r   r(   rc   r   r>   r   rC   r   r   get_show_albumartr   r   s    rk   r   zStage.setup_albumart  so      (fmm.M.M.OPd223T112%%'  224 (rl   c                 X    t               | _        | j                  | j                         y r   )r   rB   r   r   s    rk   r   zStage.setup_osk  s    #%dhh'rl   c                    t               | _        | j                  | j                  j                         | j	                  | j                         t        j                         j                  | j                  d| j                  d       t        j                         j                  | j                  d| j                  d       t        j                         j                  | j                  d| j                  d       t        j                         j                  | j                  d| j                  d       t        j                         j                  | j                  d| j                         y)	a  
        Construct the unlock dialog widget and add it to the overlay.  It will always
        initially be invisible.

        Any time the screensaver is awake, and the unlock dialog is raised, a timer runs.
        After a certain elapsed time, the state will be reset, and the dialog will be hidden
        once more.  Mouse and key events reset this timer, and the act of authentication
        temporarily suspends it - the unlock widget accomplishes this via its inhibit- and
        uninhibit-timeout signals

        We also listen to actual authentication events, to destroy the stage if there is success,
        and to do something cute if we fail (for now, this consists of 'blinking' the unlock
        dialog.)
        r   Fr   Tr   r   r   N)r
   r?   set_defaultauth_unlock_buttonr   r   r1   r2   r   r   r   r   s    rk   r   zStage.setup_unlock   s,    *^++>>?d001 	  "**4+=+=+<+/+B+BE	K 	  "**4+=+=+>+/+B+BD	J
 	  "**4+=+=+A+/+N+NPT	V 	  "**4+=+=+A+/+N+NPU	W 	  "**4+=+=+@+/+N+N	Prl   c                 4   t               | _        | j                  | j                         t        j                  r| j                  j                          t               | _        | j                  | j                         | j                  j                          y)zW
        Constructs the AudioPanel and InfoPanel and adds them to the overlay.
        N)	r   r@   r   r(   Awake
show_panelr   rA   refresh_power_stater   s    rk   r   zStage.setup_status_bars&  sf     &<d../<<'')#+doo.++-rl   c                 :    | j                   j                  |       y)ab  
        Sent from our EventHandler via the ScreensaverManager, this catches
        initial key events before the unlock dialog is made visible, so that
        the user doesn't have to first jiggle the mouse to wake things up before
        beginning to type their password.  They can just start typing, and no
        keystrokes will be lost.
        N)r?   queue_key_eventri   r   s     rk   queue_dialog_key_eventzStage.queue_dialog_key_event5  s     	**51rl   c                 (    | j                  dd       y)z
        This is called when any user event is received in our EventHandler.
        This restarts our dialog timeout.
        NT)r   r   s    rk   reset_timeoutzStage.reset_timeoutB  s    
 	d+rl   c                     |rQt         j                  sAt        j                         j	                  dt
        j                  dz  | j                         yt        j                         j                  d       y)z0
        Start or stop the dialog timer
        zwake-timeouti  N)	r(   r)   r   r   r   rj   UNLOCK_TIMEOUTon_wake_timeoutr   )ri   dialogactives      rk   r   zStage.set_timeout_activeI  sY     &11&&(..~/0/?/?$/F/3/C/CE &&(//?rl   c                 \    | j                  dd       | j                  j                          y)z<
        Go back to Sleep if we hit our timer limit
        NF)r   r7   cancel_unlockingr   s    rk   r   zStage.on_wake_timeoutT  s'     	e,%%'rl   c                 >   |r| j                   | j                   j                          | j                  | j                  j                          | j                  j                          | j                  j                          y| j                  j                          y)z
        Called by authentication success or failure.  Either starts
        the stage despawning process or simply 'blinks' the unlock
        widget, depending on the outcome.
        N)r=   r   r>   r?   r7   unlockblink)ri   r   successs      rk   r   z$Stage.authentication_result_callback]  sw       ,!!&&(##/$$))+##%LL!$$&rl   c                 8    | j                   j                          y r   )r7   r   )ri   r   s     rk   r   z$Stage.authentication_cancel_callbackm  s    %%'rl   c                 T    | j                   | j                   j                  |       yy)z<
        Passes along an away-message to the clock.
        N)r=   set_message)ri   msgs     rk   r   zStage.set_messagep  s)     ())#. )rl   c                 6    | j                   j                         S r   )r?   initialize_auth_clientr   s    rk   initialize_pamzStage.initialize_pamw  s    !!88::rl   c                 l   | j                          t        j                  ryt        j                  j	                          t        j                  | j                         | j                  | j                  j                          | j                  | j                  j                          dt        _        | j                  r| j                  j                          | j                  | j                  j                          | j                  | j                  j                          | j                  j                          | j                  | j                  j                          | j                  | j                  j                          | j                   | j                   j                          yy)zR
        Bring the unlock widget to the front and make sure it's visible.
        NT)r   r(   r   rc    place_pointer_in_primary_monitorr   clear_clipboardsr?   r=   r   r>   rA   r   r   r@   r   rB   r   s    rk   raise_unlock_widgetzStage.raise_unlock_widgetz  s:    	<<669t112(..0+  113??OO//1(""$+  %%'!''')??&OO//188HHMMO  rl   c                    | j                   r| j                   j                          | j                  d d       t        j                  | j                          | j                   | j                   j                          | j                  | j                  j                          | j                  | j                  j                          | j                  | j                  j                          | j                  | j                  j                          | j                  | j                  j                          dt        _        | j                          | j                  | j                  j                          y y r   )r?   r   r   r   r  r   r=   r>   r@   rA   rB   r(   r   r   r   r   s    rk   r   zStage.cancel_unlocking  s   %%'e,t112)##%(""$+  %%''!!#??&OO  "88HHMMO!!#??&OO//1 'rl   c                 N   t         j                  st| j                  .t        j                         r| j                  j                          | j                  .t        j                         r| j                  j                          | j                  D ]  }|j                           y)z]
        Updates all of our MonitorViews based on the power
        or Awake states.
        N)
r(   r   r=   r   r   r   r>   r   r:   r   ri   rt   s     rk   r   zStage.update_monitor_views  sy     ||  ,1H1H1J!!335##/H4N4N4P$$668}} 	G	rl   c                 H    | j                   D ]  }|j                          ~ y)z*
        Destroy all MonitorViews
        N)r:   r   r
  s     rk   rn   zStage.destroy_monitor_views  s$     }} 	GOO	rl   c                 8    | j                   j                  |      S )zQ
        GtkWidget class motion-event handler.  Delegate to EventHandler
        )rD   on_motion_eventr   s     rk   do_motion_notify_eventzStage.do_motion_notify_event  s     !!11%88rl   c                 8    | j                   j                  |      S )zT
        GtkWidget class key-press-event handler.  Delegate to EventHandler
        )rD   on_key_press_eventr   s     rk   do_key_press_eventzStage.do_key_press_event  s     !!44U;;rl   c                 8    | j                   j                  |      S )zW
        GtkWidget class button-press-event handler.  Delegate to EventHandler
        )rD   on_button_press_eventr   s     rk   do_button_press_eventzStage.do_button_press_event  s     !!77>>rl   c                    t         j                  rCt         j                  j                         }t         j                  j	                  |      | _        nt         j                  j                         | _        t         j                  j                         }| j
                  xj                  |z  c_        | j
                  xj                  |z  c_	        t        d| j
                  j                  | j
                  j                  | j
                  j                  | j
                  j                  fz         t        j                         }| j
                  j                  |_        | j
                  j                  |_        | j
                  j                  |_        | j
                  j                  |_        | j
                  j                  |_        | j
                  j                  |_        | j+                  | |t        j,                  j.                  t        j,                  j0                  z  t        j,                  j2                  z         y)z
        Override BaseWindow.update_geometry() - the Stage should always be the
        GdkScreen size, unless status.InteractiveDebug is True
        zHStage.update_geometry - new backdrop position: %d, %d  new size: %d x %dN)r(   r)   rc   r   get_monitor_geometryr   get_screen_geometryget_global_scaler   r   r   r   r   r   Geometry	min_width
min_height	max_width
max_height
base_widthbase_heightset_geometry_hintsWindowHintsMIN_SIZEMAX_SIZE	BASE_SIZE)ri   	monitor_nscalehintss       rk   rW   zStage.update_geometry  s    ""99;I::9EDI99;DIMM224EIIOOu$OII%X\`\e\e\g\gimirirititvzvv  wF  wF  HL  HQ  HQ  HX  HX  \Y  Y  	Z))//99++))//99++99?? II,,eS__-E-EH`H`-`cfcrcrc|c|-|}rl   c                     t         j                  rt         j                  j                         S t         j                  j	                         S r   )r(   r)   rc   r   r   r   s    rk   r   zStage.get_mouse_monitor  s1    ""==4466==2244rl   c                     t         j                  j                         }| j                  dk(  r|| _        y| j                  r2|| j                  k7  r"|| _        | j
                  j                          yyy)z
        Called on all user events, moves widgets to the currently
        focused monitor if it changes (whichever monitor the mouse is in)
        r    N)r(   rc   r   r;   r?   r<   queue_resize)ri   current_focus_monitors     rk   maybe_update_layoutzStage.maybe_update_layout  sh    
 !' ? ? A""b(&;D#"74;R;R"R&;D#LL%%' #Srl   c                 :    | j                   j                  |       y)z0
        Add a new child to the overlay
        N)r<   add_overlayri   r   s     rk   r   zStage.add_child_widget  s     	  (rl   c                 <    | j                   j                  |d       y)z;
        Move a child to the bottom of the overlay
        r   N)r<   reorder_overlayr/  s     rk   rp   zStage.sink_child_widget  s     	$$VQ/rl   c                    t        |t              r	 |j                         \  }}|j                  j                  |_        |j                  j
                  |_        |j                  j                  |_        |j                  j                  |_        yt        |t              r	 t        j                  j                         }t        j                  j                  |      }|j                         \  }}	|	j                  |_        |	j                  |_        |j                  |j                  dz  z   |j                  dz  z
  |_        |j
                  |j                  dz  z   |j                  dz  z
  |_        yt        |t              st        |t              r	 |j                         \  }}	t        j                  rt        j                  j                         }
n|j                   }
t        j                  j                  |
      }|j                  dz  }|j                  }t        j                  r	 | j"                  j%                         \  }}	 ||kD  r|j                  |z
  dz  }|j                  }t        |t              r*|j'                  t(        j*                  j,                         n)|j'                  t(        j*                  j.                         |j1                  t(        j*                  j2                         n2t5        j6                         r| j8                  D ]  }	 ||u r
|j;                         |j;                         k7  r"|j=                         |j=                         k7  rM|j                  dz  }|j;                         }|j;                         }||k(  r#t>        tA        jB                  dd         }||k(  r#|j'                  |       |j=                         }|j=                         }||k(  r#t>        tA        jB                  dd         }||k(  r#|j1                  |        tE        |	j                  |      |_        tE        |	j                  |      |_        ||j                  z
  dz  x}}||j                  z
  dz  x}}|j;                         }|j=                         }|t(        j*                  j,                  k(  r|j                  |z   |_        n|t(        j*                  j2                  k(  r2|j                  |j                  dz  z   |j                  dz  z
  |_        nK|t(        j*                  j.                  k(  r.|j                  |j                  z   |j                  z
  |z
  |_        |t(        j*                  j,                  k(  r|j
                  |z   |_        y|t(        j*                  j2                  k(  r2|j
                  |j                  dz  z   |j                  dz  z
  |_        y|t(        j*                  j.                  k(  r.|j
                  |j                  z   |j                  z
  |z
  |_        yt        |tF              r	 |j                         \  }}	t        j                  rt        j                  j                         }
t        j                  j                  |
      }|j                  |_        |j
                  |_        |	j                  |_        |	j                  |_        y|j                  j                  |_        |j                  j
                  |_        |	j                  |_        |	j                  |_        yt        |tH              r=	 |j                         \  }}	t        j                  rt        j                  j                         }
t        j                  j                  |
      }|j                  |j                  z   |	j                  z
  |_        |j
                  |_        |	j                  |_        |	j                  |_        y|j                  j                  |j                  j                  z   |	j                  z
  |_        |j                  j
                  |_        |	j                  |_        |	j                  |_        yt        |tJ              r	 |j                         \  }}	t        j                  j                         }
t        j                  j                  |
      }|j                  |_        |j
                  |j                  z   |j                  dz  z
  |_        |j                  |_        |j                  dz  |_        yy)a:  
        Callback for our GtkOverlay, think of this as a mini-
        window manager for our Stage.

        Depending on what type child is, we position it differently.
        We always call child.get_preferred_size() whether we plan to use
        it or not - this prevents allocation warning spew, particularly in
        Gtk >= 3.20.

        Returning True says, yes draw it.  Returning False tells it to skip
        drawing.

        If a new widget type is introduced that spawns directly on the stage,
        it must have its own handling code here.
        T      r   F)&
isinstancer	   get_preferred_sizer   r   r   r   r   r
   r(   rc   r   r  r   r   r   current_monitorr?   get_preferred_width
set_halignr   AlignSTARTEND
set_valignCENTERr   get_allow_floatingrC   
get_halign
get_valignr   randomrandintminr   r   r   )ri   r<   child
allocationr   hrt   monitor_rectmin_rectnat_rectr7  region_wregion_h	unlock_mw	unlock_nwfloaterfacapadding_leftpadding_rightpadding_toppadding_bottomhalignvaligns                           rk   rZ   zStage.position_overlay_child"  sf     e[) ++-DAq ::<<JL ::<<JL$zz//J %

 1 1Je\* mm557G!====gFL!&!9!9!;Hh'~~J (J'>>\-?-?!-CD
HXHX[\H\]JL'>>\-@-@1-DEIZIZ]^I^_JLe[)Zx-H "'!9!9!;Hh||"(--"A"A"C"'"7"7!====oNL#))A-H#**H|| (,'9'9'M'M'O$	9
 x' , 2 2Y >!CH'..e[1$$SYY__5$$SYY]]3  !1!12..0#'== - #e+$"--/53C3C3EE'J\J\J^bgbrbrbtJt$#/#6#6#:$//1"--/ Bh!+FNN1a,@!AB !Bh((,$//1"--/ Bh!+FNN1a,@!AB !Bh((,+-0  #8>>8<J #HOOX >J -5z7G7G,G1+LLL=,4z7H7H,HA+MMK.%%'F%%'F(+~~<
399++++~~1C1Ca1GHJL\L\_`L`a
399==(+~~0B0BBZEUEUUXee
(+~~;
  399++++~~1D1Dq1HIZM^M^abMbc
  399==(+~~0C0CCjFWFWWZhh
eZ( "'!9!9!;Hh||"(--"A"A"C%}}AA/R+~~
+~~
#+>>
 $,OO
!   %zz||
$zz||
#+>>
 $,OO
!eY' "'!9!9!;Hh||"(--"A"A"C%}}AA/R+~~0B0BBX^^S
+~~
#+>>
 $,OO
!   %zz||ejj.>.>>O
$zz||
#+>>
 $,OO
!e-. "'!9!9!;Hh$mm==?O!====oNL'>>JL'>>L,?,??<CVCVYZCZ[JL+11J , 3 3a 7Jrl   r   )4__name__
__module____qualname____doc__r   SignalFlagsRUN_LAST__gsignals__r+   rv   rd   re   rf   rg   r   r   rY   r   r   r   r   r   r   ro   r5   r_   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   rn   r  r  r  rW   r   r,  r   rp   rZ   r   rl   rk   r   r      s    	'--66bALe1NG##'
.%0
7'(<T#5n:x$B402"5"(
$PL.2,	@' (/;#J269<?~<5()0Orl   r   )(girequire_versiongi.repositoryr   r   r   r   r   r   rB  r(   	constantsrj   r3   monitorViewr	   r   r
   clockr   albumArtr   
audioPanelr   	infoPanelr   rB   r   floatingr   utilr   r   r   util.eventHandlerr   
util.utilsr   r*   r   r   rl   rk   <module>rl     sd    
   ?E * N N     #    !     * * * YCJJ Yrl   