322c131f9f
(locker): Remove unused class. (new_muto): Delete. (new_muto1): Ditto. (new_muto_name): Ditto. * cygheap.cc (cygheap_setup_for_child): Reflect use of static storage for muto rather than pointer. (_csbrk): Ditto. (_cmalloc): Ditto. (_cmalloc): Ditto. (_cfree): Ditto. * cygheap.h (cwdstuff::cwd_lock): Ditto. (cwdstuff::get_drive): Ditto. * cygmalloc.h (__malloc_lock): Ditto. (__malloc_unlock): Ditto. * cygtls.cc (sentry::lock): Ditto. (sentry::sentry): Ditto. (~sentry): Ditto. (_cygtls::init): Ditto. * dcrt0.cc: Ditto. (cygwin_atexit): Ditto. (cygwin_exit): Ditto. * debug.cc (lock_debug::locker): Ditto. (lock_debug::lock_debug): Ditto. (lock_debug::unlock): Ditto. (debug_init): Ditto. * dtable.cc (dtable::init_lock): Ditto. * dtable.h (dtable::lock_cs): Ditto. (dtable::lock): Ditto. (dtable::unlock): Ditto. * exceptions.cc (mask_sync): Ditto. (sighold): Ditto. (set_process_mask_delta): Ditto. (set_signal_mask): Ditto. (events_init): Ditto. * grp.cc (pwdgrp::pwdgrp): Ditto. * malloc_wrapper.cc (mallock): Ditto. (malloc_init): Ditto. * path.cc (cwdstuff::cwd_lock): Ditto. (cwdstuff::get_hash): Ditto. (cwdstuff::get_hash): Ditto. (cwdstuff::init): Ditto. (cwdstuff::set): Ditto. (cwdstuff::get): Ditto. * pwdgrp.h (pwdgrp::pglock): Ditto. (pwdgrp::refresh): Ditto. * sigproc.cc (sync_proc_subproc): Ditto. (get_proc_lock): Ditto. (proc_subproc): Ditto. (_cygtls::remove_wq): Ditto. (proc_terminate): Ditto. (sigproc_init): Ditto. * timer.cc (lock_timer_tracker::protect): Ditto. (lock_timer_tracker::lock_timer_tracker): Ditto. (lock_timer_tracker::~lock_timer_tracker): Ditto. * wininfo.cc (wininfo::_lock;): Ditto. (wininfo::winthread): Ditto. (operator HWND): Ditto. (wininfo::lock): Ditto. (wininfo::release): Ditto. * wininfo.h (wininfo::_lock;): Ditto.
141 lines
2.9 KiB
C++
141 lines
2.9 KiB
C++
/* window.cc: hidden windows for signals/itimer support
|
|
|
|
Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
|
|
|
|
Written by Sergey Okhapkin <sos@prospect.com.ru>
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#include "winsup.h"
|
|
#include <sys/time.h>
|
|
#include <stdlib.h>
|
|
#include <signal.h>
|
|
#include <limits.h>
|
|
#include <wingdi.h>
|
|
#include <winuser.h>
|
|
#define USE_SYS_TYPES_FD_SET
|
|
#include <winsock2.h>
|
|
#include <unistd.h>
|
|
#include "cygerrno.h"
|
|
#include "perprocess.h"
|
|
#include "security.h"
|
|
#include "thread.h"
|
|
#include "cygtls.h"
|
|
#include "sync.h"
|
|
#include "wininfo.h"
|
|
|
|
wininfo NO_COPY winmsg;
|
|
|
|
muto NO_COPY wininfo::_lock;
|
|
|
|
int __stdcall
|
|
wininfo::process (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
#ifndef NOSTRACE
|
|
strace.wm (uMsg, wParam, lParam);
|
|
#endif
|
|
switch (uMsg)
|
|
{
|
|
case WM_PAINT:
|
|
return 0;
|
|
case WM_DESTROY:
|
|
PostQuitMessage (0);
|
|
return 0;
|
|
case WM_ASYNCIO:
|
|
if (WSAGETSELECTEVENT (lParam) == FD_OOB)
|
|
raise (SIGURG);
|
|
else
|
|
raise (SIGIO);
|
|
return 0;
|
|
default:
|
|
return DefWindowProc (hwnd, uMsg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
static LRESULT CALLBACK
|
|
process_window_events (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
return winmsg.process (hwnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
/* Handle windows events. Inherits ownership of the wininfo lock */
|
|
DWORD WINAPI
|
|
wininfo::winthread ()
|
|
{
|
|
MSG msg;
|
|
WNDCLASS wc;
|
|
static NO_COPY char classname[] = "CygwinWndClass";
|
|
|
|
_lock.grab ();
|
|
/* Register the window class for the main window. */
|
|
|
|
wc.style = 0;
|
|
wc.lpfnWndProc = (WNDPROC) process_window_events;
|
|
wc.cbClsExtra = 0;
|
|
wc.cbWndExtra = 0;
|
|
wc.hInstance = user_data->hmodule;
|
|
wc.hIcon = NULL;
|
|
wc.hCursor = NULL;
|
|
wc.hbrBackground = NULL;
|
|
wc.lpszMenuName = NULL;
|
|
wc.lpszClassName = classname;
|
|
|
|
if (!RegisterClass (&wc))
|
|
api_fatal ("cannot register window class, %E");
|
|
|
|
/* Create hidden window. */
|
|
hwnd = CreateWindow (classname, classname, WS_POPUP, CW_USEDEFAULT,
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
(HWND) NULL, (HMENU) NULL, user_data->hmodule,
|
|
(LPVOID) NULL);
|
|
if (!hwnd)
|
|
api_fatal ("couldn't create window, %E");
|
|
release ();
|
|
|
|
while (GetMessage (&msg, hwnd, 0, 0) == TRUE)
|
|
DispatchMessage (&msg);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static DWORD WINAPI
|
|
winthread (VOID *arg)
|
|
{
|
|
return ((wininfo *) arg)->winthread ();
|
|
}
|
|
|
|
wininfo::operator
|
|
HWND ()
|
|
{
|
|
if (hwnd)
|
|
return hwnd;
|
|
|
|
lock ();
|
|
if (!hwnd)
|
|
{
|
|
_lock.upforgrabs ();
|
|
cygthread *h = new cygthread (::winthread, this, "win");
|
|
h->SetThreadPriority (THREAD_PRIORITY_HIGHEST);
|
|
h->zap_h ();
|
|
lock ();
|
|
}
|
|
release ();
|
|
return hwnd;
|
|
}
|
|
|
|
void
|
|
wininfo::lock ()
|
|
{
|
|
_lock.init ("wininfo_lock")->acquire ();
|
|
}
|
|
|
|
void
|
|
wininfo::release ()
|
|
{
|
|
_lock.release ();
|
|
}
|