Merge from emacs--rel--22
[bpt/emacs.git] / lisp / term / w32-win.el
1 ;;; w32-win.el --- parse switches controlling interface with W32 window system
2
3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5
6 ;; Author: Kevin Gallo
7 ;; Keywords: terminals
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; w32-win.el: this file is loaded from ../lisp/startup.el when it recognizes
27 ;; that W32 windows are to be used. Command line switches are parsed and those
28 ;; pertaining to W32 are processed and removed from the command line. The
29 ;; W32 display is opened and hooks are set for popping up the initial window.
30
31 ;; startup.el will then examine startup files, and eventually call the hooks
32 ;; which create the first window (s).
33
34 ;;; Code:
35 \f
36
37 ;; These are the standard X switches from the Xt Initialize.c file of
38 ;; Release 4.
39
40 ;; Command line Resource Manager string
41
42 ;; +rv *reverseVideo
43 ;; +synchronous *synchronous
44 ;; -background *background
45 ;; -bd *borderColor
46 ;; -bg *background
47 ;; -bordercolor *borderColor
48 ;; -borderwidth .borderWidth
49 ;; -bw .borderWidth
50 ;; -display .display
51 ;; -fg *foreground
52 ;; -fn *font
53 ;; -font *font
54 ;; -foreground *foreground
55 ;; -geometry .geometry
56 ;; -i .iconType
57 ;; -itype .iconType
58 ;; -iconic .iconic
59 ;; -name .name
60 ;; -reverse *reverseVideo
61 ;; -rv *reverseVideo
62 ;; -selectionTimeout .selectionTimeout
63 ;; -synchronous *synchronous
64 ;; -xrm
65
66 ;; An alist of X options and the function which handles them. See
67 ;; ../startup.el.
68
69 ;; (if (not (eq window-system 'w32))
70 ;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
71
72 (require 'frame)
73 (require 'mouse)
74 (require 'scroll-bar)
75 (require 'faces)
76 (require 'select)
77 (require 'menu-bar)
78 (require 'dnd)
79 (require 'w32-vars)
80
81 ;; Keep an obsolete alias for w32-focus-frame and w32-select-font in case
82 ;; they are used by code outside Emacs.
83 (define-obsolete-function-alias 'w32-focus-frame 'x-focus-frame "23.1")
84 (define-obsolete-function-alias 'w32-select-font 'x-select-font "23.1")
85
86 (defvar xlfd-regexp-registry-subnum)
87 (defvar w32-color-map) ;; defined in w32fns.c
88
89 (declare-function w32-send-sys-command "w32fns.c")
90 (declare-function set-message-beep "w32console.c")
91
92 ;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
93 (if (fboundp 'new-fontset)
94 (require 'fontset))
95
96 ;; The following definition is used for debugging scroll bar events.
97 ;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))
98
99 (defun w32-drag-n-drop-debug (event)
100 "Print the drag-n-drop EVENT in a readable form."
101 (interactive "e")
102 (princ event))
103
104 (defun w32-drag-n-drop (event)
105 "Edit the files listed in the drag-n-drop EVENT.
106 Switch to a buffer editing the last file dropped."
107 (interactive "e")
108 (save-excursion
109 ;; Make sure the drop target has positive co-ords
110 ;; before setting the selected frame - otherwise it
111 ;; won't work. <skx@tardis.ed.ac.uk>
112 (let* ((window (posn-window (event-start event)))
113 (coords (posn-x-y (event-start event)))
114 (x (car coords))
115 (y (cdr coords)))
116 (if (and (> x 0) (> y 0))
117 (set-frame-selected-window nil window))
118 (mapc (lambda (file-name)
119 (let ((f (subst-char-in-string ?\\ ?/ file-name))
120 (coding (or file-name-coding-system
121 default-file-name-coding-system)))
122 (setq file-name
123 (mapconcat 'url-hexify-string
124 (split-string (encode-coding-string f coding)
125 "/")
126 "/")))
127 (dnd-handle-one-url window 'private
128 (concat "file:" file-name)))
129 (car (cdr (cdr event)))))
130 (raise-frame)))
131
132 (defun w32-drag-n-drop-other-frame (event)
133 "Edit the files listed in the drag-n-drop EVENT, in other frames.
134 May create new frames, or reuse existing ones. The frame editing
135 the last file dropped is selected."
136 (interactive "e")
137 (mapcar 'find-file-other-frame (car (cdr (cdr event)))))
138
139 ;; Bind the drag-n-drop event.
140 (global-set-key [drag-n-drop] 'w32-drag-n-drop)
141 (global-set-key [C-drag-n-drop] 'w32-drag-n-drop-other-frame)
142
143 ;; Keyboard layout/language change events
144 ;; For now ignore language-change events; in the future
145 ;; we should switch the Emacs Input Method to match the
146 ;; new layout/language selected by the user.
147 (global-set-key [language-change] 'ignore)
148
149 (defvar x-invocation-args)
150
151 (defvar x-command-line-resources nil)
152
153 (defun x-handle-switch (switch)
154 "Handle SWITCH of the form \"-switch value\" or \"-switch\"."
155 (let ((aelt (assoc switch command-line-x-option-alist)))
156 (if aelt
157 (let ((param (nth 3 aelt))
158 (value (nth 4 aelt)))
159 (if value
160 (setq default-frame-alist
161 (cons (cons param value)
162 default-frame-alist))
163 (setq default-frame-alist
164 (cons (cons param
165 (car x-invocation-args))
166 default-frame-alist)
167 x-invocation-args (cdr x-invocation-args)))))))
168
169 (defun x-handle-numeric-switch (switch)
170 "Handle SWITCH of the form \"-switch n\"."
171 (let ((aelt (assoc switch command-line-x-option-alist)))
172 (if aelt
173 (let ((param (nth 3 aelt)))
174 (setq default-frame-alist
175 (cons (cons param
176 (string-to-number (car x-invocation-args)))
177 default-frame-alist)
178 x-invocation-args
179 (cdr x-invocation-args))))))
180
181 ;; Handle options that apply to initial frame only
182 (defun x-handle-initial-switch (switch)
183 (let ((aelt (assoc switch command-line-x-option-alist)))
184 (if aelt
185 (let ((param (nth 3 aelt))
186 (value (nth 4 aelt)))
187 (if value
188 (setq initial-frame-alist
189 (cons (cons param value)
190 initial-frame-alist))
191 (setq initial-frame-alist
192 (cons (cons param
193 (car x-invocation-args))
194 initial-frame-alist)
195 x-invocation-args (cdr x-invocation-args)))))))
196
197 (defun x-handle-iconic (switch)
198 "Make \"-iconic\" SWITCH apply only to the initial frame."
199 (setq default-frame-alist (cons '(icon-type) default-frame-alist)))
200
201 (defun x-handle-xrm-switch (switch)
202 "Handle the \"-xrm\" SWITCH."
203 (unless (consp x-invocation-args)
204 (error "%s: missing argument to `%s' option" (invocation-name) switch))
205 (setq x-command-line-resources
206 (if (null x-command-line-resources)
207 (car x-invocation-args)
208 (concat x-command-line-resources "\n" (car x-invocation-args))))
209 (setq x-invocation-args (cdr x-invocation-args)))
210
211 (declare-function x-parse-geometry "frame.c" (string))
212
213 (defun x-handle-geometry (switch)
214 "Handle the \"-geometry\" SWITCH."
215 (let* ((geo (x-parse-geometry (car x-invocation-args)))
216 (left (assq 'left geo))
217 (top (assq 'top geo))
218 (height (assq 'height geo))
219 (width (assq 'width geo)))
220 (if (or height width)
221 (setq default-frame-alist
222 (append default-frame-alist
223 '((user-size . t))
224 (if height (list height))
225 (if width (list width)))
226 initial-frame-alist
227 (append initial-frame-alist
228 '((user-size . t))
229 (if height (list height))
230 (if width (list width)))))
231 (if (or left top)
232 (setq initial-frame-alist
233 (append initial-frame-alist
234 '((user-position . t))
235 (if left (list left))
236 (if top (list top)))))
237 (setq x-invocation-args (cdr x-invocation-args))))
238
239 (defvar x-resource-name)
240
241 (defun x-handle-name-switch (switch)
242 "Handle the \"-name\" SWITCH."
243 ;; Handle the -name option. Set the variable x-resource-name
244 ;; to the option's operand; set the name of the initial frame, too.
245 (or (consp x-invocation-args)
246 (error "%s: missing argument to `%s' option" (invocation-name) switch))
247 (setq x-resource-name (car x-invocation-args)
248 x-invocation-args (cdr x-invocation-args))
249 (setq initial-frame-alist (cons (cons 'name x-resource-name)
250 initial-frame-alist)))
251
252 (defvar x-display-name nil
253 "The display name specifying server and frame.")
254
255 (defun x-handle-display (switch)
256 "Handle the \"-display\" SWITCH."
257 (setq x-display-name (car x-invocation-args)
258 x-invocation-args (cdr x-invocation-args))
259 ;; Make subshell programs see the same DISPLAY value Emacs really uses.
260 ;; Note that this isn't completely correct, since Emacs can use
261 ;; multiple displays. However, there is no way to tell an already
262 ;; running subshell which display the user is currently typing on.
263
264 ;; On Windows, this will not have any affect on Windows programs,
265 ;; but might be useful for X programs (running under Cygwin, tramp etc).
266 (setenv "DISPLAY" x-display-name))
267
268 (defun x-handle-args (args)
269 "Process the X-related command line options in ARGS.
270 This is done before the user's startup file is loaded. They are copied to
271 `x-invocation args' from which the X-related things are extracted, first
272 the switch (e.g., \"-fg\") in the following code, and possible values
273 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
274 This returns ARGS with the arguments that have been processed removed."
275 ;; We use ARGS to accumulate the args that we don't handle here, to return.
276 (setq x-invocation-args args
277 args nil)
278 (while (and x-invocation-args
279 (not (equal (car x-invocation-args) "--")))
280 (let* ((this-switch (car x-invocation-args))
281 (orig-this-switch this-switch)
282 completion argval aelt handler)
283 (setq x-invocation-args (cdr x-invocation-args))
284 ;; Check for long options with attached arguments
285 ;; and separate out the attached option argument into argval.
286 (if (string-match "^--[^=]*=" this-switch)
287 (setq argval (substring this-switch (match-end 0))
288 this-switch (substring this-switch 0 (1- (match-end 0)))))
289 ;; Complete names of long options.
290 (if (string-match "^--" this-switch)
291 (progn
292 (setq completion (try-completion this-switch command-line-x-option-alist))
293 (if (eq completion t)
294 ;; Exact match for long option.
295 nil
296 (if (stringp completion)
297 (let ((elt (assoc completion command-line-x-option-alist)))
298 ;; Check for abbreviated long option.
299 (or elt
300 (error "Option `%s' is ambiguous" this-switch))
301 (setq this-switch completion))))))
302 (setq aelt (assoc this-switch command-line-x-option-alist))
303 (if aelt (setq handler (nth 2 aelt)))
304 (if handler
305 (if argval
306 (let ((x-invocation-args
307 (cons argval x-invocation-args)))
308 (funcall handler this-switch))
309 (funcall handler this-switch))
310 (setq args (cons orig-this-switch args)))))
311 (nconc (nreverse args) x-invocation-args))
312 \f
313 ;;
314 ;; Available colors
315 ;;
316 ;; The ordering of the colors is chosen for the user's convenience in
317 ;; `list-colors-display', which displays the reverse of this list.
318 ;; Roughly speaking, `list-colors-display' orders by (i) named shades
319 ;; of grey with hue 0.0, sorted by value (ii) named colors with
320 ;; saturation 1.0, sorted by hue, (iii) named non-white colors with
321 ;; saturation less than 1.0, sorted by hue, (iv) other named shades of
322 ;; white, (v) numbered colors sorted by hue, and (vi) numbered shades
323 ;; of grey.
324
325 (defvar x-colors
326 '("gray100" "gray99" "gray98" "gray97" "gray96" "gray95" "gray94" "gray93" "gray92"
327 "gray91" "gray90" "gray89" "gray88" "gray87" "gray86" "gray85" "gray84" "gray83"
328 "gray82" "gray81" "gray80" "gray79" "gray78" "gray77" "gray76" "gray75" "gray74"
329 "gray73" "gray72" "gray71" "gray70" "gray69" "gray68" "gray67" "gray66" "gray65"
330 "gray64" "gray63" "gray62" "gray61" "gray60" "gray59" "gray58" "gray57" "gray56"
331 "gray55" "gray54" "gray53" "gray52" "gray51" "gray50" "gray49" "gray48" "gray47"
332 "gray46" "gray45" "gray44" "gray43" "gray42" "gray41" "gray40" "gray39" "gray38"
333 "gray37" "gray36" "gray35" "gray34" "gray33" "gray32" "gray31" "gray30" "gray29"
334 "gray28" "gray27" "gray26" "gray25" "gray24" "gray23" "gray22" "gray21" "gray20"
335 "gray19" "gray18" "gray17" "gray16" "gray15" "gray14" "gray13" "gray12" "gray11"
336 "gray10" "gray9" "gray8" "gray7" "gray6" "gray5" "gray4" "gray3" "gray2" "gray1"
337 "gray0" "LightPink1" "LightPink2" "LightPink3" "LightPink4" "pink1" "pink2" "pink3"
338 "pink4" "PaleVioletRed1" "PaleVioletRed2" "PaleVioletRed3" "PaleVioletRed4"
339 "LavenderBlush1" "LavenderBlush2" "LavenderBlush3" "LavenderBlush4" "VioletRed1"
340 "VioletRed2" "VioletRed3" "VioletRed4" "HotPink1" "HotPink2" "HotPink3" "HotPink4"
341 "DeepPink1" "DeepPink2" "DeepPink3" "DeepPink4" "maroon1" "maroon2" "maroon3"
342 "maroon4" "orchid1" "orchid2" "orchid3" "orchid4" "plum1" "plum2" "plum3" "plum4"
343 "thistle1" "thistle2" "thistle3" "thistle4" "MediumOrchid1" "MediumOrchid2"
344 "MediumOrchid3" "MediumOrchid4" "DarkOrchid1" "DarkOrchid2" "DarkOrchid3"
345 "DarkOrchid4" "purple1" "purple2" "purple3" "purple4" "MediumPurple1"
346 "MediumPurple2" "MediumPurple3" "MediumPurple4" "SlateBlue1" "SlateBlue2"
347 "SlateBlue3" "SlateBlue4" "RoyalBlue1" "RoyalBlue2" "RoyalBlue3" "RoyalBlue4"
348 "LightSteelBlue1" "LightSteelBlue2" "LightSteelBlue3" "LightSteelBlue4" "SlateGray1"
349 "SlateGray2" "SlateGray3" "SlateGray4" "DodgerBlue1" "DodgerBlue2" "DodgerBlue3"
350 "DodgerBlue4" "SteelBlue1" "SteelBlue2" "SteelBlue3" "SteelBlue4" "SkyBlue1"
351 "SkyBlue2" "SkyBlue3" "SkyBlue4" "LightSkyBlue1" "LightSkyBlue2" "LightSkyBlue3"
352 "LightSkyBlue4" "LightBlue1" "LightBlue2" "LightBlue3" "LightBlue4" "CadetBlue1"
353 "CadetBlue2" "CadetBlue3" "CadetBlue4" "azure1" "azure2" "azure3" "azure4"
354 "LightCyan1" "LightCyan2" "LightCyan3" "LightCyan4" "PaleTurquoise1"
355 "PaleTurquoise2" "PaleTurquoise3" "PaleTurquoise4" "DarkSlateGray1" "DarkSlateGray2"
356 "DarkSlateGray3" "DarkSlateGray4" "aquamarine1" "aquamarine2" "aquamarine3"
357 "aquamarine4" "SeaGreen1" "SeaGreen2" "SeaGreen3" "SeaGreen4" "honeydew1"
358 "honeydew2" "honeydew3" "honeydew4" "DarkSeaGreen1" "DarkSeaGreen2" "DarkSeaGreen3"
359 "DarkSeaGreen4" "PaleGreen1" "PaleGreen2" "PaleGreen3" "PaleGreen4"
360 "DarkOliveGreen1" "DarkOliveGreen2" "DarkOliveGreen3" "DarkOliveGreen4" "OliveDrab1"
361 "OliveDrab2" "OliveDrab3" "OliveDrab4" "ivory1" "ivory2" "ivory3" "ivory4"
362 "LightYellow1" "LightYellow2" "LightYellow3" "LightYellow4" "khaki1" "khaki2"
363 "khaki3" "khaki4" "LemonChiffon1" "LemonChiffon2" "LemonChiffon3" "LemonChiffon4"
364 "LightGoldenrod1" "LightGoldenrod2" "LightGoldenrod3" "LightGoldenrod4" "cornsilk1"
365 "cornsilk2" "cornsilk3" "cornsilk4" "goldenrod1" "goldenrod2" "goldenrod3"
366 "goldenrod4" "DarkGoldenrod1" "DarkGoldenrod2" "DarkGoldenrod3" "DarkGoldenrod4"
367 "wheat1" "wheat2" "wheat3" "wheat4" "NavajoWhite1" "NavajoWhite2" "NavajoWhite3"
368 "NavajoWhite4" "burlywood1" "burlywood2" "burlywood3" "burlywood4" "AntiqueWhite1"
369 "AntiqueWhite2" "AntiqueWhite3" "AntiqueWhite4" "bisque1" "bisque2" "bisque3"
370 "bisque4" "tan1" "tan2" "tan3" "tan4" "PeachPuff1" "PeachPuff2" "PeachPuff3"
371 "PeachPuff4" "seashell1" "seashell2" "seashell3" "seashell4" "chocolate1"
372 "chocolate2" "chocolate3" "chocolate4" "sienna1" "sienna2" "sienna3" "sienna4"
373 "LightSalmon1" "LightSalmon2" "LightSalmon3" "LightSalmon4" "salmon1" "salmon2"
374 "salmon3" "salmon4" "coral1" "coral2" "coral3" "coral4" "tomato1" "tomato2"
375 "tomato3" "tomato4" "MistyRose1" "MistyRose2" "MistyRose3" "MistyRose4" "snow1"
376 "snow2" "snow3" "snow4" "RosyBrown1" "RosyBrown2" "RosyBrown3" "RosyBrown4"
377 "IndianRed1" "IndianRed2" "IndianRed3" "IndianRed4" "firebrick1" "firebrick2"
378 "firebrick3" "firebrick4" "brown1" "brown2" "brown3" "brown4" "magenta1" "magenta2"
379 "magenta3" "magenta4" "blue1" "blue2" "blue3" "blue4" "DeepSkyBlue1" "DeepSkyBlue2"
380 "DeepSkyBlue3" "DeepSkyBlue4" "turquoise1" "turquoise2" "turquoise3" "turquoise4"
381 "cyan1" "cyan2" "cyan3" "cyan4" "SpringGreen1" "SpringGreen2" "SpringGreen3"
382 "SpringGreen4" "green1" "green2" "green3" "green4" "chartreuse1" "chartreuse2"
383 "chartreuse3" "chartreuse4" "yellow1" "yellow2" "yellow3" "yellow4" "gold1" "gold2"
384 "gold3" "gold4" "orange1" "orange2" "orange3" "orange4" "DarkOrange1" "DarkOrange2"
385 "DarkOrange3" "DarkOrange4" "OrangeRed1" "OrangeRed2" "OrangeRed3" "OrangeRed4"
386 "red1" "red2" "red3" "red4" "lavender blush" "ghost white" "lavender" "alice blue"
387 "azure" "light cyan" "mint cream" "honeydew" "ivory" "light goldenrod yellow"
388 "light yellow" "beige" "floral white" "old lace" "blanched almond" "moccasin"
389 "papaya whip" "bisque" "antique white" "linen" "peach puff" "seashell" "misty rose"
390 "snow" "light pink" "pink" "hot pink" "deep pink" "maroon" "pale violet red"
391 "violet red" "medium violet red" "violet" "plum" "thistle" "orchid" "medium orchid"
392 "dark orchid" "purple" "blue violet" "medium purple" "light slate blue"
393 "medium slate blue" "slate blue" "dark slate blue" "midnight blue" "navy"
394 "dark blue" "light steel blue" "cornflower blue" "dodger blue" "royal blue"
395 "light slate gray" "slate gray" "dark slate gray" "steel blue" "cadet blue"
396 "light sky blue" "sky blue" "light blue" "powder blue" "pale turquoise" "turquoise"
397 "medium turquoise" "dark cyan" "aquamarine" "medium aquamarine" "light sea green"
398 "medium sea green" "sea green" "dark sea green" "pale green" "lime green"
399 "forest green" "light green" "green yellow" "yellow green" "olive drab"
400 "dark olive green" "lemon chiffon" "khaki" "dark khaki" "cornsilk"
401 "pale goldenrod" "light goldenrod" "goldenrod" "dark goldenrod" "wheat"
402 "navajo white" "tan" "burlywood" "sandy brown" "peru" "chocolate" "saddle brown"
403 "sienna" "rosy brown" "dark salmon" "coral" "tomato" "light salmon" "salmon"
404 "light coral" "indian red" "firebrick" "brown" "dark red" "magenta"
405 "dark magenta" "dark violet" "medium blue" "blue" "deep sky blue"
406 "cyan" "medium spring green" "spring green" "green" "lawn green" "chartreuse"
407 "yellow" "gold" "orange" "dark orange" "orange red" "red" "white" "white smoke"
408 "gainsboro" "light grey" "gray" "dark grey" "dim gray" "black" )
409 "The list of X colors from the `rgb.txt' file.
410 XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
411
412 (defun xw-defined-colors (&optional frame)
413 "Internal function called by `defined-colors', which see."
414 (or frame (setq frame (selected-frame)))
415 (let ((defined-colors nil))
416 (dolist (this-color (or (mapcar 'car w32-color-map) x-colors))
417 (and (color-supported-p this-color frame t)
418 (setq defined-colors (cons this-color defined-colors))))
419 defined-colors))
420 \f
421 \f
422 ;;;; Function keys
423
424 ;;; make f10 activate the real menubar rather than the mini-buffer menu
425 ;;; navigation feature.
426 (defun w32-menu-bar-open (&optional frame)
427 "Start key navigation of the menu bar in FRAME.
428
429 This initially activates the first menu-bar item, and you can then navigate
430 with the arrow keys, select a menu entry with the Return key or cancel with
431 the Escape key. If FRAME has no menu bar, this function does nothing.
432
433 If FRAME is nil or not given, use the selected frame.
434 If FRAME does not have the menu bar enabled, display a text menu using
435 `tmm-menubar'."
436 (interactive "i")
437 (if menu-bar-mode
438 (w32-send-sys-command ?\xf100 frame)
439 (with-selected-frame (or frame (selected-frame))
440 (tmm-menubar))))
441 \f
442
443 ;; W32 systems have different fonts than commonly found on X, so
444 ;; we define our own standard fontset here.
445 (defvar w32-standard-fontset-spec
446 "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-standard"
447 "String of fontset spec of the standard fontset.
448 This defines a fontset consisting of the Courier New variations for
449 European languages which are distributed with Windows as
450 \"Multilanguage Support\".
451
452 See the documentation of `create-fontset-from-fontset-spec' for the format.")
453
454 (defun x-win-suspend-error ()
455 "Report an error when a suspend is attempted."
456 (error "Suspending an Emacs running under W32 makes no sense"))
457
458 (defvar image-library-alist)
459
460 ;;; Set default known names for image libraries
461 (setq image-library-alist
462 '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll")
463 (png "libpng12d.dll" "libpng12.dll" "libpng.dll"
464 ;; these are libpng 1.2.8 from GTK+
465 "libpng13d.dll" "libpng13.dll")
466 (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
467 (tiff "libtiff3.dll" "libtiff.dll")
468 (gif "giflib4.dll" "libungif4.dll" "libungif.dll")
469 (svg "librsvg-2-2.dll")
470 (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
471 (glib "libglib-2.0-0.dll")))
472
473 ;;; multi-tty support
474 (defvar w32-initialized nil
475 "Non-nil if the w32 window system has been initialized.")
476
477 (declare-function x-open-connection "w32fns.c"
478 (display &optional xrm-string must-succeed))
479
480 (declare-function setup-default-fontset "fontset" ())
481 (declare-function set-fontset-font "fontset.c"
482 (name target font-spec &optional frame add))
483 (declare-function setup-default-fontset "fontset" ())
484 (declare-function create-fontset-from-fontset-spec "fontset"
485 (fontset-spec &optional style-variant noerror))
486 (declare-function create-fontset-from-x-resource "fontset" ())
487 (declare-function x-get-resource "frame.c"
488 (attribute class &optional component subclass))
489
490 (defun w32-initialize-window-system ()
491 "Initialize Emacs for W32 GUI frames."
492
493 ;; Do the actual Windows setup here; the above code just defines
494 ;; functions and variables that we use now.
495
496 (setq command-line-args (x-handle-args command-line-args))
497
498 ;; Make sure we have a valid resource name.
499 (or (stringp x-resource-name)
500 (setq x-resource-name
501 ;; Change any . or * characters in x-resource-name to hyphens,
502 ;; so as not to choke when we use it in X resource queries.
503 (replace-regexp-in-string "[.*]" "-" (invocation-name))))
504
505 (x-open-connection "" x-command-line-resources
506 ;; Exit with a fatal error if this fails and we
507 ;; are the initial display
508 (eq initial-window-system 'w32))
509
510 ;; Setup the default fontset.
511 (setup-default-fontset)
512
513 ;; Enable Japanese fonts on Windows to be used by default.
514 (set-fontset-font t (make-char 'katakana-jisx0201)
515 '("*" . "JISX0208-SJIS"))
516 (set-fontset-font t (make-char 'latin-jisx0201)
517 '("*" . "JISX0208-SJIS"))
518 (set-fontset-font t (make-char 'japanese-jisx0208)
519 '("*" . "JISX0208-SJIS"))
520 (set-fontset-font t (make-char 'japanese-jisx0208-1978)
521 '("*" . "JISX0208-SJIS"))
522
523 ;; Create the standard fontset.
524 (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
525 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
526 (create-fontset-from-x-resource)
527
528 ;; Apply a geometry resource to the initial frame. Put it at the end
529 ;; of the alist, so that anything specified on the command line takes
530 ;; precedence.
531 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
532 parsed)
533 (if res-geometry
534 (progn
535 (setq parsed (x-parse-geometry res-geometry))
536 ;; If the resource specifies a position,
537 ;; call the position and size "user-specified".
538 (if (or (assq 'top parsed) (assq 'left parsed))
539 (setq parsed (cons '(user-position . t)
540 (cons '(user-size . t) parsed))))
541 ;; All geometry parms apply to the initial frame.
542 (setq initial-frame-alist (append initial-frame-alist parsed))
543 ;; The size parms apply to all frames.
544 (if (and (assq 'height parsed)
545 (not (assq 'height default-frame-alist)))
546 (setq default-frame-alist
547 (cons (cons 'height (cdr (assq 'height parsed)))
548 default-frame-alist))
549 (if (and (assq 'width parsed)
550 (not (assq 'width default-frame-alist)))
551 (setq default-frame-alist
552 (cons (cons 'width (cdr (assq 'width parsed)))
553 default-frame-alist)))))))
554
555 ;; Check the reverseVideo resource.
556 (let ((case-fold-search t))
557 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
558 (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
559 (setq default-frame-alist
560 (cons '(reverse . t) default-frame-alist)))))
561
562 ;; Don't let Emacs suspend under w32 gui
563 (add-hook 'suspend-hook 'x-win-suspend-error)
564
565 ;; Turn off window-splitting optimization; w32 is usually fast enough
566 ;; that this is only annoying.
567 (setq split-window-keep-point t)
568
569 ;; Turn on support for mouse wheels
570 (mouse-wheel-mode 1)
571
572 ;; W32 expects the menu bar cut and paste commands to use the clipboard.
573 (menu-bar-enable-clipboard)
574
575 ;; Don't show the frame name; that's redundant.
576 (setq-default mode-line-frame-identification " ")
577
578 ;; Set to a system sound if you want a fancy bell.
579 (set-message-beep 'ok)
580 (setq w32-initialized t))
581
582 (add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
583 (add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
584 (add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system))
585
586 (provide 'w32-win)
587
588 ;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
589 ;;; w32-win.el ends here