comparison src/device-msw.c @ 213:78f53ef88e17 r20-4b5

Import from CVS: tag r20-4b5
author cvs
date Mon, 13 Aug 2007 10:06:47 +0200
parents
children d44af0c54775
comparison
equal deleted inserted replaced
212:d8688acf4c5b 213:78f53ef88e17
1 /* Device functions for mswindows.
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1994, 1995 Free Software Foundation, Inc.
4
5 This file is part of XEmacs.
6
7 XEmacs is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with XEmacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* Synched up with: Not in FSF. */
23
24 /* Authorship:
25
26 Original authors: Jamie Zawinski and the FSF
27 Rewritten by Ben Wing and Chuck Thompson.
28 Rewritten for mswindows by Jonathan Harris, November 1997 for 20.4.
29 */
30
31
32 #include <config.h>
33 #include "lisp.h"
34
35 #include "console-msw.h"
36 #include "console-stream.h"
37 #include "events.h"
38 #include "event-msw.h"
39 #include "faces.h"
40 #include "frame.h"
41
42 Lisp_Object Qinit_pre_mswindows_win, Qinit_post_mswindows_win;
43
44 DWORD mswindows_main_thread_id;
45 DWORD mswindows_win_thread_id;
46
47 static void
48 mswindows_init_device (struct device *d, Lisp_Object props)
49 {
50 struct console *con = XCONSOLE (DEVICE_CONSOLE (d));
51 HWND desktop;
52 HDC hdc;
53 MSG msg;
54 HANDLE handle;
55
56 DEVICE_INFD (d) = DEVICE_OUTFD (d) = -1;
57 init_baud_rate (d);
58 init_one_device (d);
59
60 /* Ensure our message queue is created */
61 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
62
63 mswindows_main_thread_id = GetCurrentThreadId ();
64 #if 0
65 DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
66 GetCurrentProcess (), &hMainThread, 0, TRUE, DUPLICATE_SAME_ACCESS);
67 #endif
68 handle = CreateThread (NULL, 0,
69 (LPTHREAD_START_ROUTINE) mswindows_win_thread,
70 0, 0, &mswindows_win_thread_id);
71 AttachThreadInput (mswindows_main_thread_id, mswindows_win_thread_id, TRUE);
72
73 d->device_data = xnew_and_zero (struct mswindows_device);
74
75 desktop = GetDesktopWindow();
76 hdc = GetDC(desktop);
77 DEVICE_MSWINDOWS_LOGPIXELSX(d) = GetDeviceCaps(hdc, LOGPIXELSX);
78 DEVICE_MSWINDOWS_LOGPIXELSY(d) = GetDeviceCaps(hdc, LOGPIXELSY);
79 DEVICE_MSWINDOWS_PLANES(d) = GetDeviceCaps(hdc, PLANES);
80 /* FIXME: Only valid if RC_PALETTE bit set in RASTERCAPS,
81 what should we return for a non-palette-based device? */
82 DEVICE_MSWINDOWS_CELLS(d) = GetDeviceCaps(hdc, SIZEPALETTE);
83 DEVICE_MSWINDOWS_HORZRES(d) = GetDeviceCaps(hdc, HORZRES);
84 DEVICE_MSWINDOWS_VERTRES(d) = GetDeviceCaps(hdc, VERTRES);
85 DEVICE_MSWINDOWS_HORZSIZE(d) = GetDeviceCaps(hdc, HORZSIZE);
86 DEVICE_MSWINDOWS_VERTSIZE(d) = GetDeviceCaps(hdc, VERTSIZE);
87 ReleaseDC(desktop, hdc);
88
89 /* Wait for windows thread to be ready */
90 GetMessage (&msg, NULL, WM_XEMACS_ACK, WM_XEMACS_ACK);
91 }
92
93 static int
94 mswindows_device_pixel_width (struct device *d)
95 {
96 return(DEVICE_MSWINDOWS_HORZRES(d));
97 }
98
99 static int
100 mswindows_device_pixel_height (struct device *d)
101 {
102 return(DEVICE_MSWINDOWS_VERTRES(d));
103 }
104
105 static int
106 mswindows_device_mm_width (struct device *d)
107 {
108 return(DEVICE_MSWINDOWS_HORZSIZE(d));
109 }
110
111 static int
112 mswindows_device_mm_height (struct device *d)
113 {
114 return(DEVICE_MSWINDOWS_VERTSIZE(d));
115 }
116
117 static int
118 mswindows_device_bitplanes (struct device *d)
119 {
120 return(DEVICE_MSWINDOWS_PLANES(d));
121 }
122
123 static int
124 mswindows_device_color_cells (struct device *d)
125 {
126 return(DEVICE_MSWINDOWS_CELLS(d));
127 }
128
129
130 /************************************************************************/
131 /* initialization */
132 /************************************************************************/
133
134 void
135 syms_of_device_mswindows (void)
136 {
137 defsymbol (&Qinit_pre_mswindows_win, "init-pre-mswindows-win");
138 defsymbol (&Qinit_post_mswindows_win, "init-post-mswindows-win");
139 }
140
141 void
142 console_type_create_device_mswindows (void)
143 {
144 CONSOLE_HAS_METHOD (mswindows, init_device);
145 /* CONSOLE_HAS_METHOD (mswindows, finish_init_device); */
146 /* CONSOLE_HAS_METHOD (mswindows, mark_device); */
147 /* CONSOLE_HAS_METHOD (mswindows, delete_device); */
148 CONSOLE_HAS_METHOD (mswindows, device_pixel_width);
149 CONSOLE_HAS_METHOD (mswindows, device_pixel_height);
150 CONSOLE_HAS_METHOD (mswindows, device_mm_width);
151 CONSOLE_HAS_METHOD (mswindows, device_mm_height);
152 CONSOLE_HAS_METHOD (mswindows, device_bitplanes);
153 CONSOLE_HAS_METHOD (mswindows, device_color_cells);
154 }
155
156 void
157 vars_of_device_mswindows (void)
158 {
159 }