From: Geoff Voelker Date: Thu, 25 Jan 1996 03:06:44 +0000 (+0000) Subject: backout 1,.4 X-Git-Tag: emacs-19.34~1508 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dd118a073d7800973c5a7e3e74e541c6dc626392;p=emacs.git backout 1,.4 --- diff --git a/src/w32xfns.c b/src/w32xfns.c index 9929248e92b..e478bc24537 100644 --- a/src/w32xfns.c +++ b/src/w32xfns.c @@ -22,7 +22,6 @@ Boston, MA 02111-1307, USA. */ #include #include #include "lisp.h" -#include "frame.h" #include "blockinput.h" #include "w32term.h" #include "windowsx.h" @@ -30,78 +29,38 @@ Boston, MA 02111-1307, USA. */ #define myalloc(cb) GlobalAllocPtr (GPTR, cb) #define myfree(lp) GlobalFreePtr (lp) -CRITICAL_SECTION critsect[ CRIT_TOTAL ]; +CRITICAL_SECTION critsect; extern HANDLE keyboard_handle; -HANDLE h_input_available = NULL; +HANDLE hEvent = NULL; void init_crit () { - int i; - - for (i = 0; i < CRIT_TOTAL; i++) - InitializeCriticalSection (&critsect[i]); - /* For safety, h_input_available should only be reset by get_next_msg - when the input queue is empty, so make it a manual reset event. */ - keyboard_handle = h_input_available = CreateEvent (NULL, TRUE, FALSE, NULL); + InitializeCriticalSection (&critsect); + keyboard_handle = hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); } void -delete_crit () +enter_crit () { - int i; - - for (i = 0; i < CRIT_TOTAL; i++) - DeleteCriticalSection (&critsect[i]); - if (h_input_available) - { - CloseHandle (h_input_available); - h_input_available = NULL; - } + EnterCriticalSection (&critsect); } -/* Get a DC for frame and select palette for drawing; force an update of - all frames if palette's mapping changes. */ -HDC -GetFrameDC (FRAME_PTR f) +void +leave_crit () { - HDC hDC; - - enter_crit (CRIT_GDI); - - hDC = GetDC (f->output_data.win32->window_desc); - - if (!NILP (Vwin32_enable_palette)) - f->output_data.win32->h_old_palette = - SelectPalette (hDC, one_win32_display_info.h_palette, FALSE); - else - f->output_data.win32->h_old_palette = NULL; - - if (RealizePalette (hDC)) - { - Lisp_Object frame, framelist; - FOR_EACH_FRAME (framelist, frame) - { - SET_FRAME_GARBAGED (XFRAME (frame)); - } - } - - return hDC; + LeaveCriticalSection (&critsect); } -int -ReleaseFrameDC (FRAME_PTR f, HDC hDC) +void +delete_crit () { - int ret; - - if (f->output_data.win32->h_old_palette) - SelectPalette (hDC, f->output_data.win32->h_old_palette, FALSE); - - ret = ReleaseDC (f->output_data.win32->window_desc, hDC); - - leave_crit (CRIT_GDI); - - return ret; + DeleteCriticalSection (&critsect); + if (hEvent) + { + CloseHandle (hEvent); + hEvent = NULL; + } } typedef struct int_msg @@ -121,15 +80,15 @@ get_next_msg (lpmsg, bWait) { BOOL bRet = FALSE; - enter_crit (CRIT_MSG); + enter_crit (); /* The while loop takes care of multiple sets */ while (!nQueue && bWait) { - leave_crit (CRIT_MSG); - WaitForSingleObject (h_input_available, INFINITE); - enter_crit (CRIT_MSG); + leave_crit (); + WaitForSingleObject (hEvent, INFINITE); + enter_crit (); } if (nQueue) @@ -148,11 +107,8 @@ get_next_msg (lpmsg, bWait) bRet = TRUE; } - - if (nQueue == 0) - ResetEvent (h_input_available); - leave_crit (CRIT_MSG); + leave_crit (); return (bRet); } @@ -163,23 +119,26 @@ post_msg (lpmsg) { int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg)); - if (!lpNew) - return (FALSE); + if (!lpNew) return (FALSE); bcopy (lpmsg, &(lpNew->w32msg), sizeof (Win32Msg)); lpNew->lpNext = NULL; - enter_crit (CRIT_MSG); + enter_crit (); if (nQueue++) - lpTail->lpNext = lpNew; + { + lpTail->lpNext = lpNew; + } else - lpHead = lpNew; + { + lpHead = lpNew; + SetEvent (hEvent); + } lpTail = lpNew; - SetEvent (h_input_available); - leave_crit (CRIT_MSG); + leave_crit (); return (TRUE); }