1#ifndef _WINCLIPBOARD_H_
2#define _WINCLIPBOARD_H_
3/*
4 *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
5 *
6 *Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 *"Software"), to deal in the Software without restriction, including
9 *without limitation the rights to use, copy, modify, merge, publish,
10 *distribute, sublicense, and/or sell copies of the Software, and to
11 *permit persons to whom the Software is furnished to do so, subject to
12 *the following conditions:
13 *
14 *The above copyright notice and this permission notice shall be
15 *included in all copies or substantial portions of the Software.
16 *
17 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
21 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 *Except as contained in this notice, the name of Harold L Hunt II
26 *shall not be used in advertising or otherwise to promote the sale, use
27 *or other dealings in this Software without prior written authorization
28 *from Harold L Hunt II.
29 *
30 * Authors:	Harold L Hunt II
31 */
32
33/* Standard library headers */
34#include <assert.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <unistd.h>
38#ifdef __CYGWIN__
39#include <sys/select.h>
40#else
41#include <X11/Xwinsock.h>
42#define HAS_WINSOCK
43#endif
44#include <fcntl.h>
45#include <setjmp.h>
46#include <pthread.h>
47
48/* X headers */
49#include <X11/X.h>
50#include <X11/Xatom.h>
51#include <X11/Xproto.h>
52#include <X11/Xutil.h>
53#include <X11/Xlocale.h>
54
55/* Windows headers */
56#include <X11/Xwindows.h>
57
58
59/* Clipboard module constants */
60#define WIN_CLIPBOARD_WINDOW_CLASS		"xwinclip"
61#define WIN_CLIPBOARD_WINDOW_TITLE		"xwinclip"
62#ifdef HAS_DEVWINDOWS
63# define WIN_MSG_QUEUE_FNAME			"/dev/windows"
64#endif
65#define WIN_CONNECT_RETRIES			40
66#define WIN_CONNECT_DELAY			4
67#define WIN_JMP_OKAY				0
68#define WIN_JMP_ERROR_IO			2
69#define WIN_LOCAL_PROPERTY			"CYGX_CUT_BUFFER"
70#define WIN_XEVENTS_SUCCESS			0
71#define WIN_XEVENTS_SHUTDOWN			1
72#define WIN_XEVENTS_CONVERT			2
73#define WIN_XEVENTS_NOTIFY			3
74
75#define WM_WM_REINIT                           (WM_USER + 1)
76
77/*
78 * References to external symbols
79 */
80
81extern char *display;
82extern void ErrorF (const char* /*f*/, ...);
83extern void winDebug (const char *format, ...);
84extern void winErrorFVerb (int verb, const char *format, ...);
85
86
87/*
88 * winclipboardinit.c
89 */
90
91Bool
92winInitClipboard (void);
93
94HWND
95winClipboardCreateMessagingWindow (void);
96
97
98/*
99 * winclipboardtextconv.c
100 */
101
102void
103winClipboardDOStoUNIX (char *pszData, int iLength);
104
105void
106winClipboardUNIXtoDOS (unsigned char **ppszData, int iLength);
107
108
109/*
110 * winclipboardthread.c
111 */
112
113void *
114winClipboardProc (void *);
115
116void
117winDeinitClipboard (void);
118
119
120/*
121 * winclipboardunicode.c
122 */
123
124Bool
125winClipboardDetectUnicodeSupport (void);
126
127
128/*
129 * winclipboardwndproc.c
130 */
131
132BOOL
133winClipboardFlushWindowsMessageQueue (HWND hwnd);
134
135LRESULT CALLBACK
136winClipboardWindowProc (HWND hwnd, UINT message,
137			WPARAM wParam, LPARAM lParam);
138
139
140/*
141 * winclipboardxevents.c
142 */
143
144int
145winClipboardFlushXEvents (HWND hwnd,
146			  int iWindow,
147			  Display *pDisplay,
148			  Bool fUnicodeSupport);
149#endif
150