From 04e16a2d5e914475010085e6f3c012e7ef6382b6 Mon Sep 17 00:00:00 2001
From: Manuel Schneider
Date: Tue, 20 May 2014 13:56:36 +0200
Subject: Reduce code
* Reduce code of prepareForProjection (broadcast part)
* Make toolbar icons 48x48 px (were too large for standard windowsize)
---
gui/server_normal/mainwindow.ui | 4 +--
src/server/mainwindow/mainwindow.cpp | 51 +++++++++---------------------------
2 files changed, 15 insertions(+), 40 deletions(-)
diff --git a/gui/server_normal/mainwindow.ui b/gui/server_normal/mainwindow.ui
index 9bf32aa..6d29c97 100644
--- a/gui/server_normal/mainwindow.ui
+++ b/gui/server_normal/mainwindow.ui
@@ -67,8 +67,8 @@
- 64
- 64
+ 48
+ 48
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index 175d2fa..08ce7d0 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -439,53 +439,28 @@ bool MainWindow::isValidClient(Client* client)
*/
void MainWindow::broadcast(Client *from)
{
- for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- if ((*it)->client() != NULL && !(**it).isTutor())
- (*it)->client()->setProjectionSource(false);
-
// Projection source is never allowed to be an active VNC viewer
if (from->isActiveVncClient())
- {
- qDebug("From is active client, stopping...");
from->stopVncClient();
+
+ // Tell all clients to listen to server
+ for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it){
+ if ((*it)->client() != NULL)
+ (*it)->client()->setProjectionSource(false);
}
- from->setDesiredProjectionSource(0);
- qDebug("Broadcast requested...");
+ from->setDesiredProjectionSource(0);
from->setProjectionSource(true);
- // Set desired projection source on all clients
+ // Set desired projection source on all clients, if not "from" or oflline
for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- Client *c = (**it).client();
- if (c == NULL || c->id() == from->id())
- continue; // Self or offline
- c->setDesiredProjectionSource(from->id());
- }
+ if ((*it)->client() != NULL && (*it)->client()->id() != from->id())
+ (*it)->client()->setDesiredProjectionSource(from->id());
- if (from->isActiveVncServer())
- {
- // From is already active, if there is at least one active client, assume it is not
- // shutting down, so we can directly tell the new client to connect to it
- qDebug("Source is already running a VNC server....");
- for (QList::iterator it(_clientFrames.begin()); it != _clientFrames.end(); ++it)
- {
- Client *c = (**it).client();
- if (c == NULL || c->id() == from->id())
- continue; // Self or offline
- if (c->currentProjectionSource() != from->id())
- continue; // Other client
- // Yep :-)
- qDebug("Reusing because of active client");
- this->onVncServerStateChange(from);
- return;
- }
- qDebug("But no active client found....");
- }
- // Could not take shortcut, (re)start VNC server on source
- qDebug("Starting VNC server on source machine");
- from->startVncServer();
- return;
+ if (from->isActiveVncServer()) // From is already active
+ this->onVncServerStateChange(from);
+ else // Could not take shortcut, (re)start VNC server on source
+ from->startVncServer();
}
--
cgit v1.2.3-55-g7522