File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 2001-12-14 Peter Liljenberg <peter.liljenberg@esdgkonsult.com>
2+
3+ * display.py (Display.parse_event_response):
4+ * rq.py (Event.__init__): Fixed bug in event type decoding: bit
5+ 0-6 is the event type, and bit 7 is set if the event was sent by
6+ SendEvent.
7+
8+
192001-01-16 <petli@cendio.se>
210
311 * event.py: Changed some class names so that they correspond
Original file line number Diff line number Diff line change 1- # $Id: display.py,v 1.14 2001-12-04 11:41:01 petli Exp $
1+ # $Id: display.py,v 1.15 2001-12-14 17:03:10 petli Exp $
22#
33# Xlib.protocol.display -- core display communication
44#
@@ -733,9 +733,12 @@ def parse_request_response(self, request):
733733
734734
735735 def parse_event_response (self , etype ):
736- estruct = self .event_classes .get (etype , event .AnyEvent )
736+ # Skip bit 8 at lookup, that is set if this event came from an
737+ # SendEvent
738+ estruct = self .event_classes .get (etype & 0x7f , event .AnyEvent )
737739
738740 e = estruct (display = self , binarydata = self .data_recv [:32 ])
741+
739742 self .data_recv = buffer (self .data_recv , 32 )
740743
741744 # Drop all requests having an error handler,
Original file line number Diff line number Diff line change 1- # $Id: rq.py,v 1.11 2001-02-19 11:16 :10 petli Exp $
1+ # $Id: rq.py,v 1.12 2001-12-14 17:03 :10 petli Exp $
22#
33# Xlib.protocol.rq -- structure primitives for request, events and errors
44#
@@ -1383,15 +1383,19 @@ def __repr__(self):
13831383
13841384
13851385class Event (GetAttrData ):
1386- def __init__ (self , binarydata = None , display = None , ** keys ):
1386+ def __init__ (self , binarydata = None , display = None ,
1387+ ** keys ):
13871388 if binarydata :
13881389 self ._binary = binarydata
13891390 self ._data , data = self ._fields .parse_binary (binarydata , display ,
13901391 rawdict = 1 )
1392+ # split event type into type and send_event bit
1393+ self ._data ['send_event' ] = not not self ._data ['type' ] & 0x80
1394+ self ._data ['type' ] = self ._data ['type' ] & 0x7f
13911395 else :
13921396 if self ._code :
13931397 keys ['type' ] = self ._code
1394-
1398+
13951399 keys ['sequence_number' ] = 0
13961400
13971401 self ._binary = apply (self ._fields .to_binary , (), keys )
Original file line number Diff line number Diff line change 11#!/usr/bin/python
22#
3- # $Id: draw.py,v 1.4 2000 -12-21 12:23:07 petli Exp $
3+ # $Id: draw.py,v 1.5 2001 -12-14 17:03:10 petli Exp $
44#
55# examples/draw.py -- high-level xlib test application.
66#
@@ -61,10 +61,14 @@ def __init__(self, display):
6161
6262 # Set some WM info
6363
64+ self .WM_DELETE_WINDOW = self .d .intern_atom ('WM_DELETE_WINDOW' )
65+ self .WM_PROTOCOLS = self .d .intern_atom ('WM_PROTOCOLS' )
66+
6467 self .window .set_wm_name ('Xlib example: draw.py' )
6568 self .window .set_wm_icon_name ('draw.py' )
6669 self .window .set_wm_class ('draw' , 'XlibExample' )
6770
71+ self .window .set_wm_protocols ([self .WM_DELETE_WINDOW ])
6872 self .window .set_wm_hints (flags = Xutil .StateHint ,
6973 initial_state = Xutil .NormalState )
7074
@@ -106,6 +110,12 @@ def loop(self):
106110 if e .type == X .MotionNotify and current :
107111 current .motion (e )
108112
113+ if e .type == X .ClientMessage :
114+ if e .client_type == self .WM_PROTOCOLS :
115+ fmt , data = e .data
116+ if fmt == 32 and data [0 ] == self .WM_DELETE_WINDOW :
117+ sys .exit (0 )
118+
109119# A drawed objects, consisting of either a single
110120# romboid, or two romboids connected by a winding line
111121
You can’t perform that action at this time.
0 commit comments