1 /* window.cc: hidden windows for signals/itimer support
3 Written by Sergey Okhapkin <sos@prospect.com.ru>
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
13 #define USE_SYS_TYPES_FD_SET
15 #include "perprocess.h"
20 wininfo NO_COPY winmsg
;
22 muto NO_COPY
wininfo::_lock
;
25 wininfo::process (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
28 strace
.wm (uMsg
, wParam
, lParam
);
38 if (WSAGETSELECTEVENT (lParam
) == FD_OOB
)
44 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
48 static LRESULT CALLBACK
49 process_window_events (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
51 return winmsg
.process (hwnd
, uMsg
, wParam
, lParam
);
54 /* Handle windows events. Inherits ownership of the wininfo lock */
60 static NO_COPY WCHAR classname
[] = L
"CygwinWndClass";
63 /* Register the window class for the main window. */
66 wc
.lpfnWndProc
= (WNDPROC
) process_window_events
;
69 wc
.hInstance
= user_data
->hmodule
;
72 wc
.hbrBackground
= NULL
;
73 wc
.lpszMenuName
= NULL
;
74 wc
.lpszClassName
= classname
;
76 if (!RegisterClassW (&wc
))
77 api_fatal ("cannot register window class, %E");
79 /* Create hidden window. */
80 hwnd
= CreateWindowExW (0, classname
, classname
, WS_POPUP
, CW_USEDEFAULT
,
81 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
,
82 (HWND
) NULL
, (HMENU
) NULL
, user_data
->hmodule
,
85 api_fatal ("couldn't create window, %E");
89 while ((ret
= (int) GetMessageW (&msg
, hwnd
, 0, 0)) > 0)
90 DispatchMessageW (&msg
);
98 return ((wininfo
*) arg
)->winthread ();
111 cygthread
*h
= new cygthread (::winthread
, this, "win");
112 h
->SetThreadPriority (THREAD_PRIORITY_HIGHEST
);
123 _lock
.init ("wininfo_lock")->acquire ();