annotate src/w32xfns.c @ 26088:b7aa6ac26872

Add support for large files, 64-bit Solaris, system locale codings. * Makefile.in (emacs): Set the LC_ALL environment variable to "C" when dumping, so that the dumped Emacs doesn't have stray locale info. (dired.o): Depend on systime.h. (editfns.o): Depend on coding.h. * alloc.c, buffer.c, callproc.c, ccl.c, charset.c, coding.c, data.c, dispnew.c, editfns.c, emacs.c, filelock.c, floatfns.c, hftctl.c, keyboard.c, process.c, sysdep.c, unexelf.c, unexhp9k800.c, unexsunos4.c, vmsfns.c, vmsgmalloc.c, w32faces.c, w32menu.c, w32term.c, w32xfns.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Include <config.h> before any system include files. * alloc.c, buffer.c, ccl.c, data.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, frame.c, insdel.c, keymap.c, lread.c, m/alpha.h, print.c, search.c, sysdep.c, xdisp.c, xfaces.c, xfns.c, xmenu.c, xterm.c: Do not include <stdlib.h>, as <config.h> does this now. * callproc.c (Fcall_process): Synchronize messages locale before invoking strerror. Decode resulting string with locale-coding-system. * coding.c (Vlocale_coding_system): New var. (syms_of_coding): Adjust to above change. (emacs_strerror): New function. * coding.h (emacs_strerror, Vlocale_coding_system): New decls. * config.in (HAVE_STDIO_EXT_H, HAVE_TM_GMTOFF, HAVE___FPENDING, HAVE_FTELLO, HAVE_GETLOADAVG, HAVE_MBLEN, HAVE_MBRLEN, HAVE_STRSIGNAL): New macros. (BITS_PER_LONG): Default to 64 if _LP64 is defined. <stdlib.h>: Include if HAVE_STDLIB_H is defined and NOT_C_CODE isn't. * dired.c: Include "systime.h". (Ffile_attributes): Do not cast s.st_size to int; this loses information if int is 32 bits but st_size and EMACS_INT are larger. Treat large device numbers like large inode numbers. * dispnew.c (PENDING_OUTPUT_COUNT): Use __fpending if available. * editfns.c: Include coding.h. (emacs_strftime): Remove decl. (emacs_strftimeu): New decl. (emacs_memftimeu): Renamed from emacs_memftime; new arg UT. Use emacs_strftimeu instead of emacs_strftime. (Fformat_time_string): Convert format string using Vlocale_coding_system, and convert result back. Synchronize time locale before invoking lower level function. Invoke emacs_memftimeu, passing ut, instead of emacs_memftime. * emacs.c: Include <locale.h> if HAVE_SETLOCALE is defined. (Vmessages_locale, Vprevious_messages_locale, Vtime_locale, Vprevious_time_locale): New variables. (main): Invoke setlocale early, so that initial error messages are localized properly. But skip locale-setting if LC_ALL is "C". Fix up locale when it's safe to do so. (fixup_locale): Moved here from xterm.c. (synchronize_locale, synchronize_time_locale, synchronize_messages_locale): New functions. (syms_of_emacs): Accommodate above changes. * fileio.c (report_file_error): Convert strerror output according to Vlocale_coding_system. (Finsert_file_contents): Check for arithmetic overflow in computations that depend on file size. Report IO errors with emacs_strerror, not strerror. * fns.c (Fgethash): Declare dflt parameter. * gmalloc.c: Do not define const to nothing if HAVE_CONFIG_H is defined; that's config.h's job. * lisp.h (EMACS_INT, BITS_PER_EMACS_INT, EMACS_UINT): If _LP64, default these values to long, BITS_PER_LONG, and unsigned long. (VALBITS, MARKBIT, XINT): Do not assume 32-bit EMACS_INT. (PNTR_COMPARISON_TYPE): Default to EMACS_UINT, not to unsigned int. (code_convert_string_norecord, fixup_locale, synchronize_messages_locale, synchronize_time_locale, emacs_open, emacs_close, emacs_read, emacs_write): New decls. All Emacs callers of open, close, read, write changed to use emacs_open, emacs_close, emacs_read, emacs_write. * lread.c (file_offset, file_tell): New macros. All uses of ftell changed to file_tell. (saved_doc_string_position, prev_saved_doc_string_position): Now of type file_offset. (init_lread): Do not fix locale here; fixup_locale now does this. * m/amdahl.h, s/usg5-4.h: (NSIG): Remove. (NSIG_MINIMUM): New macro. * m/cydra5.h, m/dpx2.h, m/mips.h, m/pfa50.h, m/sps7.h, m/stride.h, m/ustation.h, s/gnu-linux.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/umips.h, s/usg5-4.h: (SIGIO): Do not undef. (BROKEN_SIGIO): New macro. * m/ustation.h: (SIGTSTP): Do not undef. (BROKEN_SIGTSTP): New macro. * s/gnu-linux.h: (SIGPOLL, SIGURG): Do not undef. (BROKEN_SIGPOLL, BROKEN_SIGURG): New macros. * s/ptx4.h: (SIGINFO): Do not undef. (BROKEN_SIGINFO): New macros. * m/delta.h, s/ptx.h, s/template.h: Doc fix. * mktime.c, strftime.c: Update to glibc 2.1.2 version, with some Emacs-related changes merged. * print.c (float_to_string): Prepend "-" to representation of a NaN if the NaN is negative. * process.c (sys_siglist): Omit if HAVE_STRSIGNAL. (wait_reading_process_input): Use emacs_strerror, not strerror. * process.c (status_message, sigchld_handler): Synchronize locale, then use strsignal istead of sys_siglist. * w32proc.c (sys_wait): Likewise. * s/aix3-1.h, s/bsd4-1.h, s/dgux.h, s/gnu-linux.h, s/hiuxmpp.h, s/hpux.h, s/iris3-5.h, s/iris3-6.h, s/irix3-3.h, s/osf1.h, s/rtu.h, s/sunos4-1.h, s/unipl5-0.h, s/unipl5-2.h, s/usg5-0.h, s/usg5-2-2.h, s/usg5-2.h, s/usg5-3.h, s/xenix.h: (open, close, read, write, INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, INTERRUPTIBLE_IO): Remove. * s/sol2-5.h (_LARGEFILE_SOURCE, _FILE_OFFSET_BITS): New macros. * sysdep.c (sys_read, sys_write, read, write, sys_close, close, sys_open, open): Remove. (emacs_open, emacs_close, emacs_read, emacs_write): Always define; the old INTERRUPTIBLE_OPEN, INTERRUPTIBLE_CLOSE, and INTERRUPTIBLE_IO macros are no longer used. (emacs_open): Renamed from sys_open. Merge BSD4_1 version. (emacs_close): Renamed from sys_close. (emacs_read): Renamed from sys_read. (emacs_write): Renamed from sys_write. (sys_siglist): Do not declare if HAVE_STRSIGNAL. (dup2): Do not print error on failure; the real dup2 doesn't. (strsignal): New function, defined if !HAVE_STRSIGNAL. * syssignal.h (SIGINFO): Undef if defined and if BROKEN_SIGINFO is defined. (SIGIO, SIGPOLL, SIGTSTP, SIGURG): Likewise. (NSIG): If less than NSIG_MINIMUM, define to NSIG_MINIMUM. (strsignal): Declare if !HAVE_STRSIGNAL. * unexelf.c (ElfBitsW, ELFSIZE, ElfExpandBitsW): New macros. (ElfW): Define in terms of ElfExpandBitsW. * w32proc.c (sys_siglist): Remove decl. * xdisp.c (decode_mode_spec): 3rd arg is int, not char, to comply with ANSI C. (display_string): Declare face_string_pos arg. * xfns.c (Fx_show_tip): Declare timeout param. * xterm.c: No need to include locale.h. (x_alloc_lighter_color, x_setup_relief_color): Pass arg as double, not float, for compatibility with ANSI C. (fixup_locale): Move to emacs.c. (x_term_init): Do not setlocale or fixup locale; the main program does this now.
author Paul Eggert <eggert@twinsun.com>
date Tue, 19 Oct 1999 07:25:11 +0000
parents 600578f35004
children f390b90e3495
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16884
36babc489b0c Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents: 16588
diff changeset
1 /* Functions taken directly from X sources for use with the Microsoft W32 API.
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 24917
diff changeset
2 Copyright (C) 1989, 1992, 1993, 1994, 1995, 1999 Free Software Foundation.
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4 This file is part of GNU Emacs.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 any later version.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
10
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13866
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13866
diff changeset
19 Boston, MA 02111-1307, USA. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
20
26088
b7aa6ac26872 Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents: 24917
diff changeset
21 #include <config.h>
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
22 #include <signal.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
23 #include <stdio.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
24 #include "lisp.h"
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
25 #include "frame.h"
23509
afcb561b535d Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 22077
diff changeset
26 #include "charset.h"
afcb561b535d Include charset.h and fontset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 22077
diff changeset
27 #include "fontset.h"
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
28 #include "blockinput.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
29 #include "w32term.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
30 #include "windowsx.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
31
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
32 #define myalloc(cb) GlobalAllocPtr (GPTR, cb)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
33 #define myfree(lp) GlobalFreePtr (lp)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
34
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
35 CRITICAL_SECTION critsect;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
36 extern HANDLE keyboard_handle;
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
37 HANDLE input_available = NULL;
22077
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
38 HANDLE interrupt_handle = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
39
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
40 void
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
41 init_crit ()
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
42 {
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
43 InitializeCriticalSection (&critsect);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
44
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
45 /* For safety, input_available should only be reset by get_next_msg
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
46 when the input queue is empty, so make it a manual reset event. */
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
47 keyboard_handle = input_available = CreateEvent (NULL, TRUE, FALSE, NULL);
22077
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
48
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
49 /* interrupt_handle is signalled when quit (C-g) is detected, so that
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
50 blocking system calls can be interrupted. We make it a manual
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
51 reset event, so that if we should ever have multiple threads
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
52 performing system calls, they will all be interrupted (I'm guessing
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
53 that would the right response). Note that we use PulseEvent to
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
54 signal this event, so that it never remains signalled. */
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
55 interrupt_handle = CreateEvent (NULL, TRUE, FALSE, NULL);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
56 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
57
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
58 void
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
59 delete_crit ()
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
60 {
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
61 DeleteCriticalSection (&critsect);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
62
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
63 if (input_available)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
64 {
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
65 CloseHandle (input_available);
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
66 input_available = NULL;
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
67 }
22077
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
68 if (interrupt_handle)
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
69 {
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
70 CloseHandle (interrupt_handle);
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
71 interrupt_handle = NULL;
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
72 }
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
73 }
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
74
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
75 void
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
76 signal_quit ()
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
77 {
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
78 /* Make sure this event never remains signalled; if the main thread
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
79 isn't in a blocking call, then this should do nothing. */
ae5e3b23c7e2 (interrupt_handle): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 19715
diff changeset
80 PulseEvent (interrupt_handle);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
81 }
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
82
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
83 void
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
84 select_palette (FRAME_PTR f, HDC hdc)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
85 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
86 if (!NILP (Vw32_enable_palette))
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
87 f->output_data.w32->old_palette =
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
88 SelectPalette (hdc, one_w32_display_info.palette, FALSE);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
89 else
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
90 f->output_data.w32->old_palette = NULL;
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
91
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
92 if (RealizePalette (hdc))
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
93 {
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
94 Lisp_Object frame, framelist;
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
95 FOR_EACH_FRAME (framelist, frame)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
96 {
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
97 SET_FRAME_GARBAGED (XFRAME (frame));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
98 }
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
99 }
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
100 }
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
101
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
102 void
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
103 deselect_palette (FRAME_PTR f, HDC hdc)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
104 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
105 if (f->output_data.w32->old_palette)
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
106 SelectPalette (hdc, f->output_data.w32->old_palette, FALSE);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
107 }
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
108
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
109 /* Get a DC for frame and select palette for drawing; force an update of
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
110 all frames if palette's mapping changes. */
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
111 HDC
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
112 get_frame_dc (FRAME_PTR f)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
113 {
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
114 HDC hdc;
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
115
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
116 enter_crit ();
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
117
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
118 hdc = GetDC (f->output_data.w32->window_desc);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
119 select_palette (f, hdc);
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
120
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
121 return hdc;
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
122 }
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
123
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
124 int
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
125 release_frame_dc (FRAME_PTR f, HDC hdc)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
126 {
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
127 int ret;
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
128
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
129 deselect_palette (f, hdc);
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
130 ret = ReleaseDC (f->output_data.w32->window_desc, hdc);
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
131
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
132 leave_crit ();
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
133
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
134 return ret;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
135 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
136
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
137 typedef struct int_msg
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
138 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
139 W32Msg w32msg;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
140 struct int_msg *lpNext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
141 } int_msg;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
142
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
143 int_msg *lpHead = NULL;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
144 int_msg *lpTail = NULL;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
145 int nQueue = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
146
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
147 BOOL
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
148 get_next_msg (lpmsg, bWait)
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
149 W32Msg * lpmsg;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
150 BOOL bWait;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
151 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
152 BOOL bRet = FALSE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
153
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
154 enter_crit ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
155
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
156 /* The while loop takes care of multiple sets */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
157
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
158 while (!nQueue && bWait)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
159 {
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
160 leave_crit ();
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
161 WaitForSingleObject (input_available, INFINITE);
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
162 enter_crit ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
163 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
164
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
165 if (nQueue)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
166 {
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
167 bcopy (&(lpHead->w32msg), lpmsg, sizeof (W32Msg));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
168
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
169 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
170 int_msg * lpCur = lpHead;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
171
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
172 lpHead = lpHead->lpNext;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
173
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
174 myfree (lpCur);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
175 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
176
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
177 nQueue--;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
178
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
179 bRet = TRUE;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
180 }
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
181
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
182 if (nQueue == 0)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
183 ResetEvent (input_available);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
184
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
185 leave_crit ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
186
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
187 return (bRet);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
188 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
189
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
190 BOOL
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
191 post_msg (lpmsg)
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
192 W32Msg * lpmsg;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
193 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
194 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
195
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
196 if (!lpNew)
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
197 return (FALSE);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
198
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
199 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
200 lpNew->lpNext = NULL;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
201
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
202 enter_crit ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
203
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
204 if (nQueue++)
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
205 {
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
206 lpTail->lpNext = lpNew;
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
207 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
208 else
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
209 {
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
210 lpHead = lpNew;
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
211 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
212
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
213 lpTail = lpNew;
15153
c1494aa589e8 Include frame.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14460
diff changeset
214 SetEvent (input_available);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
215
14352
a05133ebf2bf backout 1,.4
Geoff Voelker <voelker@cs.washington.edu>
parents: 14239
diff changeset
216 leave_crit ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
217
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
218 return (TRUE);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
219 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
220
14460
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
221 BOOL
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
222 prepend_msg (W32Msg *lpmsg)
14460
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
223 {
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
224 int_msg * lpNew = (int_msg *) myalloc (sizeof (int_msg));
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
225
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
226 if (!lpNew)
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
227 return (FALSE);
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
228
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
229 bcopy (lpmsg, &(lpNew->w32msg), sizeof (W32Msg));
14460
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
230
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
231 enter_crit ();
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
232
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
233 nQueue++;
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
234 lpNew->lpNext = lpHead;
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
235 lpHead = lpNew;
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
236
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
237 leave_crit ();
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
238
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
239 return (TRUE);
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
240 }
61fc696a0c6a (prepend_msg): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14352
diff changeset
241
24917
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
242 /* Process all messages in the current thread's queue. */
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
243 void
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
244 drain_message_queue ()
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
245 {
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
246 MSG msg;
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
247 while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
248 {
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
249 TranslateMessage (&msg);
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
250 DispatchMessage (&msg);
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
251 }
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
252 }
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
253
600578f35004 (drain_message_queue): New function.
Andrew Innes <andrewi@gnu.org>
parents: 23509
diff changeset
254
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
255 /*
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
256 * XParseGeometry parses strings of the form
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
257 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
258 * width, height, xoffset, and yoffset are unsigned integers.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
259 * Example: "=80x24+300-49"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
260 * The equal sign is optional.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
261 * It returns a bitmask that indicates which of the four values
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
262 * were actually found in the string. For each value found,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
263 * the corresponding argument is updated; for each value
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
264 * not found, the corresponding argument is left unchanged.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
265 */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
266
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
267 static int
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
268 read_integer (string, NextString)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
269 register char *string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
270 char **NextString;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
271 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
272 register int Result = 0;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
273 int Sign = 1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
274
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
275 if (*string == '+')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
276 string++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
277 else if (*string == '-')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
278 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
279 string++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
280 Sign = -1;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
281 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
282 for (; (*string >= '0') && (*string <= '9'); string++)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
283 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
284 Result = (Result * 10) + (*string - '0');
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
285 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
286 *NextString = string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
287 if (Sign >= 0)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
288 return (Result);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
289 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
290 return (-Result);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
291 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
292
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
293 int
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
294 XParseGeometry (string, x, y, width, height)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
295 char *string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
296 int *x, *y;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
297 unsigned int *width, *height; /* RETURN */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
298 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
299 int mask = NoValue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
300 register char *strind;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
301 unsigned int tempWidth, tempHeight;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
302 int tempX, tempY;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
303 char *nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
304
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
305 if ((string == NULL) || (*string == '\0')) return (mask);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
306 if (*string == '=')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
307 string++; /* ignore possible '=' at beg of geometry spec */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
308
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
309 strind = (char *)string;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
310 if (*strind != '+' && *strind != '-' && *strind != 'x')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
311 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
312 tempWidth = read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
313 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
314 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
315 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
316 mask |= WidthValue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
317 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
318
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
319 if (*strind == 'x' || *strind == 'X')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
320 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
321 strind++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
322 tempHeight = read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
323 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
324 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
325 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
326 mask |= HeightValue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
327 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
328
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
329 if ((*strind == '+') || (*strind == '-'))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
330 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
331 if (*strind == '-')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
332 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
333 strind++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
334 tempX = -read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
335 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
336 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
337 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
338 mask |= XNegative;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
339
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
340 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
341 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
342 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
343 strind++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
344 tempX = read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
345 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
346 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
347 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
348 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
349 mask |= XValue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
350 if ((*strind == '+') || (*strind == '-'))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
351 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
352 if (*strind == '-')
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
353 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
354 strind++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
355 tempY = -read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
356 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
357 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
358 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
359 mask |= YNegative;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
360
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
361 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
362 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
363 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
364 strind++;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
365 tempY = read_integer (strind, &nextCharacter);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
366 if (strind == nextCharacter)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
367 return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
368 strind = nextCharacter;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
369 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
370 mask |= YValue;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
371 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
372 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
373
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
374 /* If strind isn't at the end of the string the it's an invalid
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
375 geometry specification. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
376
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
377 if (*strind != '\0') return (0);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
378
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
379 if (mask & XValue)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
380 *x = tempX;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
381 if (mask & YValue)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
382 *y = tempY;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
383 if (mask & WidthValue)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
384 *width = tempWidth;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
385 if (mask & HeightValue)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
386 *height = tempHeight;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
387 return (mask);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
388 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
389
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15153
diff changeset
390 /* x_sync is a no-op on W32. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
391 void
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
392 x_sync (f)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
393 void *f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
394 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
395 }