CServer
 * must have connection thread in screen info map
    allows disconnect if screen map changes and screen is removed
 * put mutex locks wherever necessary (like accessing m_active)

server						client
------						------
[accept]			<--		connect
challenge			-->		[encrypt]
[verify]			<--		response (encrypted challenge, client name)
hangup if invalid
query info			-->		
					<--		info (size)

---
use automake

---
need config file and parser
  remove hard coded debugging stuff (in server.cpp)

---
win32:
  need to support window stations
    login screen on NT is a separate window station
  provide taskbar icon

win32 dll:
  should make this as small as possible
    don't use standard libraries
    use custom _DllMainCRTStartup();  just call DllMain() from it.
    use /MERGE linker switch to merge sections
  should use mutex on all public functions

---
not handling international characters

---
not handling screen saver at all yet

---
not distinguishing between caps lock and shift lock
  In Caps Lock mode, the alphabetic keys send their uppercase (shifted) char-
  acter when pressed alone. For Caps Lock mode, pressing and releasing the
  lock key turns on the mode and pressing and releasing the lock key again
  turns off the mode. In Shift Lock mode, all keys on the main keypad send
  their shifted character when pressed alone. For Shift Lock mode, pressing
  and releasing the Lock key turns on the mode, and pressing and releasing
  either the Lock or the Shift key turns off the mode.

---
problems with CLIPBOARD and KDE and NEdit
  KDE mail reader (others?) and NEdit never reply to selection request
  perhaps a general Motif problem?

currently sending all clipboards to all clients
  some clients may not need all clipboards
  add filtering mechanism

must find app that correctly sets the CLIPBOARD selection for testing
  synergy must note changes to one or both selections
    seems to be having trouble with noting CLIPBOARD after PRIMARY changes

investigate klipper
  KDE's clipboard manager?
  it crashed once when server did (see below)

---
blown assertion
  between client being added to screen list and sending screen size:
    attempt to switch to that screen blows assert
    x,y isn't inside screen because screen has zero size
  maybe have a "ready" flag for each client
    only count ready clients when finding neighbor
  or don't add client to screen list until fully ready

---
got crash when opening netscape window after trying copy in KDE mail
  BadWindow in ChangeWindowAttributes
  also got it when trying to transfer big clipboard from secondary
    or just after transferring and perhaps trying to set locally

---
sometimes not sending correct clipboard
  some kind of race condition i think
  can select text then switch and get empty clipboard
    switching back to owner screen then out gets correct clipboard

---
win32 not sending correct clipboard
  got 43 bytes sent for a 3 byte selection
  remaining bytes were 0
  problem persisted;  also got 43 bytes for a 2 byte selection

---
slow leaving primary screen on X
  possibly due to getting primary clipboards
  possibly something else
  could try asynchronously getting primary clipboard
    race condition on secondary wrt pasting

---
win32 hook DLL sometimes not unloaded when server is killed?
  will get assertion on restart as if DLL was still loaded.
  can tell because all DLL copies share data segment.
  should prevent multiple copies from loading (or initializing)
    replace asserts with (multithread locked) check of variables
    return 0 if busy
    server must handle failure
  try to figure out why it's not unloading

---
test:
  X primary
    ctrl+alt+keypad_add, ctrl+alt_keypad_minus -> eaten by primary X server
    ctrl+alt+backspace probably eaten by primary X server if so configured
    ctrl+alt+delete probably eaten locally
      probably underneath primary X server too
  Win32 desktop -> X laptop
    eaten global hot keys:
      ctrl+alt+delete -> task manager (or logon or reboot)
      alt+[shift+]tab -> cycle through tasks
      alt+[shift+]esc -> cycle windows
      ctrl+esc -> start menu
      windows+R -> run dialog
      windows+M -> minimize all
      windows+shift+M -> undo minimize all
      windows+F1 -> help
      windows+E -> explorer
      windows+F -> find files
      windows+ctrl+F -> find computer
      windows+tab -> cycle through taskbar buttons
      windows+break -> system properties
    not eaten:
      alt+space -> system menu
      shift+F10 -> context menu
      app key -> context menu
    misc:
      accessibility shortcuts: not eaten but dialogs appear anyway
  X laptop -> Win32 desktop
    check:
      shift+tab -> okay
      alt+[shift+]tab -> okay
      alt+[shift+]esc -> okay
      ctrl+esc -> start menu -> okay
      ctrl+esc, esc, shift+F10 -> toolbar context menu -> okay
      F10 -> activate menu in explorer -> okay
      shift+F10 -> context menu -> okay
      alt+space -> context menu -> okay
      alt+hyphen -> MDI window menu -> okay
      alt+letter -> open corresponding menu -> okay
      alt+F6 -> switch between windows in single program -> okay
      shift+insert CD-ROM -> bypass auto-run
    check accessibility shortcuts -> does not work
    check accessibility features
      sticky keys -> no
      filter keys -> no
      toggle keys -> no
      mouse keys -> no
      high contrast -> no
  X desktop -> win32
    check:
      shift+tab
      windows+R -> run dialog
      windows+M -> minimize all
      windows+shift+M -> minimize all
      windows+F1 -> help
      windows+E -> explorer
      windows+F -> find files
      windows+ctrl+F -> find computer
      windows+tab -> cycle through taskbar buttons
      windows+break -> system properties
      app key -> context menu
  Win32 -> Win32
    alt+F6 -> eaten (isabel to audrey, but not audrey to isabel)
    check accessibility shortcuts work on secondary
    check accessibility features work on secondary

