
     h                     `   d Z ddlZddlZddlZ ej                  d      ZddlZddlmZmZm	Z	m
Z
 ddlmZmZmZ ej                  d        Zd Zd	 Zd
 Zd Zej*                  j-                   e       dk  d      d        Zej*                  j-                   e       dk  d      d        Zy)z
    cairocffi.test_xcb
    ~~~~~~~~~~~~~~~~~~

    Test suite for cairocffi.xcb.

    :copyright: Copyright 2014-2019 by Simon Sapin
    :license: BSD, see LICENSE for details.

    Nxcffib)ConfigWindowCW	EventMaskGC   )Context
XCBSurfacecairo_versionc               #      K   t         j                  j                  d      } | t        j                  d       t        j                  |       }| |j                          yw)zs
    Fixture that will setup and take down a xcffib.Connection object running on
    a display spawned by xvfb
    DISPLAYNz$DISPLAY environment variable not set)osenvirongetpytestskipr   connect
disconnect)displayconns     n/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/cairocffi/test_xcb.pyxcb_connr      sI      jjnnY'G:;>>'"D
JOOs   A!A#c                     | j                   j                  | j                     }|j                  D ]2  }|j                  D ]!  }|j
                  |j                  k(  s|c c S  4 y)zBFind the xcffib.xproto.VISUALTYPE corresponding to the root visualN)setuprootspref_screenallowed_depthsvisuals	visual_idroot_visual)r   default_screenivs       r   find_root_visualr$   (   s[    ZZ%%d&6&67N**  	A{{n888	    c                    | j                         }| j                  j                  | j                     }| j                  j                  |j                  ||j                  dd||dt        j                  j                  j                  |j                  t        j                  t        j                  z  |j                   t        j"                  t        j$                  z  g       |S )<Creates a window of the given dimensions and returns the XIDr   )generate_idr   r   r   coreCreateWindow
root_depthrootr   xprotoWindowClassInputOutputr    r   	BackPixelr   black_pixelExposureStructureNotify)r   widthheightwidr!   s        r   create_windowr7   1   s    



CZZ%%d&6&67NII!!	1eVQ!!--""
r||#&&!:!::	
 Jr%   c                     | j                         }| j                  j                  | j                     }| j                  j                  |j                  ||||       |S )r'   )r(   r   r   r   r)   CreatePixmapr+   )r   r6   r4   r5   pixmapr!   s         r   create_pixmapr;   G   sV    FZZ%%d&6&67NII!!v Mr%   c                 &   | j                         }| j                  j                  | j                     }| j                  j                  ||j                  t        j                  t        j                  z  |j                  |j                  g       |S )z!Creates a simple graphics context)r(   r   r   r   r)   CreateGCr,   r   
Foreground
Backgroundr1   white_pixel)r   gcr!   s      r   	create_gcrB   U   su    				BZZ%%d&6&67NII
N
%&&&&	
 Ir%   i+  zCairo version too low)reasonc                 r   d}d}t        | ||      }t        | |||      }t        |       }t        |       }t	        | ||||      }|sJ t        |      }|j                  ddd       |j                          | j                  j                  |       | j                          t        j                         }	t        j                         |	dz   k  rP| j                         }
t        |
t        j                  j                         rn0t        j                         |	dz   k  rPt#        j$                  d       | j                  j'                  |||dddd||	       d }d }| j                  j)                  |       | j                  j+                  |       | j                          
r| j-                         }
|
ry y )N
   r   Never received ExposeEventr   )r7   r;   rB   r$   r
   r	   set_source_rgbpaintr)   	MapWindowflushtimewait_for_event
isinstancer   r-   ExposeEventr   failCopyAreaFreeGC
FreePixmappoll_for_event)r   r4   r5   r6   r:   rA   r    surfacectxstartevents              r   test_xcb_pixmaprX   f   s    EF %
0C8S%8F	8	B #8,K6;vFGN7 '
Cq!QIIK MMC NNIIKE
))+

"'')eV]]667 ))+

"
 	01 MM
	1	1v CGMMMMV$ NN
'') r%   c           	         d}d}t        | ||      }| j                  j                  |       | j                          t	        j                         }t	        j                         |dz   k  rP| j                         }t        |t        j                  j                        rn0t	        j                         |dz   k  rPt        j                  d       t        |       }t        | ||||      }|sJ t        |      }|j                  ddd       |j!                          | j                          | j                  j#                  |t$        j&                  t$        j(                  z  t$        j*                  z  t$        j,                  z  dd|dz  |dz  g       | j                          t	        j                         }t	        j                         |dz   k  r| j                         }t        |t        j                  j.                        rA|j0                  d|z  k(  sJ |j2                  d|z  k(  sJ |j0                  }|j2                  }n0t	        j                         |dz   k  rt        j                  d       |j5                  ||       t        |      }|j                  ddd       |j!                          | j                          r| j7                         }|ry y )NrE   rF   r         z#Never received ConfigureNotifyEvent)r7   r)   rI   rJ   rK   rL   rM   r   r-   rN   r   rO   r$   r
   r	   rG   rH   ConfigureWindowr   XYWidthHeightConfigureNotifyEventr4   r5   set_sizerS   )	r   r4   r5   r6   rV   rW   r    rT   rU   s	            r   test_xcb_windowrc      s]    EF %
0C MMC NNIIKE
))+

"'')eV]]667 ))+

"
 	01 #8,K3UFCGN7 '
Cq!QIIKNN MM!!	,..	(  
!#/#6#6
7 qAIvz	
	 NN IIKE
))+

"'')eV]]??@;;!E')))<<1V8+++KKE\\F ))+

" 	9: UF#
'
Cq!QIIK NN
'') r%   )__doc__r   rK   r   importorskipr   xcffib.xprotor   r   r   r    r	   r
   r   fixturer   r$   r7   r;   rB   markxfailrX   rc    r%   r   <module>rl      s   	 
  			X	&  9 9 0 0  ," =?U*1  33*33*l =?U*1  3B*3B*r%   