From 126c1cfaa5b5978026d44a1f8b044d367056965b Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 17 Jun 2013 18:27:56 +0100 Subject: [PATCH] hw/xwin: Separate libwinclipboard interface and internal header files Rename the libwinclipboard internal header from winclipboard.h to internal.h Put libwinclipboard's public interface into winclipboard.h This lets winclipboardinit.c partake of that public interface, and all X server headers without clashes winInitClipboard() prototype belongs in a server header v2: Remove duplicate declaration of winClipboardWindowDestroy() Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/win.h | 3 - hw/xwin/winclipboard/internal.h | 123 ++++++++++++++++++++++ hw/xwin/winclipboard/thread.c | 5 +- hw/xwin/winclipboard/winclipboard.h | 156 ++++++---------------------- hw/xwin/winclipboard/wndproc.c | 5 +- hw/xwin/winclipboard/xevents.c | 2 +- hw/xwin/winclipboardinit.c | 11 +- hw/xwin/winwndproc.c | 3 + 8 files changed, 165 insertions(+), 143 deletions(-) create mode 100644 hw/xwin/winclipboard/internal.h diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 1a882f4aa..7af35e71b 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -792,9 +792,6 @@ RegionPtr Bool winInitClipboard(void); -void - winFixClipboardChain(void); - void winClipboardShutdown(void); #endif diff --git a/hw/xwin/winclipboard/internal.h b/hw/xwin/winclipboard/internal.h new file mode 100644 index 000000000..89f0c39c7 --- /dev/null +++ b/hw/xwin/winclipboard/internal.h @@ -0,0 +1,123 @@ + +/* + *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. + * + *Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + *"Software"), to deal in the Software without restriction, including + *without limitation the rights to use, copy, modify, merge, publish, + *distribute, sublicense, and/or sell copies of the Software, and to + *permit persons to whom the Software is furnished to do so, subject to + *the following conditions: + * + *The above copyright notice and this permission notice shall be + *included in all copies or substantial portions of the Software. + * + *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR + *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + *Except as contained in this notice, the name of Harold L Hunt II + *shall not be used in advertising or otherwise to promote the sale, use + *or other dealings in this Software without prior written authorization + *from Harold L Hunt II. + * + * Authors: Harold L Hunt II + */ + +#ifndef WINCLIPBOARD_INTERNAL_H +#define WINCLIPBOARD_INTERNAL_H + +/* Standard library headers */ +#include +#include +#include +#include +#ifdef __CYGWIN__ +#include +#else +#include +#endif +#include +#include +#include + +/* X headers */ +#include +#include +#include +#include + +/* Windows headers */ +#include + +/* Clipboard module constants */ +#ifdef HAS_DEVWINDOWS +#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif +#define WIN_JMP_OKAY 0 +#define WIN_JMP_ERROR_IO 2 +#define WIN_LOCAL_PROPERTY "CYGX_CUT_BUFFER" +#define WIN_XEVENTS_SUCCESS 0 +#define WIN_XEVENTS_CONVERT 2 +#define WIN_XEVENTS_NOTIFY 3 + +#define WM_WM_REINIT (WM_USER + 1) + +/* + * References to external symbols + */ + +extern void winDebug(const char *format, ...); +extern void winErrorFVerb(int verb, const char *format, ...); + +/* + * winclipboardtextconv.c + */ + +void + winClipboardDOStoUNIX(char *pszData, int iLength); + +void + winClipboardUNIXtoDOS(char **ppszData, int iLength); + +/* + * winclipboardthread.c + */ + + +/* + * winclipboardwndproc.c + */ + +BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd); + +LRESULT CALLBACK +winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +typedef struct +{ + Display *pClipboardDisplay; + Window iClipboardWindow; +} ClipboardWindowCreationParams; + +/* + * winclipboardxevents.c + */ + +int +winClipboardFlushXEvents(HWND hwnd, + int iWindow, Display * pDisplay, Bool fUnicodeSupport); + + +Atom +winClipboardGetLastOwnedSelectionAtom(void); + +void +winClipboardInitMonitoredSelections(void); + +#endif diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c index bbb3a2142..36a1b4e45 100644 --- a/hw/xwin/winclipboard/thread.c +++ b/hw/xwin/winclipboard/thread.c @@ -35,15 +35,18 @@ #else #define HAS_WINSOCK 1 #endif + #include #include -#include "winclipboard.h" #include "windisplay.h" #ifdef __CYGWIN__ #include #endif + #include "misc.h" #include +#include "winclipboard.h" +#include "internal.h" #define WIN_CONNECT_RETRIES 40 #define WIN_CONNECT_DELAY 4 diff --git a/hw/xwin/winclipboard/winclipboard.h b/hw/xwin/winclipboard/winclipboard.h index 95b18a6e8..7aaa341d4 100644 --- a/hw/xwin/winclipboard/winclipboard.h +++ b/hw/xwin/winclipboard/winclipboard.h @@ -1,134 +1,36 @@ -/* - *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ +// +// Copyright © Jon TURNEY 2013 +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice (including the next +// paragraph) shall be included in all copies or substantial portions of the +// Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File: winclipboard.h +// Purpose: public interface to winclipboard library +// -#ifndef _WINCLIPBOARD_H_ -#define _WINCLIPBOARD_H_ - -/* Standard library headers */ -#include -#include -#include -#include -#ifdef __CYGWIN__ -#include -#else -#include -#endif -#include -#include -#include - -/* X headers */ -#include -#include -#include -#include -#include - -/* Windows headers */ -#include - -/* Clipboard module constants */ -#ifdef HAS_DEVWINDOWS -#define WIN_MSG_QUEUE_FNAME "/dev/windows" -#endif -#define WIN_JMP_OKAY 0 -#define WIN_JMP_ERROR_IO 2 -#define WIN_LOCAL_PROPERTY "CYGX_CUT_BUFFER" -#define WIN_XEVENTS_SUCCESS 0 -#define WIN_XEVENTS_CONVERT 2 -#define WIN_XEVENTS_NOTIFY 3 - -#define WM_WM_REINIT (WM_USER + 1) - -/* - * References to external symbols - */ - -extern void winDebug(const char *format, ...); -extern void winErrorFVerb(int verb, const char *format, ...); - -/* - * winclipboardinit.c - */ - -Bool - winInitClipboard(void); - -/* - * winclipboardtextconv.c - */ - -void - winClipboardDOStoUNIX(char *pszData, int iLength); - -void - winClipboardUNIXtoDOS(char **ppszData, int iLength); - -/* - * winclipboardthread.c - */ +#ifndef WINCLIPBOARD_H +#define WINCLIPBOARD_H Bool winClipboardProc(char *szDisplay); -void -winClipboardWindowDestroy(void); +void winFixClipboardChain(void); -/* - * winclipboardwndproc.c - */ - -BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd); - -LRESULT CALLBACK -winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -typedef struct -{ - Display *pClipboardDisplay; - Window iClipboardWindow; -} ClipboardWindowCreationParams; - -/* - * winclipboardxevents.c - */ - -int -winClipboardFlushXEvents(HWND hwnd, - int iWindow, Display * pDisplay, Bool fUnicodeSupport); - - -Atom -winClipboardGetLastOwnedSelectionAtom(void); - -void -winClipboardInitMonitoredSelections(void); +void winClipboardWindowDestroy(void); #endif diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c index 459170f2a..769422bbc 100644 --- a/hw/xwin/winclipboard/wndproc.c +++ b/hw/xwin/winclipboard/wndproc.c @@ -33,10 +33,13 @@ #ifdef HAVE_XWIN_CONFIG_H #include #endif + #include #include -#include "winclipboard.h" + +#include "internal.h" #include "misc.h" +#include "winclipboard.h" /* * Constants diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index a792467f0..3fcf6e3b1 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -34,7 +34,7 @@ #include #endif -#include "winclipboard.h" +#include "internal.h" #include "misc.h" #include diff --git a/hw/xwin/winclipboardinit.c b/hw/xwin/winclipboardinit.c index 25790d044..3324661df 100644 --- a/hw/xwin/winclipboardinit.c +++ b/hw/xwin/winclipboardinit.c @@ -35,22 +35,13 @@ #include #include -#include "os.h" +#include "win.h" #include "winclipboard/winclipboard.h" #include "windisplay.h" #define WIN_CLIPBOARD_RETRIES 40 #define WIN_CLIPBOARD_DELAY 1 -extern void winSetAuthorization(void); - -/* - * References to external symbols - */ - -extern Bool g_fClipboard; -extern Bool g_fClipboardStarted; - /* * Local variables */ diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index bee223de7..e3adb5605 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -42,6 +42,9 @@ #include "winmsg.h" #include "winmonitors.h" #include "inputstr.h" +#ifdef XWIN_CLIPBOARD +#include "winclipboard/winclipboard.h" +#endif /* * Global variables