@@ -93,15 +93,15 @@ def client_dir_read(handle_id: int, entry_num: int | None = None, client_id: int
9393
9494def client_drag_register (client_id : int = 0 ) -> bytes :
9595 """Escape code a client sends to start offering drags (t=o, no payload)."""
96- meta = f'{ DND_CODE } ;t=o'
96+ meta = f'{ DND_CODE } ;t=o:x=1 '
9797 if client_id :
9898 meta += f':i={ client_id } '
9999 return _osc (meta )
100100
101101
102102def client_drag_unregister (client_id : int = 0 ) -> bytes :
103103 """Escape code a client sends to stop offering drags (t=O)."""
104- meta = f'{ DND_CODE } ;t=O '
104+ meta = f'{ DND_CODE } ;t=o:x=2 '
105105 if client_id :
106106 meta += f':i={ client_id } '
107107 return _osc (meta )
@@ -1303,6 +1303,7 @@ def test_window_close_during_transfer_no_leak(self) -> None:
13031303
13041304 def _setup_drag_offer (self , screen , wid , cap , mimes : str = 'text/plain' , operations : int = 1 , client_id : int = 0 ):
13051305 """Send t=o with operations and payload to set up a drag offer being built."""
1306+ parse_bytes (screen , client_drag_register ())
13061307 parse_bytes (screen , client_drag_offer_mimes (operations , mimes , client_id = client_id ))
13071308 cap .consume (wid ) # discard any output
13081309
@@ -1320,42 +1321,45 @@ def test_drag_register_and_unregister(self) -> None:
13201321 def test_drag_offer_single_mime (self ) -> None :
13211322 """Client can offer a drag with a single MIME type."""
13221323 with dnd_test_window () as (osw , wid , screen , cap ):
1324+ parse_bytes (screen , client_drag_register ())
13231325 parse_bytes (screen , client_drag_offer_mimes (1 , 'text/plain' ))
13241326 # No error expected – the offer is being built.
13251327 self ._assert_no_output (cap , wid )
13261328
13271329 def test_drag_offer_multiple_mimes (self ) -> None :
13281330 """Client can offer a drag with multiple MIME types."""
13291331 with dnd_test_window () as (osw , wid , screen , cap ):
1332+ parse_bytes (screen , client_drag_register ())
13301333 parse_bytes (screen , client_drag_offer_mimes (3 , 'text/plain text/uri-list application/json' ))
13311334 self ._assert_no_output (cap , wid )
13321335
13331336 def test_drag_offer_no_operations_returns_einval (self ) -> None :
13341337 """Offering MIME types with operations=0 (no valid operations) returns EINVAL."""
13351338 with dnd_test_window () as (osw , wid , screen , cap ):
1339+ parse_bytes (screen , client_drag_register ())
13361340 # First need a valid offer to set allowed_operations, but if we pass o=0
13371341 # directly and there's no prior offer, drag_add_mimes should abort with EINVAL.
13381342 parse_bytes (screen , client_drag_offer_mimes (0 , 'text/plain' ))
1339- events = self ._get_events (cap , wid )
1340- self .assertEqual (len (events ), 1 , events )
1341- self .ae (events [0 ]['type' ], 'E' )
1342- self .ae (events [0 ]['payload' ].strip (), b'EINVAL' )
1343+ self .assert_error (cap , wid )
13431344
13441345 def test_drag_offer_copy_only (self ) -> None :
13451346 """Offering with operations=1 (copy only) is accepted."""
13461347 with dnd_test_window () as (osw , wid , screen , cap ):
1348+ parse_bytes (screen , client_drag_register ())
13471349 parse_bytes (screen , client_drag_offer_mimes (1 , 'text/plain' ))
13481350 self ._assert_no_output (cap , wid )
13491351
13501352 def test_drag_offer_move_only (self ) -> None :
13511353 """Offering with operations=2 (move only) is accepted."""
13521354 with dnd_test_window () as (osw , wid , screen , cap ):
1355+ parse_bytes (screen , client_drag_register ())
13531356 parse_bytes (screen , client_drag_offer_mimes (2 , 'text/plain' ))
13541357 self ._assert_no_output (cap , wid )
13551358
13561359 def test_drag_offer_copy_and_move (self ) -> None :
13571360 """Offering with operations=3 (copy+move) is accepted."""
13581361 with dnd_test_window () as (osw , wid , screen , cap ):
1362+ parse_bytes (screen , client_drag_register ())
13591363 parse_bytes (screen , client_drag_offer_mimes (3 , 'text/plain text/html' ))
13601364 self ._assert_no_output (cap , wid )
13611365
@@ -1556,6 +1560,7 @@ def test_drag_client_id_propagated(self) -> None:
15561560 """The client_id (i=…) set during drag offer is echoed in error replies."""
15571561 client_id = 99
15581562 with dnd_test_window () as (osw , wid , screen , cap ):
1563+ parse_bytes (screen , client_drag_register ())
15591564 parse_bytes (screen , client_drag_offer_mimes (1 , 'text/plain' , client_id = client_id ))
15601565 self ._assert_no_output (cap , wid )
15611566 # Starting the drag will fail (no real window), producing an error with client_id
@@ -1582,6 +1587,7 @@ def test_drag_chunked_mime_offer(self) -> None:
15821587 """A large MIME list can be sent in chunks using m=1."""
15831588 with dnd_test_window () as (osw , wid , screen , cap ):
15841589 # First chunk with m=1 (more coming)
1590+ parse_bytes (screen , client_drag_register ())
15851591 parse_bytes (screen , client_drag_offer_mimes (1 , 'text/plain ' , more = True ))
15861592 self ._assert_no_output (cap , wid )
15871593
0 commit comments