aboutsummaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/common/randr.cxx62
-rw-r--r--unix/tx/TXButton.h9
-rw-r--r--unix/tx/TXCheckbox.h9
-rw-r--r--unix/tx/TXDialog.h8
-rw-r--r--unix/tx/TXLabel.h4
-rw-r--r--unix/tx/TXWindow.cxx18
-rw-r--r--unix/tx/TXWindow.h10
-rw-r--r--unix/vncconfig/QueryConnectDialog.cxx4
-rw-r--r--unix/vncconfig/QueryConnectDialog.h8
-rw-r--r--unix/vncconfig/vncconfig.cxx42
-rw-r--r--unix/vncpasswd/vncpasswd.cxx12
-rw-r--r--unix/x0vncserver/Geometry.cxx2
-rw-r--r--unix/x0vncserver/Image.cxx49
-rw-r--r--unix/x0vncserver/Image.h12
-rw-r--r--unix/x0vncserver/XDesktop.cxx58
-rw-r--r--unix/x0vncserver/XDesktop.h36
-rw-r--r--unix/x0vncserver/XPixelBuffer.cxx2
-rw-r--r--unix/x0vncserver/XPixelBuffer.h2
-rw-r--r--unix/x0vncserver/x0vncserver.cxx55
-rw-r--r--unix/xserver/hw/vnc/Makefile.am2
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.cc36
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.cc13
-rw-r--r--unix/xserver/hw/vnc/XserverDesktop.h28
-rw-r--r--unix/xserver/hw/vnc/vncExtInit.cc6
24 files changed, 237 insertions, 250 deletions
diff --git a/unix/common/randr.cxx b/unix/common/randr.cxx
index 12c4841f..e4e2d7be 100644
--- a/unix/common/randr.cxx
+++ b/unix/common/randr.cxx
@@ -236,10 +236,14 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Next, reconfigure all known outputs */
for (int i = 0;i < vncRandRGetOutputCount();i++) {
unsigned int output;
+ char *name_;
+ std::string name;
rfb::ScreenSet::const_iterator iter;
output = vncRandRGetOutputId(i);
+ name = name_ = vncRandRGetOutputName(i);
+ free(name_);
/* Known? */
if (outputIdMap->count(output) == 0)
@@ -259,31 +263,24 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Probably not needed, but let's be safe */
if (!vncRandRIsOutputUsable(i)) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Required output '%s' cannot be used", name);
- free(name);
- }
+ if (logErrors)
+ vlog.error("Required output '%s' cannot be used", name.c_str());
return rfb::resultInvalid;
}
/* Possible mode? */
if (!vncRandRCheckOutputMode(i, iter->dimensions.width(),
iter->dimensions.height())) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Output '%s' does not support required mode %dx%d", name,
+ if (logErrors)
+ vlog.error("Output '%s' does not support required mode %dx%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height());
- free(name);
- }
return rfb::resultInvalid;
}
- char *name = vncRandRGetOutputName(i);
- vlog.debug("Reconfiguring output '%s' to %dx%d+%d+%d", name,
+ vlog.debug("Reconfiguring output '%s' to %dx%d+%d+%d", name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
if (dryrun)
continue;
@@ -295,13 +292,11 @@ static unsigned int _setScreenLayout(bool dryrun,
iter->dimensions.width(),
iter->dimensions.height());
if (!ret) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d", name,
+ if (logErrors)
+ vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
- }
return rfb::resultInvalid;
}
}
@@ -311,6 +306,8 @@ static unsigned int _setScreenLayout(bool dryrun,
for (iter = layout.begin();iter != layout.end();++iter) {
OutputIdMap::const_iterator oi;
unsigned int output;
+ char *name_;
+ std::string name;
int i;
/* Does this screen have an output already? */
@@ -332,6 +329,8 @@ static unsigned int _setScreenLayout(bool dryrun,
return rfb::resultInvalid;
}
output = vncRandRGetOutputId(i);
+ name = name_ = vncRandRGetOutputName(i);
+ free(name_);
/*
* Make sure we already have an entry for this, or
@@ -342,31 +341,24 @@ static unsigned int _setScreenLayout(bool dryrun,
/* Probably not needed, but let's be safe */
if (!vncRandRIsOutputUsable(i)) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Required new output '%s' cannot be used", name);
- free(name);
- }
+ if (logErrors)
+ vlog.error("Required new output '%s' cannot be used", name.c_str());
return rfb::resultInvalid;
}
/* Possible mode? */
if (!vncRandRCheckOutputMode(i, iter->dimensions.width(),
iter->dimensions.height())) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("New output '%s' does not support required mode %dx%d", name,
+ if (logErrors)
+ vlog.error("New output '%s' does not support required mode %dx%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height());
- free(name);
- }
return rfb::resultInvalid;
}
- char *name = vncRandRGetOutputName(i);
- vlog.debug("Reconfiguring new output '%s' to %dx%d+%d+%d", name,
+ vlog.debug("Reconfiguring new output '%s' to %dx%d+%d+%d", name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
if (dryrun)
continue;
@@ -378,13 +370,11 @@ static unsigned int _setScreenLayout(bool dryrun,
iter->dimensions.width(),
iter->dimensions.height());
if (!ret) {
- if (logErrors) {
- char *name = vncRandRGetOutputName(i);
- vlog.error("Failed to reconfigure new output '%s' to %dx%d+%d+%d", name,
+ if (logErrors)
+ vlog.error("Failed to reconfigure new output '%s' to %dx%d+%d+%d",
+ name.c_str(),
iter->dimensions.width(), iter->dimensions.height(),
iter->dimensions.tl.x, iter->dimensions.tl.y);
- free(name);
- }
return rfb::resultInvalid;
}
}
diff --git a/unix/tx/TXButton.h b/unix/tx/TXButton.h
index a51f2ecd..88964833 100644
--- a/unix/tx/TXButton.h
+++ b/unix/tx/TXButton.h
@@ -41,14 +41,15 @@ public:
class TXButton : public TXWindow, public TXEventHandler {
public:
- TXButton(Display* dpy_, const char* text_, TXButtonCallback* cb_=0,
- TXWindow* parent_=0, int w=1, int h=1)
+ TXButton(Display* dpy_, const char* text_,
+ TXButtonCallback* cb_=nullptr,
+ TXWindow* parent_=nullptr, int w=1, int h=1)
: TXWindow(dpy_, w, h, parent_), cb(cb_), down(false),
disabled_(false)
{
setEventHandler(this);
setText(text_);
- gc = XCreateGC(dpy, win(), 0, 0);
+ gc = XCreateGC(dpy, win(), 0, nullptr);
XSetFont(dpy, gc, defaultFont);
addEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask);
}
@@ -91,7 +92,7 @@ private:
XDrawString(dpy, win(), gc, startx, starty, text.data(), text.size());
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXCheckbox.h b/unix/tx/TXCheckbox.h
index 76cdc950..179e3e84 100644
--- a/unix/tx/TXCheckbox.h
+++ b/unix/tx/TXCheckbox.h
@@ -48,14 +48,15 @@ public:
class TXCheckbox : public TXWindow, public TXEventHandler {
public:
TXCheckbox(Display* dpy_, const char* text_, TXCheckboxCallback* cb_,
- bool radio_=false, TXWindow* parent_=0, int w=1, int h=1)
- : TXWindow(dpy_, w, h, parent_), cb(cb_), text(0),
+ bool radio_=false, TXWindow* parent_=nullptr,
+ int w=1, int h=1)
+ : TXWindow(dpy_, w, h, parent_), cb(cb_), text(nullptr),
boxSize(radio_ ? 12 : 13), boxPad(4),
checked_(false), disabled_(false), radio(radio_)
{
setEventHandler(this);
setText(text_);
- gc = XCreateGC(dpy, win(), 0, 0);
+ gc = XCreateGC(dpy, win(), 0, nullptr);
XSetFont(dpy, gc, defaultFont);
addEventMask(ExposureMask| ButtonPressMask | ButtonReleaseMask);
}
@@ -109,7 +110,7 @@ private:
text, strlen(text));
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXDialog.h b/unix/tx/TXDialog.h
index 861a20be..720c50d0 100644
--- a/unix/tx/TXDialog.h
+++ b/unix/tx/TXDialog.h
@@ -33,9 +33,9 @@
class TXDialog : public TXWindow, public TXDeleteWindowCallback {
public:
- TXDialog(Display* dpy, int width, int height, const char* name,
+ TXDialog(Display* dpy_, int width, int height, const char* name,
bool modal_=false)
- : TXWindow(dpy, width, height), done(false), ok(false), modal(modal_)
+ : TXWindow(dpy_, width, height), done(false), ok(false), modal(modal_)
{
toplevel(name, this);
resize(width, height);
@@ -62,7 +62,7 @@ public:
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- int n = select(FD_SETSIZE, &rfds, 0, 0, 0);
+ int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
if (n < 0) throw rdr::SystemException("select",errno);
}
}
@@ -82,7 +82,7 @@ public:
}
protected:
- virtual void deleteWindow(TXWindow* /*w*/) {
+ void deleteWindow(TXWindow* /*w*/) override {
ok = false;
done = true;
unmap();
diff --git a/unix/tx/TXLabel.h b/unix/tx/TXLabel.h
index 24b8cbb3..1e0cc0e5 100644
--- a/unix/tx/TXLabel.h
+++ b/unix/tx/TXLabel.h
@@ -35,7 +35,7 @@ public:
enum HAlign { left, centre, right };
enum VAlign { top, middle, bottom };
- TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=0,
+ TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=nullptr,
int w=1, int h=1, HAlign ha=centre, VAlign va=middle)
: TXWindow(dpy_, w, h, parent_), lineSpacing(2), lines(0),
halign(ha), valign(va)
@@ -108,7 +108,7 @@ private:
} while (i < text.size());
}
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
switch (ev->type) {
case Expose:
paint();
diff --git a/unix/tx/TXWindow.cxx b/unix/tx/TXWindow.cxx
index ee097e45..343b9c28 100644
--- a/unix/tx/TXWindow.cxx
+++ b/unix/tx/TXWindow.cxx
@@ -44,15 +44,15 @@ unsigned long TXWindow::disabledFg, TXWindow::disabledBg;
unsigned long TXWindow::enabledBg;
unsigned long TXWindow::scrollbarBg;
Colormap TXWindow::cmap = 0;
-GC TXWindow::defaultGC = 0;
+GC TXWindow::defaultGC = nullptr;
Font TXWindow::defaultFont = 0;
-XFontStruct* TXWindow::defaultFS = 0;
+XFontStruct* TXWindow::defaultFS = nullptr;
Time TXWindow::cutBufferTime = 0;
Pixmap TXWindow::dot = 0, TXWindow::tick = 0;
const int TXWindow::dotSize = 4, TXWindow::tickSize = 8;
char* TXWindow::defaultWindowClass;
-TXGlobalEventHandler* TXWindow::globalEventHandler = NULL;
+TXGlobalEventHandler* TXWindow::globalEventHandler = nullptr;
void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
{
@@ -79,7 +79,7 @@ void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
darkBg = disabledFg = cols[3].pixel;
scrollbarBg = cols[4].pixel;
white = enabledBg = cols[5].pixel;
- defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, 0);
+ defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, nullptr);
defaultFS
= XLoadQueryFont(dpy, "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
if (!defaultFS) {
@@ -258,7 +258,8 @@ Window TXWindow::windowWithName(Display* dpy, Window top, const char* name)
TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
int borderWidth)
: dpy(dpy_), xPad(3), yPad(3), bevel(2), parent(parent_), width_(w),
- height_(h), eventHandler(0), dwc(0), eventMask(0), toplevel_(false)
+ height_(h), eventHandler(nullptr), dwc(nullptr), eventMask(0),
+ toplevel_(false)
{
sizeHints.flags = 0;
XSetWindowAttributes attr;
@@ -266,7 +267,8 @@ TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
attr.border_pixel = 0;
Window par = parent ? parent->win() : DefaultRootWindow(dpy);
win_ = XCreateWindow(dpy, par, 0, 0, width_, height_, borderWidth,
- CopyFromParent, CopyFromParent, CopyFromParent,
+ CopyFromParent, CopyFromParent,
+ (Visual*)CopyFromParent,
CWBackPixel | CWBorderPixel, &attr);
if (parent) map();
@@ -292,7 +294,7 @@ void TXWindow::toplevel(const char* name, TXDeleteWindowCallback* dwc_,
if (!windowClass) windowClass = defaultWindowClass;
classHint.res_name = (char*)name;
classHint.res_class = (char*)windowClass;
- XSetWMProperties(dpy, win(), 0, 0, argv, argc,
+ XSetWMProperties(dpy, win(), nullptr, nullptr, argv, argc,
&sizeHints, &wmHints, &classHint);
XStoreName(dpy, win(), name);
XSetIconName(dpy, win(), name);
@@ -443,7 +445,7 @@ void TXWindow::handleXEvent(XEvent* ev)
break;
}
}
- selectionNotify(&ev->xselection, 0, 0, 0, 0);
+ selectionNotify(&ev->xselection, 0, 0, 0, nullptr);
break;
case SelectionRequest:
diff --git a/unix/tx/TXWindow.h b/unix/tx/TXWindow.h
index 223c07a8..9f2a30cb 100644
--- a/unix/tx/TXWindow.h
+++ b/unix/tx/TXWindow.h
@@ -65,7 +65,8 @@ public:
// background (currently grey). It is mapped by default if it has a parent.
// If no parent is specified its parent is the root window and it will remain
// unmapped.
- TXWindow(Display* dpy_, int width=1, int height=1, TXWindow* parent_=0,
+ TXWindow(Display* dpy_, int width=1, int height=1,
+ TXWindow* parent_=nullptr,
int borderWidth=0);
virtual ~TXWindow();
@@ -73,8 +74,9 @@ public:
// window-manager-related properties are set on the window. The given
// TXDeleteWindowCallback is notified when the window is "deleted" (cloesd)
// by the user.
- void toplevel(const char* name, TXDeleteWindowCallback* dwc=0,
- int argc=0, char** argv=0, const char* windowClass=0,
+ void toplevel(const char* name, TXDeleteWindowCallback* dwc=nullptr,
+ int argc=0, char** argv=nullptr,
+ const char* windowClass=nullptr,
bool iconic=false);
// setMaxSize() tells the window manager the maximum size to allow a
@@ -181,7 +183,7 @@ public:
// strEmptyToNull() returns the string it's given but turns an empty string
// into null, which can be useful for passing rfb parameters to Xlib calls.
- static char* strEmptyToNull(char* s) { return s && s[0] ? s : 0; }
+ static char* strEmptyToNull(char* s) { return s && s[0] ? s : nullptr; }
// The following are default values for various things.
static unsigned long black, white;
diff --git a/unix/vncconfig/QueryConnectDialog.cxx b/unix/vncconfig/QueryConnectDialog.cxx
index e725de7d..aa1b78ad 100644
--- a/unix/vncconfig/QueryConnectDialog.cxx
+++ b/unix/vncconfig/QueryConnectDialog.cxx
@@ -25,12 +25,12 @@
#include "QueryConnectDialog.h"
#include "vncExt.h"
-QueryConnectDialog::QueryConnectDialog(Display* dpy,
+QueryConnectDialog::QueryConnectDialog(Display* dpy_,
const char* address_,
const char* user_,
int timeout_,
QueryResultCallback* cb)
- : TXDialog(dpy, 300, 100, "VNC Server : Accept Connection?"),
+ : TXDialog(dpy_, 300, 100, "VNC Server : Accept Connection?"),
addressLbl(dpy, "Host:",this),
address(dpy, address_, this),
userLbl(dpy, "User:", this),
diff --git a/unix/vncconfig/QueryConnectDialog.h b/unix/vncconfig/QueryConnectDialog.h
index dcf64e40..5763e1ce 100644
--- a/unix/vncconfig/QueryConnectDialog.h
+++ b/unix/vncconfig/QueryConnectDialog.h
@@ -40,10 +40,10 @@ class QueryConnectDialog : public TXDialog, public TXEventHandler,
QueryConnectDialog(Display* dpy, const char* address_,
const char* user_, int timeout_,
QueryResultCallback* cb);
- void handleEvent(TXWindow*, XEvent* ) { }
- void deleteWindow(TXWindow*);
- void buttonActivate(TXButton* b);
- void handleTimeout(rfb::Timer* t);
+ void handleEvent(TXWindow*, XEvent* ) override { }
+ void deleteWindow(TXWindow*) override;
+ void buttonActivate(TXButton* b) override;
+ void handleTimeout(rfb::Timer* t) override;
private:
void refreshTimeout();
TXLabel addressLbl, address, userLbl, user, timeoutLbl, timeout;
diff --git a/unix/vncconfig/vncconfig.cxx b/unix/vncconfig/vncconfig.cxx
index 30d04ca6..ab7c6315 100644
--- a/unix/vncconfig/vncconfig.cxx
+++ b/unix/vncconfig/vncconfig.cxx
@@ -62,14 +62,14 @@ BoolParameter iconic("iconic", "Start with window iconified", 0);
#define SET_PRIMARY "SetPrimary"
#define SEND_PRIMARY "SendPrimary"
-char* programName = 0;
+char* programName = nullptr;
Display* dpy;
int vncExtEventBase, vncExtErrorBase;
-static bool getBoolParam(Display* dpy, const char* param) {
+static bool getBoolParam(Display* dpy_, const char* param) {
char* data;
int len;
- if (XVncExtGetParam(dpy, param, &data, &len)) {
+ if (XVncExtGetParam(dpy_, param, &data, &len)) {
if (strcmp(data,"1") == 0) return true;
}
return false;
@@ -80,13 +80,13 @@ class VncConfigWindow : public TXWindow, public TXEventHandler,
public TXCheckboxCallback,
public QueryResultCallback {
public:
- VncConfigWindow(Display* dpy)
- : TXWindow(dpy, 300, 100),
- acceptClipboard(dpy, "Accept clipboard from viewers", this, false, this),
- setPrimaryCB(dpy, "Also set primary selection", this, false, this),
- sendClipboard(dpy, "Send clipboard to viewers", this, false, this),
- sendPrimaryCB(dpy, "Send primary selection to viewers", this,false,this),
- queryConnectDialog(0)
+ VncConfigWindow(Display* dpy_)
+ : TXWindow(dpy_, 300, 100),
+ acceptClipboard(dpy_, "Accept clipboard from viewers", this, false, this),
+ setPrimaryCB(dpy_, "Also set primary selection", this, false, this),
+ sendClipboard(dpy_, "Send clipboard to viewers", this, false, this),
+ sendPrimaryCB(dpy_, "Send primary selection to viewers", this,false,this),
+ queryConnectDialog(nullptr)
{
int y = yPad;
acceptClipboard.move(xPad, y);
@@ -104,18 +104,18 @@ public:
sendPrimaryCB.disabled(!sendClipboard.checked());
y += sendPrimaryCB.height();
setEventHandler(this);
- toplevel("VNC config", this, 0, 0, 0, iconic);
+ toplevel("VNC config", this, 0, nullptr, nullptr, iconic);
XVncExtSelectInput(dpy, win(), VncExtQueryConnectMask);
}
// handleEvent()
- virtual void handleEvent(TXWindow* /*w*/, XEvent* ev) {
+ void handleEvent(TXWindow* /*w*/, XEvent* ev) override {
if (ev->type == vncExtEventBase + VncExtQueryConnectNotify) {
vlog.debug("query connection event");
if (queryConnectDialog)
delete queryConnectDialog;
- queryConnectDialog = 0;
+ queryConnectDialog = nullptr;
char* qcAddress;
char* qcUser;
int qcTimeout;
@@ -134,12 +134,12 @@ public:
}
// TXDeleteWindowCallback method
- virtual void deleteWindow(TXWindow* /*w*/) {
+ void deleteWindow(TXWindow* /*w*/) override {
exit(1);
}
// TXCheckboxCallback method
- virtual void checkboxSelect(TXCheckbox* checkbox) {
+ void checkboxSelect(TXCheckbox* checkbox) override {
if (checkbox == &acceptClipboard) {
XVncExtSetParam(dpy, (acceptClipboard.checked()
? ACCEPT_CUT_TEXT "=1" : ACCEPT_CUT_TEXT "=0"));
@@ -158,10 +158,10 @@ public:
}
// QueryResultCallback interface
- virtual void queryApproved() {
+ void queryApproved() override {
XVncExtApproveConnect(dpy, queryConnectId, 1);
}
- virtual void queryRejected() {
+ void queryRejected() override {
XVncExtApproveConnect(dpy, queryConnectId, 0);
}
@@ -278,8 +278,8 @@ int main(int argc, char** argv)
} else if (strcmp(argv[i], "-list") == 0) {
int nParams;
char** list = XVncExtListParams(dpy, &nParams);
- for (int i = 0; i < nParams; i++) {
- printf("%s\n",list[i]);
+ for (int n = 0; n < nParams; n++) {
+ printf("%s\n",list[n]);
}
XVncExtFreeParamList(list);
} else if (strcmp(argv[i], "-set") == 0) {
@@ -306,7 +306,7 @@ int main(int argc, char** argv)
while (true) {
struct timeval tv;
- struct timeval* tvp = 0;
+ struct timeval* tvp = nullptr;
// Process any incoming X events
TXWindow::handleXEvents(dpy);
@@ -329,7 +329,7 @@ int main(int argc, char** argv)
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- int n = select(FD_SETSIZE, &rfds, 0, 0, tvp);
+ int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, tvp);
if (n < 0) throw rdr::SystemException("select",errno);
}
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 30091a3d..877ebcbd 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -72,7 +72,7 @@ static const char* getpassword(const char* prompt) {
result[strlen(result)-1] = 0;
return buf;
}
- return 0;
+ return nullptr;
}
// Reads passwords from stdin and prints encrypted passwords to stdout.
@@ -81,7 +81,7 @@ static int encrypt_pipe() {
// We support a maximum of two passwords right now
for (i = 0;i < 2;i++) {
- const char *result = getpassword(NULL);
+ const char *result = getpassword(nullptr);
if (!result)
break;
@@ -102,7 +102,7 @@ static int encrypt_pipe() {
static std::vector<uint8_t> readpassword() {
while (true) {
const char *passwd = getpassword("Password:");
- if (passwd == NULL) {
+ if (passwd == nullptr) {
perror("getpassword error");
exit(1);
}
@@ -117,7 +117,7 @@ static std::vector<uint8_t> readpassword() {
}
passwd = getpassword("Verify:");
- if (passwd == NULL) {
+ if (passwd == nullptr) {
perror("getpass error");
exit(1);
}
@@ -158,7 +158,7 @@ int main(int argc, char** argv)
if (fname[0] == '\0') {
const char *configDir = os::getvncconfigdir();
- if (configDir == NULL) {
+ if (configDir == nullptr) {
fprintf(stderr, "Can't obtain VNC config directory\n");
exit(1);
}
@@ -175,7 +175,7 @@ int main(int argc, char** argv)
fprintf(stderr, "Would you like to enter a view-only password (y/n)? ");
char yesno[3];
- if (fgets(yesno, 3, stdin) != NULL && (yesno[0] == 'y' || yesno[0] == 'Y')) {
+ if (fgets(yesno, 3, stdin) != nullptr && (yesno[0] == 'y' || yesno[0] == 'Y')) {
obfuscatedReadOnly = readpassword();
} else {
fprintf(stderr, "A view-only password is not used\n");
diff --git a/unix/x0vncserver/Geometry.cxx b/unix/x0vncserver/Geometry.cxx
index 3f7f2863..28e71be4 100644
--- a/unix/x0vncserver/Geometry.cxx
+++ b/unix/x0vncserver/Geometry.cxx
@@ -71,7 +71,7 @@ Rect Geometry::parseString(const char *arg) const
{
Rect result; // empty by default
- if (arg != NULL && strlen(arg) > 0) {
+ if (arg != nullptr && strlen(arg) > 0) {
int w, h;
int x = 0, y = 0;
char sign_x[2] = "+";
diff --git a/unix/x0vncserver/Image.cxx b/unix/x0vncserver/Image.cxx
index 755da787..c2026134 100644
--- a/unix/x0vncserver/Image.cxx
+++ b/unix/x0vncserver/Image.cxx
@@ -63,13 +63,13 @@ ImageCleanup imageCleanup;
static rfb::LogWriter vlog("Image");
Image::Image(Display *d)
- : xim(NULL), dpy(d)
+ : xim(nullptr), dpy(d)
{
imageCleanup.images.push_back(this);
}
Image::Image(Display *d, int width, int height)
- : xim(NULL), dpy(d)
+ : xim(nullptr), dpy(d)
{
imageCleanup.images.push_back(this);
Init(width, height);
@@ -85,10 +85,11 @@ void Image::Init(int width, int height)
}
xim = XCreateImage(dpy, vis, DefaultDepth(dpy, DefaultScreen(dpy)),
- ZPixmap, 0, 0, width, height, BitmapPad(dpy), 0);
+ ZPixmap, 0, nullptr, width, height,
+ BitmapPad(dpy), 0);
xim->data = (char *)malloc(xim->bytes_per_line * xim->height);
- if (xim->data == NULL) {
+ if (xim->data == nullptr) {
vlog.error("malloc() failed");
exit(1);
}
@@ -99,7 +100,7 @@ Image::~Image()
imageCleanup.images.remove(this);
// XDestroyImage will free xim->data if necessary
- if (xim != NULL)
+ if (xim != nullptr)
XDestroyImage(xim);
}
@@ -217,12 +218,12 @@ static int ShmCreationXErrorHandler(Display* /*dpy*/,
}
ShmImage::ShmImage(Display *d)
- : Image(d), shminfo(NULL)
+ : Image(d), shminfo(nullptr)
{
}
ShmImage::ShmImage(Display *d, int width, int height)
- : Image(d), shminfo(NULL)
+ : Image(d), shminfo(nullptr)
{
Init(width, height);
}
@@ -241,7 +242,7 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
Visual *visual;
int depth;
- if (vinfo == NULL) {
+ if (vinfo == nullptr) {
visual = DefaultVisual(dpy, DefaultScreen(dpy));
depth = DefaultDepth(dpy, DefaultScreen(dpy));
} else {
@@ -256,12 +257,12 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
shminfo = new XShmSegmentInfo;
- xim = XShmCreateImage(dpy, visual, depth, ZPixmap, 0, shminfo,
+ xim = XShmCreateImage(dpy, visual, depth, ZPixmap, nullptr, shminfo,
width, height);
- if (xim == NULL) {
+ if (xim == nullptr) {
vlog.error("XShmCreateImage() failed");
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
@@ -273,22 +274,22 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
vlog.error("shmget() failed (%d bytes requested)",
int(xim->bytes_per_line * xim->height));
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
- shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, 0, 0);
+ shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, nullptr, 0);
if (shminfo->shmaddr == (char *)-1) {
perror("shmat");
vlog.error("shmat() failed (%d bytes requested)",
int(xim->bytes_per_line * xim->height));
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
@@ -301,21 +302,21 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
if (caughtShmError) {
vlog.error("XShmAttach() failed");
shmdt(shminfo->shmaddr);
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
XDestroyImage(xim);
- xim = NULL;
+ xim = nullptr;
delete shminfo;
- shminfo = NULL;
+ shminfo = nullptr;
return;
}
}
ShmImage::~ShmImage()
{
- if (shminfo != NULL) {
+ if (shminfo != nullptr) {
XShmDetach(dpy, shminfo);
shmdt(shminfo->shmaddr);
- shmctl(shminfo->shmid, IPC_RMID, 0);
+ shmctl(shminfo->shmid, IPC_RMID, nullptr);
delete shminfo;
}
}
@@ -354,13 +355,13 @@ ImageFactory::~ImageFactory()
Image *ImageFactory::newImage(Display *d, int width, int height)
{
- Image *image = NULL;
+ Image *image = nullptr;
// Now, try to use shared memory image.
if (mayUseShm) {
image = new ShmImage(d, width, height);
- if (image->xim != NULL) {
+ if (image->xim != nullptr) {
return image;
}
diff --git a/unix/x0vncserver/Image.h b/unix/x0vncserver/Image.h
index bf62e7d0..a89a26ad 100644
--- a/unix/x0vncserver/Image.h
+++ b/unix/x0vncserver/Image.h
@@ -98,20 +98,20 @@ public:
ShmImage(Display *d, int width, int height);
virtual ~ShmImage();
- virtual const char *className() const {
+ const char *className() const override {
return "ShmImage";
}
- virtual const char *classDesc() const {
+ const char *classDesc() const override {
return "shared memory image";
}
- virtual void get(Window wnd, int x = 0, int y = 0);
- virtual void get(Window wnd, int x, int y, int w, int h,
- int dst_x = 0, int dst_y = 0);
+ void get(Window wnd, int x = 0, int y = 0) override;
+ void get(Window wnd, int x, int y, int w, int h,
+ int dst_x = 0, int dst_y = 0) override;
protected:
- void Init(int width, int height, const XVisualInfo *vinfo = NULL);
+ void Init(int width, int height, const XVisualInfo *vinfo = nullptr);
XShmSegmentInfo *shminfo;
diff --git a/unix/x0vncserver/XDesktop.cxx b/unix/x0vncserver/XDesktop.cxx
index 55ea9667..4286c541 100644
--- a/unix/x0vncserver/XDesktop.cxx
+++ b/unix/x0vncserver/XDesktop.cxx
@@ -26,6 +26,8 @@
#include <signal.h>
#include <unistd.h>
+#include <algorithm>
+
#include <network/Socket.h>
#include <rfb/LogWriter.h>
@@ -80,11 +82,11 @@ static const char * ledNames[XDESKTOP_N_LEDS] = {
};
XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
- : dpy(dpy_), geometry(geometry_), pb(0), server(0),
- queryConnectDialog(0), queryConnectSock(0),
+ : dpy(dpy_), geometry(geometry_), pb(nullptr), server(nullptr),
+ queryConnectDialog(nullptr), queryConnectSock(nullptr),
oldButtonMask(0), haveXtest(false), haveDamage(false),
maxButtons(0), running(false), ledMasks(), ledState(0),
- codeMap(0), codeMapLen(0)
+ codeMap(nullptr), codeMapLen(0)
{
int major, minor;
@@ -108,7 +110,7 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
Bool on;
a = XInternAtom(dpy, ledNames[i], True);
- if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, NULL, NULL))
+ if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, nullptr, nullptr))
continue;
ledMasks[i] = 1u << shift;
@@ -283,7 +285,7 @@ void XDesktop::stop() {
#ifdef HAVE_XTEST
// Delete added keycodes
- deleteAddedKeysyms(dpy);
+ deleteAddedKeysyms();
#endif
#ifdef HAVE_XDAMAGE
@@ -292,12 +294,12 @@ void XDesktop::stop() {
#endif
delete queryConnectDialog;
- queryConnectDialog = 0;
+ queryConnectDialog = nullptr;
- server->setPixelBuffer(0);
+ server->setPixelBuffer(nullptr);
delete pb;
- pb = 0;
+ pb = nullptr;
}
void XDesktop::terminate() {
@@ -316,15 +318,13 @@ void XDesktop::queryConnection(network::Socket* sock,
// Someone already querying?
if (queryConnectSock) {
std::list<network::Socket*> sockets;
- std::list<network::Socket*>::iterator i;
// Check if this socket is still valid
server->getSockets(&sockets);
- for (i = sockets.begin(); i != sockets.end(); i++) {
- if (*i == queryConnectSock) {
- server->approveConnection(sock, false, "Another connection is currently being queried.");
- return;
- }
+ if (std::find(sockets.begin(), sockets.end(),
+ queryConnectSock) != sockets.end()) {
+ server->approveConnection(sock, false, "Another connection is currently being queried.");
+ return;
}
}
@@ -368,7 +368,7 @@ void XDesktop::pointerEvent(const Point& pos, int buttonMask) {
}
#ifdef HAVE_XTEST
-KeyCode XDesktop::XkbKeysymToKeycode(Display* dpy, KeySym keysym) {
+KeyCode XDesktop::XkbKeysymToKeycode(KeySym keysym) {
XkbDescPtr xkb;
XkbStateRec state;
unsigned int mods;
@@ -401,12 +401,12 @@ KeyCode XDesktop::XkbKeysymToKeycode(Display* dpy, KeySym keysym) {
// Shift+Tab is usually ISO_Left_Tab, but RFB hides this fact. Do
// another attempt if we failed the initial lookup
if ((keycode == 0) && (keysym == XK_Tab) && (mods & ShiftMask))
- return XkbKeysymToKeycode(dpy, XK_ISO_Left_Tab);
+ return XkbKeysymToKeycode(XK_ISO_Left_Tab);
return keycode;
}
-KeyCode XDesktop::addKeysym(Display* dpy, KeySym keysym)
+KeyCode XDesktop::addKeysym(KeySym keysym)
{
int types[1];
unsigned int key;
@@ -460,7 +460,7 @@ KeyCode XDesktop::addKeysym(Display* dpy, KeySym keysym)
return 0;
}
-void XDesktop::deleteAddedKeysyms(Display* dpy) {
+void XDesktop::deleteAddedKeysyms() {
XkbDescPtr xkb;
xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
@@ -476,10 +476,10 @@ void XDesktop::deleteAddedKeysyms(Display* dpy) {
for (it = addedKeysyms.begin(); it != addedKeysyms.end(); it++) {
if (XkbKeyNumGroups(xkb, it->second) != 0) {
// Check if we are removing keysym we added ourself
- if (XkbKeysymToKeycode(dpy, it->first) != it->second)
+ if (XkbKeysymToKeycode(it->first) != it->second)
continue;
- XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, NULL, &changes);
+ XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, nullptr, &changes);
if (it->second < lowestKeyCode)
lowestKeyCode = it->second;
@@ -501,19 +501,19 @@ void XDesktop::deleteAddedKeysyms(Display* dpy) {
addedKeysyms.clear();
}
-KeyCode XDesktop::keysymToKeycode(Display* dpy, KeySym keysym) {
+KeyCode XDesktop::keysymToKeycode(KeySym keysym) {
int keycode = 0;
// XKeysymToKeycode() doesn't respect state, so we have to use
// something slightly more complex
- keycode = XkbKeysymToKeycode(dpy, keysym);
+ keycode = XkbKeysymToKeycode(keysym);
if (keycode != 0)
return keycode;
// TODO: try to further guess keycode with all possible mods as Xvnc does
- keycode = addKeysym(dpy, keysym);
+ keycode = addKeysym(keysym);
if (keycode == 0)
vlog.error("Failure adding new keysym 0x%lx", keysym);
@@ -538,7 +538,7 @@ void XDesktop::keyEvent(uint32_t keysym, uint32_t xtcode, bool down) {
if (pressedKeys.find(keysym) != pressedKeys.end())
keycode = pressedKeys[keysym];
else {
- keycode = keysymToKeycode(dpy, keysym);
+ keycode = keysymToKeycode(keysym);
}
}
@@ -931,7 +931,7 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
if (cev->window == cev->root)
return false;
- server->setCursor(0, 0, Point(), NULL);
+ server->setCursor(0, 0, Point(), nullptr);
return true;
#endif
}
@@ -942,8 +942,8 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
void XDesktop::queryApproved()
{
assert(isRunning());
- server->approveConnection(queryConnectSock, true, 0);
- queryConnectSock = 0;
+ server->approveConnection(queryConnectSock, true, nullptr);
+ queryConnectSock = nullptr;
}
void XDesktop::queryRejected()
@@ -951,7 +951,7 @@ void XDesktop::queryRejected()
assert(isRunning());
server->approveConnection(queryConnectSock, false,
"Connection rejected by local user");
- queryConnectSock = 0;
+ queryConnectSock = nullptr;
}
#ifdef HAVE_XFIXES
@@ -960,7 +960,7 @@ bool XDesktop::setCursor()
XFixesCursorImage *cim;
cim = XFixesGetCursorImage(dpy);
- if (cim == NULL)
+ if (cim == nullptr)
return false;
// Copied from XserverDesktop::setCursor() in
diff --git a/unix/x0vncserver/XDesktop.h b/unix/x0vncserver/XDesktop.h
index fc230e5b..125ddeb0 100644
--- a/unix/x0vncserver/XDesktop.h
+++ b/unix/x0vncserver/XDesktop.h
@@ -47,25 +47,25 @@ public:
virtual ~XDesktop();
void poll();
// -=- SDesktop interface
- virtual void init(rfb::VNCServer* vs);
- virtual void start();
- virtual void stop();
- virtual void terminate();
+ void init(rfb::VNCServer* vs) override;
+ void start() override;
+ void stop() override;
+ void terminate() override;
bool isRunning();
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
- virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
- virtual void keyEvent(uint32_t keysym, uint32_t xtcode, bool down);
- virtual void clientCutText(const char* str);
- virtual unsigned int setScreenLayout(int fb_width, int fb_height,
- const rfb::ScreenSet& layout);
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
+ void pointerEvent(const rfb::Point& pos, int buttonMask) override;
+ void keyEvent(uint32_t keysym, uint32_t xtcode, bool down) override;
+ void clientCutText(const char* str) override;
+ unsigned int setScreenLayout(int fb_width, int fb_height,
+ const rfb::ScreenSet& layout) override;
// -=- TXGlobalEventHandler interface
- virtual bool handleGlobalEvent(XEvent* ev);
+ bool handleGlobalEvent(XEvent* ev) override;
// -=- QueryResultCallback interface
- virtual void queryApproved();
- virtual void queryRejected();
+ void queryApproved() override;
+ void queryRejected() override;
protected:
Display* dpy;
@@ -101,10 +101,10 @@ protected:
protected:
#ifdef HAVE_XTEST
- KeyCode XkbKeysymToKeycode(Display* dpy, KeySym keysym);
- KeyCode addKeysym(Display* dpy, KeySym keysym);
- void deleteAddedKeysyms(Display* dpy);
- KeyCode keysymToKeycode(Display* dpy, KeySym keysym);
+ KeyCode XkbKeysymToKeycode(KeySym keysym);
+ KeyCode addKeysym(KeySym keysym);
+ void deleteAddedKeysyms();
+ KeyCode keysymToKeycode(KeySym keysym);
#endif
#ifdef HAVE_XFIXES
bool setCursor();
diff --git a/unix/x0vncserver/XPixelBuffer.cxx b/unix/x0vncserver/XPixelBuffer.cxx
index b7506513..0e24cc51 100644
--- a/unix/x0vncserver/XPixelBuffer.cxx
+++ b/unix/x0vncserver/XPixelBuffer.cxx
@@ -35,7 +35,7 @@ using namespace rfb;
XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
const Rect &rect)
: FullFramePixelBuffer(),
- m_poller(0),
+ m_poller(nullptr),
m_dpy(dpy),
m_image(factory.newImage(dpy, rect.width(), rect.height())),
m_offsetLeft(rect.tl.x),
diff --git a/unix/x0vncserver/XPixelBuffer.h b/unix/x0vncserver/XPixelBuffer.h
index 18c85fe2..7556e6ef 100644
--- a/unix/x0vncserver/XPixelBuffer.h
+++ b/unix/x0vncserver/XPixelBuffer.h
@@ -45,7 +45,7 @@ public:
inline void poll(rfb::VNCServer *server) { m_poller->poll(server); }
// Override PixelBuffer::grabRegion().
- virtual void grabRegion(const rfb::Region& region);
+ void grabRegion(const rfb::Region& region) override;
protected:
PollingManager *m_poller;
diff --git a/unix/x0vncserver/x0vncserver.cxx b/unix/x0vncserver/x0vncserver.cxx
index ffaf5788..49c95137 100644
--- a/unix/x0vncserver/x0vncserver.cxx
+++ b/unix/x0vncserver/x0vncserver.cxx
@@ -90,10 +90,10 @@ static const char* defaultDesktopName()
return "";
struct passwd* pwent = getpwuid(getuid());
- if (pwent == NULL)
+ if (pwent == nullptr)
return "";
- int len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+ int len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
if (len < 0)
return "";
@@ -154,19 +154,19 @@ class FileTcpFilter : public TcpFilter
public:
FileTcpFilter(const char *fname)
- : TcpFilter("-"), fileName(NULL), lastModTime(0)
+ : TcpFilter("-"), fileName(nullptr), lastModTime(0)
{
- if (fname != NULL)
+ if (fname != nullptr)
fileName = strdup((char *)fname);
}
virtual ~FileTcpFilter()
{
- if (fileName != NULL)
+ if (fileName != nullptr)
free(fileName);
}
- virtual bool verifyConnection(Socket* s)
+ bool verifyConnection(Socket* s) override
{
if (!reloadRules()) {
vlog.error("Could not read IP filtering rules: rejecting all clients");
@@ -182,7 +182,7 @@ protected:
bool reloadRules()
{
- if (fileName == NULL)
+ if (fileName == nullptr)
return true;
struct stat st;
@@ -192,7 +192,7 @@ protected:
if (st.st_mtime != lastModTime) {
// Actually reload only if the file was modified
FILE *fp = fopen(fileName, "r");
- if (fp == NULL)
+ if (fp == nullptr)
return false;
// Remove all the rules from the parent class
@@ -225,14 +225,14 @@ private:
bool readLine(char *buf, int bufSize, FILE *fp)
{
- if (fp == NULL || buf == NULL || bufSize == 0)
+ if (fp == nullptr || buf == nullptr || bufSize == 0)
return false;
- if (fgets(buf, bufSize, fp) == NULL)
+ if (fgets(buf, bufSize, fp) == nullptr)
return false;
char *ptr = strchr(buf, '\n');
- if (ptr != NULL) {
+ if (ptr != nullptr) {
*ptr = '\0'; // remove newline at the end
} else {
if (!feof(fp)) {
@@ -353,7 +353,7 @@ int main(int argc, char** argv)
const char *addr = interface;
if (strcasecmp(addr, "all") == 0)
- addr = 0;
+ addr = nullptr;
if (localhostOnly)
createLocalTcpListeners(&tcp_listeners, (int)rfbport);
else
@@ -368,10 +368,8 @@ int main(int argc, char** argv)
FileTcpFilter fileTcpFilter(hostsFile);
if (strlen(hostsFile) != 0)
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- (*i)->setFilter(&fileTcpFilter);
+ for (SocketListener* listener : listeners)
+ listener->setFilter(&fileTcpFilter);
}
if (listeners.empty()) {
@@ -395,10 +393,8 @@ int main(int argc, char** argv)
FD_ZERO(&wfds);
FD_SET(ConnectionNumber(dpy), &rfds);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++)
- FD_SET((*i)->getFd(), &rfds);
+ for (SocketListener* listener : listeners)
+ FD_SET(listener->getFd(), &rfds);
server.getSockets(&sockets);
int clients_connected = 0;
@@ -436,8 +432,8 @@ int main(int argc, char** argv)
// Do the wait...
sched.sleepStarted();
- int n = select(FD_SETSIZE, &rfds, &wfds, 0,
- wait_ms ? &tv : NULL);
+ int n = select(FD_SETSIZE, &rfds, &wfds, nullptr,
+ wait_ms ? &tv : nullptr);
sched.sleepFinished();
if (n < 0) {
@@ -450,11 +446,9 @@ int main(int argc, char** argv)
}
// Accept new VNC connections
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- if (FD_ISSET((*i)->getFd(), &rfds)) {
- Socket* sock = (*i)->accept();
+ for (SocketListener* listener : listeners) {
+ if (FD_ISSET(listener->getFd(), &rfds)) {
+ Socket* sock = listener->accept();
if (sock) {
server.addSocket(sock);
} else {
@@ -494,11 +488,8 @@ int main(int argc, char** argv)
TXWindow::handleXEvents(dpy);
// Run listener destructors; remove UNIX sockets etc
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- delete *i;
- }
+ for (SocketListener* listener : listeners)
+ delete listener;
vlog.info("Terminated");
return 0;
diff --git a/unix/xserver/hw/vnc/Makefile.am b/unix/xserver/hw/vnc/Makefile.am
index f9372183..d344c85d 100644
--- a/unix/xserver/hw/vnc/Makefile.am
+++ b/unix/xserver/hw/vnc/Makefile.am
@@ -14,6 +14,8 @@ AM_CPPFLAGS = \
-I$(TIGERVNC_SRCDIR)/unix/common \
$(DIX_CFLAGS)
+AM_CXXFLAGS = -std=gnu++11
+
noinst_LTLIBRARIES = libvnccommon.la
HDRS = vncExtInit.h vncHooks.h \
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index 25431b65..2cbee35c 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -51,7 +51,7 @@ void vncLogError(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->verror(format, ap);
@@ -63,7 +63,7 @@ void vncLogStatus(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vstatus(format, ap);
@@ -75,7 +75,7 @@ void vncLogInfo(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vinfo(format, ap);
@@ -87,7 +87,7 @@ void vncLogDebug(const char *name, const char *format, ...)
LogWriter *vlog;
va_list ap;
vlog = LogWriter::getLogWriter(name);
- if (vlog == NULL)
+ if (vlog == nullptr)
return;
va_start(ap, format);
vlog->vdebug(format, ap);
@@ -96,12 +96,12 @@ void vncLogDebug(const char *name, const char *format, ...)
int vncSetParam(const char *name, const char *value)
{
- if (value != NULL)
+ if (value != nullptr)
return rfb::Configuration::setParam(name, value);
else {
VoidParameter *param;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
+ if (param == nullptr)
return false;
return param->setParam();
}
@@ -118,11 +118,11 @@ char* vncGetParam(const char *name)
// Hack to avoid exposing password!
if (strcasecmp(name, "Password") == 0)
- return NULL;
+ return nullptr;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
- return NULL;
+ if (param == nullptr)
+ return nullptr;
return strdup(param->getValueStr().c_str());
}
@@ -132,8 +132,8 @@ const char* vncGetParamDesc(const char *name)
rfb::VoidParameter *param;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
- return NULL;
+ if (param == nullptr)
+ return nullptr;
return param->getDescription();
}
@@ -144,11 +144,11 @@ int vncIsParamBool(const char *name)
BoolParameter *bparam;
param = rfb::Configuration::getParam(name);
- if (param == NULL)
+ if (param == nullptr)
return false;
bparam = dynamic_cast<BoolParameter*>(param);
- if (bparam == NULL)
+ if (bparam == nullptr)
return false;
return true;
@@ -179,8 +179,8 @@ char *vncGetParamList(void)
}
data = (char*)malloc(len + 1);
- if (data == NULL)
- return NULL;
+ if (data == nullptr)
+ return nullptr;
ptr = data;
for (ParameterIterator i; i.param; i.next()) {
@@ -227,7 +227,7 @@ char* vncConvertLF(const char* src, size_t bytes)
try {
return strdup(convertLF(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
@@ -236,7 +236,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes)
try {
return strdup(latin1ToUTF8(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
@@ -245,7 +245,7 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes)
try {
return strdup(utf8ToLatin1(src, bytes).c_str());
} catch (...) {
- return NULL;
+ return nullptr;
}
}
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc
index d4ee16b8..0c2b5bf9 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.cc
+++ b/unix/xserver/hw/vnc/XserverDesktop.cc
@@ -80,7 +80,7 @@ XserverDesktop::XserverDesktop(int screenIndex_,
void* fbptr, int stride_)
: screenIndex(screenIndex_),
server(0), listeners(listeners_),
- shadowFramebuffer(NULL),
+ shadowFramebuffer(nullptr),
queryConnectId(0), queryConnectTimer(this)
{
format = pf;
@@ -88,11 +88,8 @@ XserverDesktop::XserverDesktop(int screenIndex_,
server = new VNCServerST(name, this);
setFramebuffer(width, height, fbptr, stride_);
- for (std::list<SocketListener*>::iterator i = listeners.begin();
- i != listeners.end();
- i++) {
- vncSetNotifyFd((*i)->getFd(), screenIndex, true, false);
- }
+ for (SocketListener* listener : listeners)
+ vncSetNotifyFd(listener->getFd(), screenIndex, true, false);
}
XserverDesktop::~XserverDesktop()
@@ -123,7 +120,7 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_)
if (shadowFramebuffer) {
delete [] shadowFramebuffer;
- shadowFramebuffer = NULL;
+ shadowFramebuffer = nullptr;
}
if (!fbptr) {
@@ -521,7 +518,7 @@ void XserverDesktop::handleClipboardData(const char* data_)
void XserverDesktop::grabRegion(const rfb::Region& region)
{
- if (shadowFramebuffer == NULL)
+ if (shadowFramebuffer == nullptr)
return;
std::vector<rfb::Rect> rects;
diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h
index e604295b..3b0f869f 100644
--- a/unix/xserver/hw/vnc/XserverDesktop.h
+++ b/unix/xserver/hw/vnc/XserverDesktop.h
@@ -91,21 +91,21 @@ public:
const char* rejectMsg=0);
// rfb::SDesktop callbacks
- virtual void init(rfb::VNCServer* vs);
- virtual void terminate();
- virtual void queryConnection(network::Socket* sock,
- const char* userName);
- virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
- virtual void keyEvent(uint32_t keysym, uint32_t keycode, bool down);
- virtual unsigned int setScreenLayout(int fb_width, int fb_height,
- const rfb::ScreenSet& layout);
- virtual void frameTick(uint64_t msc);
- virtual void handleClipboardRequest();
- virtual void handleClipboardAnnounce(bool available);
- virtual void handleClipboardData(const char* data);
+ void init(rfb::VNCServer* vs) override;
+ void terminate() override;
+ void queryConnection(network::Socket* sock,
+ const char* userName) override;
+ void pointerEvent(const rfb::Point& pos, int buttonMask) override;
+ void keyEvent(uint32_t keysym, uint32_t keycode, bool down) override;
+ unsigned int setScreenLayout(int fb_width, int fb_height,
+ const rfb::ScreenSet& layout) override;
+ void frameTick(uint64_t msc) override;
+ void handleClipboardRequest() override;
+ void handleClipboardAnnounce(bool available) override;
+ void handleClipboardData(const char* data) override;
// rfb::PixelBuffer callbacks
- virtual void grabRegion(const rfb::Region& r);
+ void grabRegion(const rfb::Region& r) override;
protected:
bool handleListenerEvent(int fd,
@@ -115,7 +115,7 @@ protected:
rfb::VNCServer* sockserv,
bool read, bool write);
- virtual void handleTimeout(rfb::Timer* t);
+ void handleTimeout(rfb::Timer* t) override;
private:
diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc
index 4003e768..073b07e2 100644
--- a/unix/xserver/hw/vnc/vncExtInit.cc
+++ b/unix/xserver/hw/vnc/vncExtInit.cc
@@ -114,10 +114,10 @@ static const char* defaultDesktopName()
return "";
struct passwd* pwent = getpwuid(getuid());
- if (pwent == NULL)
+ if (pwent == nullptr)
return "";
- size_t len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+ size_t len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
if (len < 0)
return "";
@@ -286,7 +286,7 @@ void vncExtensionClose(void)
try {
for (int scr = 0; scr < vncGetScreenCount(); scr++) {
delete desktop[scr];
- desktop[scr] = NULL;
+ desktop[scr] = nullptr;
}
} catch (rdr::Exception& e) {
vncFatalError("vncExtInit: %s\n",e.str());