summaryrefslogtreecommitdiffstats
path: root/tx
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2006-04-17 02:57:56 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2006-04-17 02:57:56 +0000
commit3cf9feaae7895f4ea11915b21c895496a0933ca5 (patch)
treef293e2e4530af7d94a23ffa84e4fcb282338bdbd /tx
parentbdf5651f1db8a40f744f378896dc33eb7f58fa50 (diff)
downloadtigervnc-3cf9feaae7895f4ea11915b21c895496a0933ca5.tar.gz
tigervnc-3cf9feaae7895f4ea11915b21c895496a0933ca5.zip
The "tx" library merged with VNC 4.1.1 code.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/merge-with-vnc-4.1.1@525 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'tx')
-rw-r--r--tx/Makefile.in3
-rw-r--r--tx/TXButton.h8
-rw-r--r--tx/TXCheckbox.h8
-rw-r--r--tx/TXDialog.h16
-rw-r--r--tx/TXEntry.h6
-rw-r--r--tx/TXImage.cxx8
-rw-r--r--tx/TXImage.h4
-rw-r--r--tx/TXLabel.h10
-rw-r--r--tx/TXMenu.cxx4
-rw-r--r--tx/TXMenu.h4
-rw-r--r--tx/TXMsgBox.h9
-rw-r--r--tx/TXScrollbar.cxx4
-rw-r--r--tx/TXScrollbar.h4
-rw-r--r--tx/TXViewport.cxx16
-rw-r--r--tx/TXViewport.h12
-rw-r--r--tx/TXWindow.cxx6
-rw-r--r--tx/TXWindow.h5
-rw-r--r--tx/Timer.cxx110
-rw-r--r--tx/Timer.h51
19 files changed, 66 insertions, 222 deletions
diff --git a/tx/Makefile.in b/tx/Makefile.in
index b953325a..89c30b17 100644
--- a/tx/Makefile.in
+++ b/tx/Makefile.in
@@ -1,6 +1,5 @@
-SRCS = TXWindow.cxx TXScrollbar.cxx TXViewport.cxx TXImage.cxx TXMenu.cxx \
- Timer.cxx
+SRCS = TXWindow.cxx TXScrollbar.cxx TXViewport.cxx TXImage.cxx TXMenu.cxx
OBJS = $(SRCS:.cxx=.o)
diff --git a/tx/TXButton.h b/tx/TXButton.h
index c22dbf94..b7472797 100644
--- a/tx/TXButton.h
+++ b/tx/TXButton.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -62,8 +62,8 @@ public:
text.buf = rfb::strDup(text_);
int textWidth = XTextWidth(defaultFS, text.buf, strlen(text.buf));
int textHeight = (defaultFS->ascent + defaultFS->descent);
- int newWidth = vncmax(width(), textWidth + xPad*2 + bevel*2);
- int newHeight = vncmax(height(), textHeight + yPad*2 + bevel*2);
+ int newWidth = __rfbmax(width(), textWidth + xPad*2 + bevel*2);
+ int newHeight = __rfbmax(height(), textHeight + yPad*2 + bevel*2);
if (width() < newWidth || height() < newHeight) {
resize(newWidth, newHeight);
}
diff --git a/tx/TXCheckbox.h b/tx/TXCheckbox.h
index 41eef27c..3c2a23b8 100644
--- a/tx/TXCheckbox.h
+++ b/tx/TXCheckbox.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -71,8 +71,8 @@ public:
text = strdup(text_);
int textWidth = XTextWidth(defaultFS, text, strlen(text));
int textHeight = (defaultFS->ascent + defaultFS->descent);
- int newWidth = vncmax(width(), textWidth + xPad*2 + boxPad*2 + boxSize);
- int newHeight = vncmax(height(), textHeight + yPad*2);
+ int newWidth = __rfbmax(width(), textWidth + xPad*2 + boxPad*2 + boxSize);
+ int newHeight = __rfbmax(height(), textHeight + yPad*2);
if (width() < newWidth || height() < newHeight) {
resize(newWidth, newHeight);
}
diff --git a/tx/TXDialog.h b/tx/TXDialog.h
index 01677a9e..0bfd88a8 100644
--- a/tx/TXDialog.h
+++ b/tx/TXDialog.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -38,9 +38,7 @@ public:
: TXWindow(dpy, width, height), done(false), ok(false), modal(modal_)
{
toplevel(name, this);
- int dpyWidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
- int dpyHeight = HeightOfScreen(DefaultScreenOfDisplay(dpy));
- setUSPosition((dpyWidth - width - 10) / 2, (dpyHeight - height - 30) / 2);
+ resize(width, height);
}
virtual ~TXDialog() {}
@@ -75,6 +73,14 @@ public:
// to make sure that checkboxes have the right state, etc.
virtual void initDialog() {}
+ // resize() is overidden here to re-center the dialog
+ void resize(int w, int h) {
+ TXWindow::resize(w,h);
+ int dpyWidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
+ int dpyHeight = HeightOfScreen(DefaultScreenOfDisplay(dpy));
+ setUSPosition((dpyWidth - width() - 10) / 2, (dpyHeight - height() - 30) / 2);
+ }
+
protected:
virtual void deleteWindow(TXWindow* w) {
ok = false;
diff --git a/tx/TXEntry.h b/tx/TXEntry.h
index 0d1f005f..90029579 100644
--- a/tx/TXEntry.h
+++ b/tx/TXEntry.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -58,7 +58,7 @@ public:
| ButtonPressMask);
text[0] = 0;
int textHeight = (defaultFS->ascent + defaultFS->descent);
- int newHeight = vncmax(height(), textHeight + yPad*2 + bevel*2);
+ int newHeight = __rfbmax(height(), textHeight + yPad*2 + bevel*2);
if (height() < newHeight) {
resize(width(), newHeight);
}
diff --git a/tx/TXImage.cxx b/tx/TXImage.cxx
index 7801578c..5fa68288 100644
--- a/tx/TXImage.cxx
+++ b/tx/TXImage.cxx
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -74,8 +74,8 @@ void TXImage::resize(int w, int h)
if (w == width() && h == height()) return;
int oldStrideBytes = getStride() * (format.bpp/8);
- int rowsToCopy = vncmin(h, height());
- int bytesPerRow = vncmin(w, width()) * (format.bpp/8);
+ int rowsToCopy = __rfbmin(h, height());
+ int bytesPerRow = __rfbmin(w, width()) * (format.bpp/8);
rdr::U8* oldData = 0;
bool allocData = false;
diff --git a/tx/TXImage.h b/tx/TXImage.h
index 8185366a..055bd22d 100644
--- a/tx/TXImage.h
+++ b/tx/TXImage.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
diff --git a/tx/TXLabel.h b/tx/TXLabel.h
index bbd893a5..3d5200d6 100644
--- a/tx/TXLabel.h
+++ b/tx/TXLabel.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -63,12 +63,12 @@ public:
} while (text.buf[i] != 0);
int textHeight = ((defaultFS->ascent + defaultFS->descent + lineSpacing)
* lines);
-
- int newWidth = vncmax(width(), textWidth + xPad*2);
- int newHeight = vncmax(height(), textHeight + yPad*2);
+ int newWidth = __rfbmax(width(), textWidth + xPad*2);
+ int newHeight = __rfbmax(height(), textHeight + yPad*2);
if (width() < newWidth || height() < newHeight) {
resize(newWidth, newHeight);
}
+ invalidate();
}
private:
diff --git a/tx/TXMenu.cxx b/tx/TXMenu.cxx
index 4069f2d2..92712f55 100644
--- a/tx/TXMenu.cxx
+++ b/tx/TXMenu.cxx
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
diff --git a/tx/TXMenu.h b/tx/TXMenu.h
index 82dafa56..d0245ee9 100644
--- a/tx/TXMenu.h
+++ b/tx/TXMenu.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
diff --git a/tx/TXMsgBox.h b/tx/TXMsgBox.h
index 00c4eb5f..ff84e6ae 100644
--- a/tx/TXMsgBox.h
+++ b/tx/TXMsgBox.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -49,7 +49,7 @@ enum TXMsgBoxFlags {
class TXMsgBox : public TXDialog, public TXButtonCallback {
public:
TXMsgBox(Display* dpy, const char* text, unsigned int flags, const char* title=0)
- : TXDialog(dpy, 1, 1, "Message"),
+ : TXDialog(dpy, 1, 1, "Message", true),
textLabel(dpy, "", this),
okButton(dpy, "OK", this, this, 60),
cancelButton(dpy, "Cancel", this, this, 60)
@@ -99,7 +99,8 @@ public:
}
virtual void buttonActivate(TXButton* b) {
- ok = (b == &okButton);
+ ok = (b == &okButton);
+ done = true;
unmap();
}
diff --git a/tx/TXScrollbar.cxx b/tx/TXScrollbar.cxx
index 946ccffc..47e124c3 100644
--- a/tx/TXScrollbar.cxx
+++ b/tx/TXScrollbar.cxx
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
diff --git a/tx/TXScrollbar.h b/tx/TXScrollbar.h
index 4cc2afa3..87fec3d8 100644
--- a/tx/TXScrollbar.h
+++ b/tx/TXScrollbar.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
diff --git a/tx/TXViewport.cxx b/tx/TXViewport.cxx
index 67982e9f..abe51734 100644
--- a/tx/TXViewport.cxx
+++ b/tx/TXViewport.cxx
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -100,21 +100,19 @@ bool TXViewport::bumpScrollEvent(XMotionEvent* ev)
else if (ev->y_root == 0) bumpScrollY = bumpScrollPixels;
if (bumpScrollX || bumpScrollY) {
- if (bumpScrollTimer.isSet()) return true;
+ if (bumpScrollTimer.isStarted()) return true;
if (setOffset(xOff + bumpScrollX, yOff + bumpScrollY)) {
- bumpScrollTimer.reset(25);
+ bumpScrollTimer.start(25);
return true;
}
}
- bumpScrollTimer.cancel();
+ bumpScrollTimer.stop();
return false;
}
-void TXViewport::timerCallback(Timer* timer)
-{
- if (setOffset(xOff + bumpScrollX, yOff + bumpScrollY))
- bumpScrollTimer.reset(25);
+bool TXViewport::handleTimeout(rfb::Timer* timer) {
+ return setOffset(xOff + bumpScrollX, yOff + bumpScrollY);
}
void TXViewport::resizeNotify()
diff --git a/tx/TXViewport.h b/tx/TXViewport.h
index 9dddc2f8..0c9857d2 100644
--- a/tx/TXViewport.h
+++ b/tx/TXViewport.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -28,12 +28,12 @@
#ifndef __TXVIEWPORT_H__
#define __TXVIEWPORT_H__
+#include <rfb/Timer.h>
#include "TXWindow.h"
#include "TXScrollbar.h"
-#include "Timer.h"
class TXViewport : public TXWindow, public TXScrollbarCallback,
- public TimerCallback {
+ public rfb::Timer::Callback {
public:
TXViewport(Display* dpy_, int width, int height, TXWindow* parent_=0);
virtual ~TXViewport();
@@ -62,14 +62,14 @@ public:
private:
virtual void resizeNotify();
virtual void scrollbarPos(int x, int y, TXScrollbar* sb);
- virtual void timerCallback(Timer* timer);
+ virtual bool handleTimeout(rfb::Timer* timer);
TXWindow* clipper;
TXWindow* child;
TXScrollbar* hScrollbar;
TXScrollbar* vScrollbar;
const int scrollbarSize;
int xOff, yOff;
- Timer bumpScrollTimer;
+ rfb::Timer bumpScrollTimer;
bool bumpScroll;
bool needScrollbars;
int bumpScrollX, bumpScrollY;
diff --git a/tx/TXWindow.cxx b/tx/TXWindow.cxx
index 1114685c..6d211beb 100644
--- a/tx/TXWindow.cxx
+++ b/tx/TXWindow.cxx
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -73,7 +73,7 @@ void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
white = enabledBg = cols[5].pixel;
defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, 0);
defaultFS
- = XLoadQueryFont(dpy, "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-*");
+ = XLoadQueryFont(dpy, "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
if (!defaultFS) {
defaultFS = XLoadQueryFont(dpy, "fixed");
if (!defaultFS) {
diff --git a/tx/TXWindow.h b/tx/TXWindow.h
index 20c31c95..5ada181b 100644
--- a/tx/TXWindow.h
+++ b/tx/TXWindow.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
- *
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ *
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -110,6 +110,7 @@ public:
void resize(int w, int h);
void raise() { XRaiseWindow(dpy, win()); }
void setBorderWidth(int bw);
+ void invalidate(int x=0, int y=0, int w=0, int h=0) { XClearArea(dpy, win(), x, y, w, h, True); }
// ownSelection requests that the window owns the given selection from the
// given time (the time should be taken from an X event).
diff --git a/tx/Timer.cxx b/tx/Timer.cxx
deleted file mode 100644
index 3acb631b..00000000
--- a/tx/Timer.cxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-//
-// Timer.cxx
-//
-
-// XXX Lynx/OS 2.3: get proto for gettimeofday()
-#ifdef Lynx
-#include <sys/proto.h>
-#endif
-
-#include "Timer.h"
-
-static Timer* timers;
-
-void Timer::callTimers()
-{
- struct timeval now;
- gettimeofday(&now, 0);
- while (timers) {
- Timer* timer = timers;
- if (timer->before(now)) {
- timers = timers->next;
- timer->cb->timerCallback(timer);
- } else {
- break;
- }
- }
-}
-
-bool Timer::getTimeout(struct timeval* timeout)
-{
- if (!timers) return false;
- Timer* timer = timers;
- struct timeval now;
- gettimeofday(&now, 0);
- if (timer->before(now)) {
- timeout->tv_sec = 0;
- timeout->tv_usec = 0;
- return true;
- }
- timeout->tv_sec = timer->tv.tv_sec - now.tv_sec;
- if (timer->tv.tv_usec < now.tv_usec) {
- timeout->tv_usec = timer->tv.tv_usec + 1000000 - now.tv_usec;
- timeout->tv_sec--;
- } else {
- timeout->tv_usec = timer->tv.tv_usec - now.tv_usec;
- }
- return true;
-}
-
-Timer::Timer(TimerCallback* cb_) : cb(cb_) {}
-Timer::~Timer()
-{
- cancel();
-}
-
-void Timer::reset(int ms) {
- cancel();
- gettimeofday(&tv, 0);
- tv.tv_sec += ms / 1000;
- tv.tv_usec += (ms % 1000) * 1000;
- if (tv.tv_usec > 1000000) {
- tv.tv_sec += 1;
- tv.tv_usec -= 1000000;
- }
-
- Timer** timerPtr;
- for (timerPtr = &timers; *timerPtr; timerPtr = &(*timerPtr)->next) {
- if (before((*timerPtr)->tv)) {
- next = *timerPtr;
- *timerPtr = this;
- break;
- }
- }
- if (!*timerPtr) {
- next = 0;
- *timerPtr = this;
- }
-}
-
-void Timer::cancel() {
- for (Timer** timerPtr = &timers; *timerPtr; timerPtr = &(*timerPtr)->next) {
- if (*timerPtr == this) {
- *timerPtr = (*timerPtr)->next;
- break;
- }
- }
-}
-
-bool Timer::isSet() {
- for (Timer* timer = timers; timer; timer = timer->next)
- if (timer == this) return true;
- return false;
-}
diff --git a/tx/Timer.h b/tx/Timer.h
deleted file mode 100644
index dabe4cdf..00000000
--- a/tx/Timer.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
- *
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- * USA.
- */
-#ifndef __TIMER_H__
-#define __TIMER_H__
-
-#include <sys/time.h>
-#include <unistd.h>
-
-class TimerCallback;
-
-class Timer {
-public:
- static void callTimers();
- static bool getTimeout(struct timeval* timeout);
-
- Timer(TimerCallback* cb_);
- ~Timer();
- void reset(int ms);
- void cancel();
- bool isSet();
- bool before(struct timeval other) {
- return (tv.tv_sec < other.tv_sec ||
- (tv.tv_sec == other.tv_sec && tv.tv_usec < other.tv_usec));
- }
-private:
- struct timeval tv;
- TimerCallback* cb;
- Timer* next;
-};
-
-class TimerCallback {
-public:
- virtual void timerCallback(Timer* timer) = 0;
-};
-
-#endif