From 6534027c5ce5579c4293aa346cadf0850aa02157 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 19 Oct 2016 23:56:34 +0200 Subject: Implement "Attention" feature (virtual hand-raising) --- src/client/net/serverconnection.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/client/net/serverconnection.cpp') diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index 1275921..02c35fd 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -66,6 +66,14 @@ void ServerConnection::sendMessage(NetworkMessage& message) } } +void ServerConnection::sendAttention(bool on) +{ + NetworkMessage msg; + msg.setField(_ID, _ATTENTION); + msg.setField(_ENABLE, _BOOL(on)); + sendMessage(msg); +} + /** * Disconnect from current server. * Do some cleanup also, like stopping any VNC server/client @@ -177,18 +185,21 @@ void ServerConnection::handleMsg() } int x = _fromServer.getFieldString(_X).toInt(); int y = _fromServer.getFieldString(_Y).toInt(); - if (x < 32) - x = 32; - else if (x > 400) - x = 400; - if (y < 18) - y = 18; - else if (y > 300) - y = 300; // Get rect of primary screen const QDesktopWidget primary; const QRect primaryRect = primary.screenGeometry(); + // Limit requested size so it won't easily leak sensitive information + if (x < 32) { + x = 32; + } else if (x > primaryRect.width() / 8) { + x = primaryRect.width() / 8; + } + if (y < 18) { + y = 18; + } else if (y > primaryRect.height() / 8) { + y = primaryRect.height() / 8; + } QPixmap desktop( QPixmap::grabWindow( @@ -255,6 +266,8 @@ void ServerConnection::handleMsg() _blank->lock(_fromServer.getFieldString("MESSAGE")); else _blank->unlock(); + } else if (id == _ATTENTION) { + emit attentionChanged(_fromServer.getFieldString(_ENABLE) == __TRUE); } } -- cgit v1.2.3-55-g7522