{
try {
if (!authenticated()) return;
- if (cp.width && cp.height && (server->pb->width() != cp.width ||
- server->pb->height() != cp.height))
+ if (cp.width && cp.height &&
+ (server->getPixelBuffer()->width() != cp.width ||
+ server->getPixelBuffer()->height() != cp.height))
{
// We need to clip the next update to the new size, but also add any
// extra bits if it's bigger. If we wanted to do this exactly, something
// updates.add_changed(Rect(0, cp.height, cp.width,
// server->pb->height()));
- damagedCursorRegion.assign_intersect(server->pb->getRect());
+ damagedCursorRegion.assign_intersect(server->getPixelBuffer()->getRect());
- cp.width = server->pb->width();
- cp.height = server->pb->height();
- cp.screenLayout = server->screenLayout;
+ cp.width = server->getPixelBuffer()->width();
+ cp.height = server->getPixelBuffer()->height();
+ cp.screenLayout = server->getScreenLayout();
if (state() == RFBSTATE_NORMAL) {
// We should only send EDS to client asking for both
if (!writer()->writeExtendedDesktopSize()) {
}
// Drop any lossy tracking that is now outside the framebuffer
- encodeManager.pruneLosslessRefresh(Region(server->pb->getRect()));
+ encodeManager.pruneLosslessRefresh(Region(server->getPixelBuffer()->getRect()));
}
// Just update the whole screen at the moment because we're too lazy to
// work out what's actually changed.
updates.clear();
- updates.add_changed(server->pb->getRect());
+ updates.add_changed(server->getPixelBuffer()->getRect());
writeFramebufferUpdate();
} catch(rdr::Exception &e) {
close(e.str());
if (!cp.supportsLocalCursorWithAlpha &&
!cp.supportsLocalCursor && !cp.supportsLocalXCursor)
return true;
- if (!server->cursorPos.equals(pointerEventPos) &&
+ if (!server->getCursorPos().equals(pointerEventPos) &&
(time(0) - pointerEventTime) > 0)
return true;
lastEventTime = time(0);
// - Set the connection parameters appropriately
- cp.width = server->pb->width();
- cp.height = server->pb->height();
- cp.screenLayout = server->screenLayout;
+ cp.width = server->getPixelBuffer()->width();
+ cp.height = server->getPixelBuffer()->height();
+ cp.screenLayout = server->getScreenLayout();
cp.setName(server->getName());
- cp.setLEDState(server->ledState);
+ cp.setLEDState(server->getLEDState());
// - Set the default pixel format
- cp.setPF(server->pb->getPF());
+ cp.setPF(server->getPixelBuffer()->getPF());
char buffer[256];
cp.pf().print(buffer, 256);
vlog.info("Server default pixel format %s", buffer);
// - Mark the entire display as "dirty"
- updates.add_changed(server->pb->getRect());
+ updates.add_changed(server->getPixelBuffer()->getRect());
startTime = time(0);
}
}
// Avoid lock keys if we don't know the server state
- if ((server->ledState == ledUnknown) &&
+ if ((server->getLEDState() == ledUnknown) &&
((keysym == XK_Caps_Lock) ||
(keysym == XK_Num_Lock) ||
(keysym == XK_Scroll_Lock))) {
return;
}
- if (down && (server->ledState != ledUnknown)) {
+ if (down && (server->getLEDState() != ledUnknown)) {
// CapsLock synchronisation heuristic
// (this assumes standard interaction between CapsLock the Shift
// keys and normal characters)
uppercase = (keysym >= XK_A) && (keysym <= XK_Z);
shift = isShiftPressed();
- lock = server->ledState & ledCapsLock;
+ lock = server->getLEDState() & ledCapsLock;
if (lock == (uppercase == shift)) {
vlog.debug("Inserting fake CapsLock to get in sync with client");
number = ((keysym >= XK_KP_0) && (keysym <= XK_KP_9)) ||
(keysym == XK_KP_Separator) || (keysym == XK_KP_Decimal);
shift = isShiftPressed();
- lock = server->ledState & ledNumLock;
+ lock = server->getLEDState() & ledNumLock;
if (shift) {
// We don't know the appropriate NumLock state for when Shift
bogusCopiedCursor = damagedCursorRegion;
bogusCopiedCursor.translate(ui.copy_delta);
- bogusCopiedCursor.assign_intersect(server->pb->getRect());
+ bogusCopiedCursor.assign_intersect(server->getPixelBuffer()->getRect());
if (!ui.copied.intersect(bogusCopiedCursor).is_empty()) {
updates.add_changed(bogusCopiedCursor);
needNewUpdateInfo = true;
if (!authenticated())
return;
- cp.screenLayout = server->screenLayout;
+ cp.screenLayout = server->getScreenLayout();
if (state() != RFBSTATE_NORMAL)
return;
cp.setCursor(emptyCursor);
clientHasCursor = false;
} else {
- cp.setCursor(*server->cursor);
+ cp.setCursor(*server->getCursor());
clientHasCursor = true;
}
accessRights = accessRights & ~(AccessPtrEvents | AccessKeyEvents | AccessView);
break;
}
- framebufferUpdateRequest(server->pb->getRect(), false);
+ framebufferUpdateRequest(server->getPixelBuffer()->getRect(), false);
}
int VNCSConnectionST::getStatus()
{
virtual void setPixelBuffer(PixelBuffer* pb, const ScreenSet& layout);
virtual void setPixelBuffer(PixelBuffer* pb);
virtual void setScreenLayout(const ScreenSet& layout);
- virtual PixelBuffer* getPixelBuffer() const { return pb; }
+ virtual const PixelBuffer* getPixelBuffer() const { return pb; }
virtual void serverCutText(const char* str, int len);
virtual void approveConnection(network::Socket* sock, bool accept,
virtual void setCursor(int width, int height, const Point& hotspot,
const rdr::U8* data);
virtual void setCursorPos(const Point& p);
+ virtual void setName(const char* name_);
virtual void setLEDState(unsigned state);
virtual void bell();
// VNCServerST-only methods
+ // Methods to get the currently set server state
+
+ const ScreenSet& getScreenLayout() const { return screenLayout; }
+ const Cursor* getCursor() const { return cursor; }
+ const Point& getCursorPos() const { return cursorPos; }
+ const char* getName() const { return name.buf; }
+ unsigned getLEDState() const { return ledState; }
+
// closeClients() closes all RFB sessions, except the specified one (if
// any), and logs the specified reason for closure.
void closeClients(const char* reason, network::Socket* sock);
SConnection* getSConnection(network::Socket* sock);
- // getName() returns the name of this VNC Server. NB: The value returned
- // is the server's internal buffer which may change after any other methods
- // are called - take a copy if necessary.
- const char* getName() const {return name.buf;}
-
- // setName() specifies the desktop name that the server should provide to
- // clients
- virtual void setName(const char* name_);
-
// queryConnection() is called when a connection has been
// successfully authenticated. The sock and userName arguments identify
// the socket and the name of the authenticated user, if any.