First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xwin / winclipboardinit.c
blob6a0cbaf2c40d9fb6f05bbddc0292e31f86656aa2
1 /*
2 *Copyright (C) 2003-2004 Harold L Hunt II All Rights Reserved.
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *Except as contained in this notice, the name of Harold L Hunt II
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from Harold L Hunt II.
28 * Authors: Harold L Hunt II
31 #ifdef HAVE_XWIN_CONFIG_H
32 #include <xwin-config.h>
33 #endif
34 #include "dixstruct.h"
35 #include "winclipboard.h"
39 * Local typedefs
42 typedef int (*winDispatchProcPtr) (ClientPtr);
44 DISPATCH_PROC(winProcSetSelectionOwner);
48 * References to external symbols
51 extern pthread_t g_ptClipboardProc;
52 extern winDispatchProcPtr winProcSetSelectionOwnerOrig;
53 extern Bool g_fClipboard;
54 extern HWND g_hwndClipboard;
58 * Intialize the Clipboard module
61 Bool
62 winInitClipboard ()
64 ErrorF ("winInitClipboard ()\n");
66 /* Wrap some internal server functions */
67 if (ProcVector[X_SetSelectionOwner] != winProcSetSelectionOwner)
69 winProcSetSelectionOwnerOrig = ProcVector[X_SetSelectionOwner];
70 ProcVector[X_SetSelectionOwner] = winProcSetSelectionOwner;
73 /* Spawn a thread for the Clipboard module */
74 if (pthread_create (&g_ptClipboardProc,
75 NULL,
76 winClipboardProc,
77 NULL))
79 /* Bail if thread creation failed */
80 ErrorF ("winInitClipboard - pthread_create failed.\n");
81 return FALSE;
84 return TRUE;
89 * Create the Windows window that we use to recieve Windows messages
92 HWND
93 winClipboardCreateMessagingWindow ()
95 WNDCLASS wc;
96 HWND hwnd;
98 /* Setup our window class */
99 wc.style = CS_HREDRAW | CS_VREDRAW;
100 wc.lpfnWndProc = winClipboardWindowProc;
101 wc.cbClsExtra = 0;
102 wc.cbWndExtra = 0;
103 wc.hInstance = GetModuleHandle (NULL);
104 wc.hIcon = 0;
105 wc.hCursor = 0;
106 wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
107 wc.lpszMenuName = NULL;
108 wc.lpszClassName = WIN_CLIPBOARD_WINDOW_CLASS;
109 RegisterClass (&wc);
111 /* Create the window */
112 hwnd = CreateWindowExA (0, /* Extended styles */
113 WIN_CLIPBOARD_WINDOW_CLASS,/* Class name */
114 WIN_CLIPBOARD_WINDOW_TITLE,/* Window name */
115 WS_OVERLAPPED, /* Not visible anyway */
116 CW_USEDEFAULT, /* Horizontal position */
117 CW_USEDEFAULT, /* Vertical position */
118 CW_USEDEFAULT, /* Right edge */
119 CW_USEDEFAULT, /* Bottom edge */
120 (HWND) NULL, /* No parent or owner window */
121 (HMENU) NULL, /* No menu */
122 GetModuleHandle (NULL),/* Instance handle */
123 NULL); /* Creation data */
124 assert (hwnd != NULL);
126 /* I'm not sure, but we may need to call this to start message processing */
127 ShowWindow (hwnd, SW_HIDE);
129 /* Similarly, we may need a call to this even though we don't paint */
130 UpdateWindow (hwnd);
132 return hwnd;
135 void
136 winFixClipboardChain (void)
138 if (g_fClipboard
139 && g_hwndClipboard)
141 PostMessage (g_hwndClipboard, WM_WM_REINIT, 0, 0);