Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of Xpra. 

2# Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com> 

3# Copyright (C) 2012-2019 Antoine Martin <antoine@xpra.org> 

4# Xpra is released under the terms of the GNU GPL v2, or, at your option, any 

5# later version. See the file COPYING for details. 

6 

7from xpra.x11.bindings.window_bindings import constants, X11WindowBindings #@UnresolvedImport 

8from xpra.log import Logger 

9 

10log = Logger("x11", "focus") 

11 

12X11Window = X11WindowBindings() 

13 

14CurrentTime = constants["CurrentTime"] 

15SubstructureNotifyMask = constants["SubstructureNotifyMask"] 

16SubstructureRedirectMask = constants["SubstructureRedirectMask"] 

17 

18 

19def send_wm_take_focus(target, timestamp): 

20 xid = target.get_xid() 

21 log("sending WM_TAKE_FOCUS: %#x, X11 timestamp=%r", xid, int(timestamp or 0)) 

22 if timestamp<0: 

23 timestamp = CurrentTime #better than nothing... 

24 elif timestamp>0xFFFFFFFF: 

25 raise OverflowError("invalid time: %#x" % timestamp) 

26 elif timestamp>0x7FFFFFFF: 

27 timestamp = int(0x100000000-timestamp) 

28 if timestamp<0x80000000: 

29 return -timestamp 

30 else: 

31 return -0x80000000 

32 X11Window.sendClientMessage(xid, xid, False, 0, 

33 "WM_PROTOCOLS", 

34 "WM_TAKE_FOCUS", timestamp) 

35 

36def send_wm_delete_window(target): 

37 xid = target.get_xid() 

38 log("sending WM_DELETE_WINDOW to %#x", xid) 

39 X11Window.sendClientMessage(xid, xid, False, 0, 

40 "WM_PROTOCOLS", 

41 "WM_DELETE_WINDOW", 

42 CurrentTime) 

43 

44def send_wm_workspace(root, win, workspace=0): 

45 event_mask = SubstructureNotifyMask | SubstructureRedirectMask 

46 X11Window.sendClientMessage(root.get_xid(), win.get_xid(), False, event_mask, 

47 "_NET_WM_DESKTOP", 

48 workspace, CurrentTime) 

49 

50def send_wm_request_frame_extents(root, win): 

51 event_mask = SubstructureNotifyMask | SubstructureRedirectMask 

52 X11Window.sendClientMessage(root.get_xid(), win.get_xid(), False, event_mask, 

53 "_NET_REQUEST_FRAME_EXTENTS", 

54 0, CurrentTime)