---
audrey->isabel
  num-lock light on isabel doesn't respond to generated events.
  seems to be linked to something lower-level.  however, keytest
  does report num-lock keyboard state is being toggled.

  other toggle lights don't always respond immediately
    usually go on/off when active window changes though

---
avoid fullscreen transparent window on win32
  using CBT hook to discard activation/focus messages
    but it's not being called when we lose keyboard input
  also, we sometimes don't get the keyboard input to start with

---
keyboard hook problems (win32)
  now passing keyboard events through in most cases
    this fixes problem on isabel where toggle lights don't toggle
    and num-lock behaved incorrectly (generated wrong keys).
    seems the DefWindowProc() needed to process the keys
  unfortunately, keys sometimes leak into wrong app.  seems related
    to times when we don't get the keyboard input.  key events are
    not delivered to app on primary until cursor returns to primary.
    no idea how that's possible.
  current have some code to check active window and reset it in
    keyboard hook.  that code doesn't work.
  seem to be having problems with windows key now, too.  looks like
    a down is sent but not the corresponding up so secondary system
    thinks the key is always down.

---
try to determine keyboard quirks automatically
  in particular, set the half-duplex flags
  maybe KBD extension will help determine this

---
blown assert:
  client crashed and primary jumped to primary
  left over queued motion events then processed
    caused call to CServer::onMouseMoveSecondary
    m_protocol is NULL because we're on primary screen
  must flush queued events when jumping to primary
    check for other things to do when jumping to primary

---
key events sent to console on win me (95/98?) are very slow
  1/4 to 1/2 second delay before key up is processed
  key up log message is also delayed
    console causing a system-wide delay?

---
adjust thread priorities on win32
  maybe remove changes altogether
  currently isabel starts single-stepping mouse when dragging window
    sometimes it goes normal speed but it's mostly very slow
    even a very high priority doesn't seem to help
      haven't tried real-time priority
  a very high priority on client fixes delay when typeing into console
  is it the output console causing the slowness?

---
Accessibility Shortcuts

   Key                                Result
   -------------------------------------------------------------------
   Tap SHIFT 5 times                  Toggles StickyKeys on and off.

   Press down and hold the right      Toggles FilterKeys on and off.
   SHIFT key for 8 seconds

   Press down and hold the NUM LOCK   Toggles ToggleKeys on and off.
   key for 5 seconds

   Left ALT+left SHIFT+NUM LOCK       Toggles MouseKeys on and off.

   Left ALT+left SHIFT+PRINT SCREEN   Toggles High Contrast on and off.

---
disable ctrl+alt+del info:
  SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0)
    fools system into thinking screen saver is running
    that disables ctrl+alt+del, alt+tab, ctrl+esc
    dunno if keystrokes are queued
    may be limited to win 95/98/me
  win nt sp 3 and above:
    low-level keyboard hook is called before ctrl+esc, alt+tab, alt+esc
    use that to capture and disable
    seems that low-level hook is notified of ctrl+alt+del but can't stop it
  win nt sp 2 and below
    ctrl+esc can be disabled by replacing task manager (dunno how)
    RegisterHotKey() can be used to catch alt+tab and alt+esc
      only while app is running, of course
  win nt
    keyboard filter driver can capture keys (see win NT DDK)
  http://216.239.51.100/search?q=cache:q-f03UHhFMMC:www.thescarms.com/VBasic/StopReBoot.asp+alt%2Btab+disable&hl=en
    some info on changing keyboard scan code mapping
    can be used to disable keys but looks like reboot is required

---
Q179905
  suggestion for bypassing hook code when called by debugger.
  may prevent system from getting locked up when debugging.

---
config file format:

section screens
  <screen>:
    # args in any order
    # not sure if any args
end

section links
  <screen>:
    # args in any order
    [left=<screen>]
    [right=<screen>]
    [up=<screen>]
    [down=<screen>]
end

---
will have to redo clipboard stuff on win32

need timeout on CReply objects
  should flush replies that are too old
  assumption is that requestor is broken