]> source.dussan.org Git - tigervnc.git/commitdiff
The "tx" library merged with VNC 4.1.1 code.
authorConstantin Kaplinsky <const@tightvnc.com>
Mon, 17 Apr 2006 02:57:56 +0000 (02:57 +0000)
committerConstantin Kaplinsky <const@tightvnc.com>
Mon, 17 Apr 2006 02:57:56 +0000 (02:57 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/branches/merge-with-vnc-4.1.1@525 3789f03b-4d11-0410-bbf8-ca57d06f2519

19 files changed:
tx/Makefile.in
tx/TXButton.h
tx/TXCheckbox.h
tx/TXDialog.h
tx/TXEntry.h
tx/TXImage.cxx
tx/TXImage.h
tx/TXLabel.h
tx/TXMenu.cxx
tx/TXMenu.h
tx/TXMsgBox.h
tx/TXScrollbar.cxx
tx/TXScrollbar.h
tx/TXViewport.cxx
tx/TXViewport.h
tx/TXWindow.cxx
tx/TXWindow.h
tx/Timer.cxx [deleted file]
tx/Timer.h [deleted file]

index b953325adb56909a6fc9b6975cb563a461ef9970..89c30b17a05cad71f12ea8a1125ecc95955d6963 100644 (file)
@@ -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)
 
index c22dbf9461e82f77a32c894683ef3f25687df8ea..b7472797688cf0944e588f98c1adb7ece32fbbbc 100644 (file)
@@ -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);
     }
index 41eef27cb6a1da5482ac56714a8e20d11194aed5..3c2a23b8ee0a58725ed9d595940524c5b749d8c3 100644 (file)
@@ -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);
     }
index 01677a9ed80be222058eb16fd57e9aea936af068..0bfd88a87e7448ca7457e18f10bfdbb376155afc 100644 (file)
@@ -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;
index 0d1f005ff6e9802aeb11213a2caca933a5c163f5..9002957988911e74b4f9aca01997a4e2aad8c2a4 100644 (file)
@@ -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);
     }
index 7801578ccf6efeaba8c20376554af3849b28424d..5fa6828800ffa058f01bda71165932e9a8b2593a 100644 (file)
@@ -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;
 
index 8185366ae81b602627eec791911f4e08cd2c54eb..055bd22d520428bcb18d1375fd6d5a283c562f7c 100644 (file)
@@ -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
index bbd893a564d7a718353c3cf3b92ccd6fb4a9d783..3d5200d6748c6894490838ba100df33182b0c8c0 100644 (file)
@@ -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:
index 4069f2d2fda99ffc403f66cf406607c6a376f8d8..92712f558efdaa54d878b06c6ea56532d588eab3 100644 (file)
@@ -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
index 82dafa56e3780b4e366ddd77541571d579276e85..d0245ee92ac479d20e375fdbfa88d29b6c4ae23c 100644 (file)
@@ -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
index 00c4eb5f0ff35ca5f1507bcc70ecf5033467d4fc..ff84e6ae3a98cec981f0a19bfcdfdd592135b850 100644 (file)
@@ -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();
   }
 
index 946ccffc830e8dbe1303ae8faa39e2c7ce7e6939..47e124c37519784848e255e8e1c81eb332fc8a6a 100644 (file)
@@ -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
index 4cc2afa3cfc2c884b0d36b356519ec13f3715ecf..87fec3d8a4bd16cbd3b639e06e2cd2f077f9fe60 100644 (file)
@@ -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
index 67982e9fe1dad0c9fb97327179d6f2ef07748af0..abe5173402307690fae6d0b609df00cac2727483 100644 (file)
@@ -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()
index 9dddc2f8691778723a1783b0dd12028e8c274d66..0c9857d28b4ff0be88e5e6d51d014b1c03e53aa0 100644 (file)
@@ -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
 #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;
index 1114685c22576aca1d420862e1681a3f086210cb..6d211beb03ccca082c61112c076b3cdaeabfa96f 100644 (file)
@@ -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) {
index 20c31c9531594621ce96a8d6d4a1b6d5c86dba0d..5ada181b85fb5830f8d1d79894acb04c43d77673 100644 (file)
@@ -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 (file)
index 3acb631..0000000
+++ /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 (file)
index dabe4cd..0000000
+++ /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