Skip to content

Commit

Permalink
#901: inconify all windows when the session is locked
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@10762 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 8, 2015
1 parent 5b1d4cf commit 3751f63
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions src/xpra/platform/win32/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,28 @@ def show_desktop(b):
log.warn("failed to call show_desktop(%s): %s", b, e)


WM_WTSSESSION_CHANGE = 0x02b1
WTS_CONSOLE_CONNECT = 0x1
WTS_CONSOLE_DISCONNECT = 0x2
WTS_REMOTE_CONNECT = 0x3
WTS_REMOTE_DISCONNECT = 0x4
WTS_SESSION_LOGON = 0x5
WTS_SESSION_LOGOFF = 0x6
WTS_SESSION_LOCK = 0x7
WTS_SESSION_UNLOCK = 0x8
WTS_SESSION_REMOTE_CONTROL = 0x9
WTS_SESSION_EVENTS = {
WTS_CONSOLE_CONNECT : "CONSOLE CONNECT",
WTS_CONSOLE_DISCONNECT : "CONSOLE_DISCONNECT",
WTS_REMOTE_CONNECT : "REMOTE_CONNECT",
WTS_REMOTE_DISCONNECT : "REMOTE_DISCONNECT",
WTS_SESSION_LOGON : "SESSION_LOGON",
WTS_SESSION_LOGOFF : "SESSION_LOGOFF",
WTS_SESSION_LOCK : "SESSION_LOCK",
WTS_SESSION_UNLOCK : "SESSION_UNLOCK",
WTS_SESSION_REMOTE_CONTROL: "SESSION_REMOTE_CONTROL",
}

class ClientExtras(object):
def __init__(self, client, opts):
self.client = client
Expand All @@ -561,6 +583,7 @@ def __init__(self, client, opts):
el.add_event_callback(win32con.WM_ACTIVATEAPP, self.activateapp)
el.add_event_callback(win32con.WM_POWERBROADCAST, self.power_broadcast_event)
el.add_event_callback(win32con.WM_MOVE, self.wm_move)
el.add_event_callback(WM_WTSSESSION_CHANGE, self.session_change_event)
except Exception as e:
log.error("cannot register focus and power callbacks: %s", e)

Expand All @@ -583,6 +606,16 @@ def wm_move(self, wParam, lParam):
#but we do want to process it as such (see window reinit code)
c.screen_size_changed()

def session_change_event(self, event, session):
event_name = WTS_SESSION_EVENTS.get(event, event)
log("WM_WTSSESSION_CHANGE: %s on session %#x", event_name, session)
c = self.client
if c and event in (WTS_SESSION_LOGOFF, WTS_SESSION_LOCK):
log("will iconify all our windows")
for window in c._id_to_window.values():
if not window.is_tray():
window.iconify()

def activateapp(self, wParam, lParam):
c = self.client
log("WM_ACTIVATEAPP: %s/%s client=%s", wParam, lParam, c)
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/platform/win32/wndproc_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
0x02a1: "WM_MOUSEHOVER",
0x02a2: "WM_NCMOUSELEAVE",
0x02a3: "WM_MOUSELEAVE",
0x02b1: "WM_WTSSESSION_CHANGE",
0x0300: "WM_CUT",
0x0301: "WM_COPY",
0x0302: "WM_PASTE",
Expand Down Expand Up @@ -740,4 +741,4 @@
0x2210: "OCM_PARENTNOTIFY",
0x8000: "WM_APP",
0xcccd: "WM_RASDIALEVENT",
}
}

0 comments on commit 3751f63

Please sign in to comment.