The "rfb_win32" 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@523 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb_win32/SDisplay.h b/rfb_win32/SDisplay.h
index c4c08bf..6dbb50a 100644
--- a/rfb_win32/SDisplay.h
+++ b/rfb_win32/SDisplay.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
@@ -20,31 +20,21 @@
 //
 // The SDisplay class encapsulates a system display.
 
-// *** THIS INTERFACE NEEDS TIDYING TO SEPARATE COORDINATE SYSTEMS BETTER ***
-
 #ifndef __RFB_SDISPLAY_H__
 #define __RFB_SDISPLAY_H__
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
 #include <rfb/SDesktop.h>
 #include <rfb/UpdateTracker.h>
 #include <rfb/Configuration.h>
-#include <rfb/util.h>
-
-#include <winsock2.h>
-#include <rfb_win32/Win32Util.h>
-#include <rfb_win32/SocketManager.h>
-#include <rfb_win32/DeviceFrameBuffer.h>
+#include <rfb_win32/Handle.h>
+#include <rfb_win32/EventManager.h>
 #include <rfb_win32/SInput.h>
 #include <rfb_win32/Clipboard.h>
-#include <rfb_win32/MsgWindow.h>
+#include <rfb_win32/CleanDesktop.h>
 #include <rfb_win32/WMCursor.h>
-#include <rfb_win32/WMHooks.h>
 #include <rfb_win32/WMNotifier.h>
-#include <rfb_win32/WMWindowCopyRect.h>
-#include <rfb_win32/WMPoller.h>
+#include <rfb_win32/DeviceFrameBuffer.h>
+#include <rfb_win32/DeviceContext.h>
 
 namespace rfb {
 
@@ -54,33 +44,33 @@
     // -=- SDisplay
     //
 
-    class SDisplayCore;
+    class SDisplayCore {
+    public:
+      virtual ~SDisplayCore() {};
+      virtual void setScreenRect(const Rect& screenRect_) = 0;
+      virtual void flushUpdates() = 0;
+      virtual const char* methodName() const = 0;
+    };
 
     class SDisplay : public SDesktop,
       WMMonitor::Notifier,
       Clipboard::Notifier,
-      UpdateTracker,
-      public SocketManager::EventHandler
+      public EventHandler
     {
     public:
-      SDisplay(const TCHAR* device=0);
+      SDisplay();
       virtual ~SDisplay();
 
       // -=- SDesktop interface
 
       virtual void start(VNCServer* vs);
       virtual void stop();
-      virtual void pointerEvent(const Point& pos, rdr::U8 buttonmask);
+      virtual void pointerEvent(const Point& pos, int buttonmask);
       virtual void keyEvent(rdr::U32 key, bool down);
       virtual void clientCutText(const char* str, int len);
       virtual void framebufferUpdateRequest();
       virtual Point getFbSize();
 
-      // -=- UpdateTracker
-
-      virtual void add_changed(const Region& rgn);
-      virtual void add_copied(const Region& dest, const Point& delta);
-
       // -=- Clipboard
       
       virtual void notifyClipboardChanged(const char* text, int len);
@@ -92,7 +82,7 @@
       // -=- EventHandler interface
 
       HANDLE getUpdateEvent() {return updateEvent;}
-      virtual bool processEvent(HANDLE event);
+      virtual void processEvent(HANDLE event);
 
       // -=- Notification of whether or not SDisplay is started
 
@@ -100,38 +90,62 @@
 
       friend class SDisplayCore;
 
-      static BoolParameter use_hooks;
+      static IntParameter updateMethod;
       static BoolParameter disableLocalInputs;
       static StringParameter disconnectAction;
       static BoolParameter removeWallpaper;
       static BoolParameter removePattern;
       static BoolParameter disableEffects;
 
-    protected:
-      void restart();
-      void recreatePixelBuffer();
-      bool flushChangeTracker();  // true if flushed, false if empty
+      // -=- Use by VNC Config to determine whether hooks, driver, etc are available
+      static bool areHooksAvailable();
+      static bool isDriverAvailable();
 
-      void triggerUpdate();
+
+    protected:
+      bool isRestartRequired();
+      void startCore();
+      void stopCore();
+      void restartCore();
+      void recreatePixelBuffer(bool force=false);
+      bool flushChangeTracker();  // true if flushed, false if empty
 
       VNCServer* server;
 
       // -=- Display pixel buffer
       DeviceFrameBuffer* pb;
-      TCharArray deviceName;
-      HDC device;
-      bool releaseDevice;
+      DeviceContext* device;
 
       // -=- The coordinates of Window's entire virtual Screen
       Rect screenRect;
 
-      // -=- All changes are collected in Display coords and merged
-      SimpleUpdateTracker change_tracker;
+      // -=- All changes are collected in UN-CLIPPED Display coords and merged
+      //     When they are to be flushed to the VNCServer, they are changed
+      //     to server coords and clipped appropriately.
+      SimpleUpdateTracker updates;
+      ClippingUpdateTracker clipper;
 
       // -=- Internal SDisplay implementation
       SDisplayCore* core;
+      int updateMethod_;
 
-      // -=- Cursor
+      // Inputs
+      SPointer* ptr;
+      SKeyboard* kbd;
+      Clipboard* clipboard;
+      WMBlockInput* inputs;
+
+      // Desktop state
+      WMMonitor* monitor;
+
+      // Desktop optimisation
+      CleanDesktop* cleanDesktop;
+      bool isWallpaperRemoved;
+      bool isPatternRemoved;
+      bool areEffectsDisabled;
+
+      // Cursor
+      WMCursor* cursor;
       WMCursor::Info old_cursor;
       Region old_cursor_region;
       Point cursor_renderpos;