aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2004-01-22 02:36:55 +0000
committerKaroly Lorentey2004-01-22 02:36:55 +0000
commite9cda8277618ce4e2644e852539474b7b67f09e3 (patch)
treeca87f4bef3d3f98379211ea69f1fb3c26452a540
parent990e879437236fc76e827d6191899c117f01fd99 (diff)
downloademacs-e9cda8277618ce4e2644e852539474b7b67f09e3.tar.gz
emacs-e9cda8277618ce4e2644e852539474b7b67f09e3.zip
Romain Francoise's and Ami Fischman's bugfixes.
src/term.c (create_tty_output): Fix syntax error. Reported by Ami Fischman (ami at fischman dot org). lisp/loadup.el: Load term/x-win.el if X is available. lisp/startup.el (handle-args-function-alist) (window-system-initialization-alist): New variables. (command-line): Don't load term/x-win.el, use the above variables. lisp/x-win.el: (x-initialize-window-system): New function, move X initialization here. (x-initialized): New variable. lisp/frame.el (make-frame-on-display): Don't initialize X twice, and make sure to pass the correct display parameter to x-open-connection. Reported by Romain Francoise (romain at orebokech dot com). git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-58
-rw-r--r--README.multi-tty2
-rw-r--r--lisp/frame.el4
-rw-r--r--lisp/loadup.el7
-rw-r--r--lisp/startup.el41
-rw-r--r--lisp/term/x-win.el261
-rw-r--r--src/term.c4
6 files changed, 181 insertions, 138 deletions
diff --git a/README.multi-tty b/README.multi-tty
index 42e1867d98e..70d0fd12180 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -140,6 +140,8 @@ See arch logs.
140THINGS TO DO 140THINGS TO DO
141------------ 141------------
142 142
143** emacs -nw --eval '(y-or-n-p "Foobar")' segfaults.
144
143** Fix color handling during tty+X combo sessions. (It seems that tty 145** Fix color handling during tty+X combo sessions. (It seems that tty
144 sessions automatically convert the face colors to terminal colors 146 sessions automatically convert the face colors to terminal colors
145 when the face is loaded. This conversion must happen instead on 147 when the face is loaded. This conversion must happen instead on
diff --git a/lisp/frame.el b/lisp/frame.el
index f374f838696..8d76c7b70ba 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -570,7 +570,9 @@ The optional second argument PARAMETERS specifies additional frame parameters."
570 (interactive "sMake frame on display: ") 570 (interactive "sMake frame on display: ")
571 (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display) 571 (or (string-match "\\`[^:]*:[0-9]+\\(\\.[0-9]+\\)?\\'" display)
572 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN")) 572 (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
573 (load (concat term-file-prefix "x-win")) 573 (unless x-initialized
574 (setq x-display-name display)
575 (x-initialize-window-system))
574 (make-frame `((window-system . x) (display . ,display) . ,parameters))) 576 (make-frame `((window-system . x) (display . ,display) . ,parameters)))
575 577
576(defun make-frame-on-tty (device type &optional parameters) 578(defun make-frame-on-tty (device type &optional parameters)
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 26f7b34108a..c64df547582 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -190,6 +190,13 @@
190 (load "emacs-lisp/float-sup"))) 190 (load "emacs-lisp/float-sup")))
191(message "%s" (garbage-collect)) 191(message "%s" (garbage-collect))
192 192
193(when (fboundp 'x-create-frame)
194 (load "mouse")
195 (load "international/fontset")
196 (load "term/x-win"))
197
198(message "%s" (garbage-collect))
199
193(load "vc-hooks") 200(load "vc-hooks")
194(load "ediff-hook") 201(load "ediff-hook")
195(message "%s" (garbage-collect)) 202(message "%s" (garbage-collect))
diff --git a/lisp/startup.el b/lisp/startup.el
index 969daf49777..baf87e75ae2 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -590,6 +590,20 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
590(defvar tool-bar-originally-present nil 590(defvar tool-bar-originally-present nil
591 "Non-nil if tool-bars are present before user and site init files are read.") 591 "Non-nil if tool-bars are present before user and site init files are read.")
592 592
593(defvar handle-args-function-alist '((nil . tty-handle-args))
594 "Functions for processing window-system dependent command-line arguments.
595Window system startup files should add their own function to this
596alist, which should parse the command line arguments. Those
597pertaining to the window system should be processed and removed
598from the returned command line.")
599
600(defvar window-system-initialization-alist '((nil . ignore))
601 "Alist of window-system initialization functions.
602Window-system startup files should add their own initialization
603function to this list. The function should take no arguments,
604and initialize the window system environment to prepare for
605opening the first frame (e.g. open a connection to the server).")
606
593;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc. 607;; Handle the X-like command-line arguments "-fg", "-bg", "-name", etc.
594(defun tty-handle-args (args) 608(defun tty-handle-args (args)
595 (let (rest) 609 (let (rest)
@@ -709,14 +723,21 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
709 723
710 ;; Read window system's init file if using a window system. 724 ;; Read window system's init file if using a window system.
711 (condition-case error 725 (condition-case error
712 (if (and initial-window-system (not noninteractive)) 726 (unless noninteractive
713 (load (concat term-file-prefix 727 (if (and initial-window-system
714 (symbol-name initial-window-system) 728 (not (featurep
715 "-win") 729 (intern (concat (symbol-name initial-window-system)
716 ;; Every window system should have a startup file; 730 "-win")))))
717 ;; barf if we can't find it. 731 (error "Unsupported window system `%s'" initial-window-system))
718 nil t)) 732 ;; Process window-system specific command line parameters.
719 ;; If we can't read it, print the error message and exit. 733 (setq command-line-args
734 (funcall (or (cdr (assq initial-window-system handle-args-function-alist))
735 (error "Unsupported window system `%s'" initial-window-system))
736 command-line-args))
737 ;; Initialize the window system. (Open connection, etc.)
738 (funcall (or (cdr (assq initial-window-system window-system-initialization-alist))
739 (error "Unsupported window system `%s'" initial-window-system))))
740 ;; If there was an error, print the error message and exit.
720 (error 741 (error
721 (princ 742 (princ
722 (if (eq (car error) 'error) 743 (if (eq (car error) 'error)
@@ -735,10 +756,6 @@ or `CVS', and any subdirectory that contains a file named `.nosearch'."
735 (setq initial-window-system nil) 756 (setq initial-window-system nil)
736 (kill-emacs))) 757 (kill-emacs)))
737 758
738 ;; Windowed displays do this inside their *-win.el.
739 (unless (or (display-graphic-p) noninteractive)
740 (setq command-line-args (tty-handle-args command-line-args)))
741
742 (set-locale-environment nil) 759 (set-locale-environment nil)
743 760
744 ;; Convert the arguments to Emacs internal representation. 761 ;; Convert the arguments to Emacs internal representation.
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index 11e3c073b76..e0233d64dbd 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -24,10 +24,16 @@
24 24
25;;; Commentary: 25;;; Commentary:
26 26
27;; X-win.el: this file is loaded from ../lisp/startup.el when it recognizes 27;; X-win.el: this file defines functions to initialize the X window
28;; that X windows are to be used. Command line switches are parsed and those 28;; system and process X-specific command line parameters before
29;; pertaining to X are processed and removed from the command line. The 29;; creating the first X frame.
30;; X display is opened and hooks are set for popping up the initial window. 30
31;; Note that contrary to previous Emacs versions, the act of loading
32;; this file should not have the side effect of initializing the
33;; window system or processing command line arguments (this file is
34;; now loaded in loadup.el). See the variables
35;; `handle-args-function-alist' and
36;; `window-system-initialization-alist' for more details.
31 37
32;; startup.el will then examine startup files, and eventually call the hooks 38;; startup.el will then examine startup files, and eventually call the hooks
33;; which create the first window(s). 39;; which create the first window(s).
@@ -1159,10 +1165,6 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
1159 1165
1160;;;; Function keys 1166;;;; Function keys
1161 1167
1162;;; XXX This might be wrong with multi-tty support.
1163(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
1164 global-map)
1165
1166;; Map certain keypad keys into ASCII characters 1168;; Map certain keypad keys into ASCII characters
1167;; that people usually expect. 1169;; that people usually expect.
1168(define-key function-key-map [backspace] [127]) 1170(define-key function-key-map [backspace] [127])
@@ -2237,7 +2239,7 @@ order until succeed.")
2237 (if text 2239 (if text
2238 (remove-text-properties 0 (length text) '(foreign-selection nil) text)) 2240 (remove-text-properties 0 (length text) '(foreign-selection nil) text))
2239 text)) 2241 text))
2240 2242
2241;;; Return the value of the current X selection. 2243;;; Return the value of the current X selection.
2242;;; Consult the selection, and the cut buffer. Treat empty strings 2244;;; Consult the selection, and the cut buffer. Treat empty strings
2243;;; as if they were unset. 2245;;; as if they were unset.
@@ -2329,132 +2331,143 @@ order until succeed.")
2329 )) 2331 ))
2330 2332
2331 2333
2332;;; Do the actual X Windows setup here; the above code just defines 2334;;; Window system initialization.
2333;;; functions and variables that we use now.
2334
2335(setq command-line-args (x-handle-args command-line-args))
2336 2335
2337;;; Make sure we have a valid resource name. 2336(defun x-win-suspend-error ()
2338(or (stringp x-resource-name) 2337 (error "Suspending an Emacs running under X makes no sense"))
2339 (let (i)
2340 (setq x-resource-name (invocation-name))
2341 2338
2342 ;; Change any . or * characters in x-resource-name to hyphens, 2339(defvar x-initialized nil
2343 ;; so as not to choke when we use it in X resource queries. 2340 "Non-nil if the X window system has been initialized.")
2344 (while (setq i (string-match "[.*]" x-resource-name)) 2341
2345 (aset x-resource-name i ?-)))) 2342(defun x-initialize-window-system ()
2343 "Initialize Emacs for X frames and open the first connection to an X server."
2344 ;; Make sure we have a valid resource name.
2345 (or (stringp x-resource-name)
2346 (let (i)
2347 (setq x-resource-name (invocation-name))
2348
2349 ;; Change any . or * characters in x-resource-name to hyphens,
2350 ;; so as not to choke when we use it in X resource queries.
2351 (while (setq i (string-match "[.*]" x-resource-name))
2352 (aset x-resource-name i ?-))))
2353
2354 (x-open-connection (or x-display-name
2355 (setq x-display-name (getenv "DISPLAY")))
2356 x-command-line-resources
2357 ;; Exit Emacs with fatal error if this fails and we
2358 ;; are the initial display.
2359 (eq initial-window-system 'x))
2360
2361 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
2362 x-cut-buffer-max))
2363
2364 ;; Setup the default fontset.
2365 (setup-default-fontset)
2366
2367 ;; Create the standard fontset.
2368 (create-fontset-from-fontset-spec standard-fontset-spec t)
2369
2370 ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2371 (create-fontset-from-x-resource)
2372
2373 ;; Try to create a fontset from a font specification which comes
2374 ;; from initial-frame-alist, default-frame-alist, or X resource.
2375 ;; A font specification in command line argument (i.e. -fn XXXX)
2376 ;; should be already in default-frame-alist as a `font'
2377 ;; parameter. However, any font specifications in site-start
2378 ;; library, user's init file (.emacs), and default.el are not
2379 ;; yet handled here.
2380
2381 (let ((font (or (cdr (assq 'font initial-frame-alist))
2382 (cdr (assq 'font default-frame-alist))
2383 (x-get-resource "font" "Font")))
2384 xlfd-fields resolved-name)
2385 (if (and font
2386 (not (query-fontset font))
2387 (setq resolved-name (x-resolve-font-name font))
2388 (setq xlfd-fields (x-decompose-font-name font)))
2389 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2390 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2391 ;; Create a fontset from FONT. The fontset name is
2392 ;; generated from FONT.
2393 (create-fontset-from-ascii-font font resolved-name "startup"))))
2394
2395 ;; Sun expects the menu bar cut and paste commands to use the clipboard.
2396 ;; This has ,? to match both on Sunos and on Solaris.
2397 (if (string-match "Sun Microsystems,? Inc\\."
2398 (x-server-vendor))
2399 (menu-bar-enable-clipboard))
2400
2401 ;; Apply a geometry resource to the initial frame. Put it at the end
2402 ;; of the alist, so that anything specified on the command line takes
2403 ;; precedence.
2404 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2405 parsed)
2406 (if res-geometry
2407 (progn
2408 (setq parsed (x-parse-geometry res-geometry))
2409 ;; If the resource specifies a position,
2410 ;; call the position and size "user-specified".
2411 (if (or (assq 'top parsed) (assq 'left parsed))
2412 (setq parsed (cons '(user-position . t)
2413 (cons '(user-size . t) parsed))))
2414 ;; All geometry parms apply to the initial frame.
2415 (setq initial-frame-alist (append initial-frame-alist parsed))
2416 ;; The size parms apply to all frames.
2417 (if (assq 'height parsed)
2418 (setq default-frame-alist
2419 (cons (cons 'height (cdr (assq 'height parsed)))
2420 default-frame-alist)))
2421 (if (assq 'width parsed)
2422 (setq default-frame-alist
2423 (cons (cons 'width (cdr (assq 'width parsed)))
2424 default-frame-alist))))))
2425
2426 ;; Check the reverseVideo resource.
2427 (let ((case-fold-search t))
2428 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2429 (if (and rv
2430 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2431 (setq default-frame-alist
2432 (cons '(reverse . t) default-frame-alist)))))
2346 2433
2347(x-open-connection (or x-display-name 2434 ;; Set x-selection-timeout, measured in milliseconds.
2348 (setq x-display-name (getenv "DISPLAY"))) 2435 (let ((res-selection-timeout
2349 x-command-line-resources 2436 (x-get-resource "selectionTimeout" "SelectionTimeout")))
2350 ;; Exit Emacs with fatal error if this fails and we 2437 (setq x-selection-timeout 20000)
2351 ;; are the initial display. 2438 (if res-selection-timeout
2352 (eq initial-window-system 'x)) 2439 (setq x-selection-timeout (string-to-number res-selection-timeout))))
2353 2440
2354(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces)) 2441 ;; XXX This is wrong in general with multi-tty support.
2442 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
2443 global-map)
2355 2444
2356(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100) 2445 ;; XXX This is wrong in general with multi-tty support.
2357 x-cut-buffer-max)) 2446 (add-hook 'suspend-hook 'x-win-suspend-error)
2358
2359;; Setup the default fontset.
2360(setup-default-fontset)
2361
2362;; Create the standard fontset.
2363(create-fontset-from-fontset-spec standard-fontset-spec t)
2364
2365;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
2366(create-fontset-from-x-resource)
2367
2368;; Try to create a fontset from a font specification which comes
2369;; from initial-frame-alist, default-frame-alist, or X resource.
2370;; A font specification in command line argument (i.e. -fn XXXX)
2371;; should be already in default-frame-alist as a `font'
2372;; parameter. However, any font specifications in site-start
2373;; library, user's init file (.emacs), and default.el are not
2374;; yet handled here.
2375
2376(let ((font (or (cdr (assq 'font initial-frame-alist))
2377 (cdr (assq 'font default-frame-alist))
2378 (x-get-resource "font" "Font")))
2379 xlfd-fields resolved-name)
2380 (if (and font
2381 (not (query-fontset font))
2382 (setq resolved-name (x-resolve-font-name font))
2383 (setq xlfd-fields (x-decompose-font-name font)))
2384 (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
2385 (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
2386 ;; Create a fontset from FONT. The fontset name is
2387 ;; generated from FONT.
2388 (create-fontset-from-ascii-font font resolved-name "startup"))))
2389
2390;; Sun expects the menu bar cut and paste commands to use the clipboard.
2391;; This has ,? to match both on Sunos and on Solaris.
2392(if (string-match "Sun Microsystems,? Inc\\."
2393 (x-server-vendor))
2394 (menu-bar-enable-clipboard))
2395
2396;; Apply a geometry resource to the initial frame. Put it at the end
2397;; of the alist, so that anything specified on the command line takes
2398;; precedence.
2399(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
2400 parsed)
2401 (if res-geometry
2402 (progn
2403 (setq parsed (x-parse-geometry res-geometry))
2404 ;; If the resource specifies a position,
2405 ;; call the position and size "user-specified".
2406 (if (or (assq 'top parsed) (assq 'left parsed))
2407 (setq parsed (cons '(user-position . t)
2408 (cons '(user-size . t) parsed))))
2409 ;; All geometry parms apply to the initial frame.
2410 (setq initial-frame-alist (append initial-frame-alist parsed))
2411 ;; The size parms apply to all frames.
2412 (if (assq 'height parsed)
2413 (setq default-frame-alist
2414 (cons (cons 'height (cdr (assq 'height parsed)))
2415 default-frame-alist)))
2416 (if (assq 'width parsed)
2417 (setq default-frame-alist
2418 (cons (cons 'width (cdr (assq 'width parsed)))
2419 default-frame-alist))))))
2420
2421;; Check the reverseVideo resource.
2422(let ((case-fold-search t))
2423 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
2424 (if (and rv
2425 (string-match "^\\(true\\|yes\\|on\\)$" rv))
2426 (setq default-frame-alist
2427 (cons '(reverse . t) default-frame-alist)))))
2428 2447
2429;; Set x-selection-timeout, measured in milliseconds. 2448 ;; Arrange for the kill and yank functions to set and check the clipboard.
2430(let ((res-selection-timeout 2449 (setq interprogram-cut-function 'x-select-text)
2431 (x-get-resource "selectionTimeout" "SelectionTimeout"))) 2450 (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
2432 (setq x-selection-timeout 20000)
2433 (if res-selection-timeout
2434 (setq x-selection-timeout (string-to-number res-selection-timeout))))
2435 2451
2436;; XXX This is wrong with multi-tty support. 2452 ;; Turn off window-splitting optimization; X is usually fast enough
2437(defun x-win-suspend-error () 2453 ;; that this is only annoying.
2438 (error "Suspending an Emacs running under X makes no sense")) 2454 (setq split-window-keep-point t)
2439(add-hook 'suspend-hook 'x-win-suspend-error)
2440 2455
2441;;; Arrange for the kill and yank functions to set and check the clipboard. 2456 ;; Motif direct handling of f10 wasn't working right,
2442(setq interprogram-cut-function 'x-select-text) 2457 ;; So temporarily we've turned it off in lwlib-Xm.c
2443(setq interprogram-paste-function 'x-cut-buffer-or-selection-value) 2458 ;; and turned the Emacs f10 back on.
2459 ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
2460 ;; (if (featurep 'motif)
2461 ;; (global-set-key [f10] 'ignore))
2444 2462
2445;;; Turn off window-splitting optimization; X is usually fast enough 2463 ;; Turn on support for mouse wheels.
2446;;; that this is only annoying. 2464 (mouse-wheel-mode 1)
2447(setq split-window-keep-point t)
2448 2465
2449;; Motif direct handling of f10 wasn't working right, 2466 (setq x-initialized t))
2450;; So temporarily we've turned it off in lwlib-Xm.c
2451;; and turned the Emacs f10 back on.
2452;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
2453;; (if (featurep 'motif)
2454;; (global-set-key [f10] 'ignore))
2455 2467
2456;; Turn on support for mouse wheels. 2468(add-to-list 'handle-args-function-alist '(x . x-handle-args))
2457(mouse-wheel-mode 1) 2469(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
2470(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
2458 2471
2459(provide 'x-win) 2472(provide 'x-win)
2460 2473
diff --git a/src/term.c b/src/term.c
index 3ab02c501b8..c6782efa606 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2908,10 +2908,12 @@ delete_tty (struct display *display)
2908void 2908void
2909create_tty_output (struct frame *f) 2909create_tty_output (struct frame *f)
2910{ 2910{
2911 struct tty_output *t;
2912
2911 if (! FRAME_TERMCAP_P (f)) 2913 if (! FRAME_TERMCAP_P (f))
2912 abort (); 2914 abort ();
2913 2915
2914 struct tty_output *t = xmalloc (sizeof (struct tty_output)); 2916 t = xmalloc (sizeof (struct tty_output));
2915 bzero (t, sizeof (struct tty_output)); 2917 bzero (t, sizeof (struct tty_output));
2916 2918
2917 t->display_info = FRAME_DISPLAY (f)->display_info.tty; 2919 t->display_info = FRAME_DISPLAY (f)->display_info.tty;