(or clip-text primary-text cut-text)
))
-\f
-;;; Do the actual X Windows setup here; the above code just defines
-;;; functions and variables that we use now.
-
-(setq command-line-args (x-handle-args command-line-args))
-
-;;; Make sure we have a valid resource name.
-(or (stringp x-resource-name)
- (let (i)
- (setq x-resource-name (invocation-name))
-
- ;; Change any . or * characters in x-resource-name to hyphens,
- ;; so as not to choke when we use it in X resource queries.
- (while (setq i (string-match "[.*]" x-resource-name))
- (aset x-resource-name i ?-))))
-
-(x-open-connection (or x-display-name
- (setq x-display-name (getenv "DISPLAY")))
- x-command-line-resources
- ;; Exit Emacs with fatal error if this fails.
- t)
-
-(setq frame-creation-function 'x-create-frame-with-faces)
-
-(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
- x-cut-buffer-max))
-
-;; Setup the default fontset.
-(setup-default-fontset)
-
-;; Create the standard fontset.
-(create-fontset-from-fontset-spec standard-fontset-spec t)
-
-;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
-(create-fontset-from-x-resource)
-
-;; Try to create a fontset from a font specification which comes
-;; from initial-frame-alist, default-frame-alist, or X resource.
-;; A font specification in command line argument (i.e. -fn XXXX)
-;; should be already in default-frame-alist as a `font'
-;; parameter. However, any font specifications in site-start
-;; library, user's init file (.emacs), and default.el are not
-;; yet handled here.
-
-(let ((font (or (cdr (assq 'font initial-frame-alist))
- (cdr (assq 'font default-frame-alist))
- (x-get-resource "font" "Font")))
- xlfd-fields resolved-name)
- (if (and font
- (not (query-fontset font))
- (setq resolved-name (x-resolve-font-name font))
- (setq xlfd-fields (x-decompose-font-name font)))
- (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
- (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
- ;; Create a fontset from FONT. The fontset name is
- ;; generated from FONT.
- (create-fontset-from-ascii-font font resolved-name "startup"))))
-
-;; Apply a geometry resource to the initial frame. Put it at the end
-;; of the alist, so that anything specified on the command line takes
-;; precedence.
-(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
- parsed)
- (if res-geometry
- (progn
- (setq parsed (x-parse-geometry res-geometry))
- ;; If the resource specifies a position,
- ;; call the position and size "user-specified".
- (if (or (assq 'top parsed) (assq 'left parsed))
- (setq parsed (cons '(user-position . t)
- (cons '(user-size . t) parsed))))
- ;; All geometry parms apply to the initial frame.
- (setq initial-frame-alist (append initial-frame-alist parsed))
- ;; The size parms apply to all frames.
- (if (assq 'height parsed)
- (setq default-frame-alist
- (cons (cons 'height (cdr (assq 'height parsed)))
- default-frame-alist)))
- (if (assq 'width parsed)
- (setq default-frame-alist
- (cons (cons 'width (cdr (assq 'width parsed)))
- default-frame-alist))))))
-
-;; Check the reverseVideo resource.
-(let ((case-fold-search t))
- (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
- (if (and rv
- (string-match "^\\(true\\|yes\\|on\\)$" rv))
- (setq default-frame-alist
- (cons '(reverse . t) default-frame-alist)))))
++(defun x-clipboard-yank ()
++ "Insert the clipboard contents, or the last stretch of killed text."
++ (interactive)
++ (let ((clipboard-text (x-get-selection 'CLIPBOARD))
++ (x-select-enable-clipboard t))
++ (if (and clipboard-text (> (length clipboard-text) 0))
++ (kill-new clipboard-text))
++ (yank)))
+
-;; Set x-selection-timeout, measured in milliseconds.
-(let ((res-selection-timeout
- (x-get-resource "selectionTimeout" "SelectionTimeout")))
- (setq x-selection-timeout 20000)
- (if res-selection-timeout
- (setq x-selection-timeout (string-to-number res-selection-timeout))))
+\f
+;;; Window system initialization.
(defun x-win-suspend-error ()
(error "Suspending an Emacs running under X makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-;;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
-(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
+(defvar x-initialized nil
+ "Non-nil if the X window system has been initialized.")
+
+(defun x-initialize-window-system ()
+ "Initialize Emacs for X frames and open the first connection to an X server."
+ ;; Make sure we have a valid resource name.
+ (or (stringp x-resource-name)
+ (let (i)
+ (setq x-resource-name (invocation-name))
+
+ ;; Change any . or * characters in x-resource-name to hyphens,
+ ;; so as not to choke when we use it in X resource queries.
+ (while (setq i (string-match "[.*]" x-resource-name))
+ (aset x-resource-name i ?-))))
+
+ (x-open-connection (or x-display-name
+ (setq x-display-name (getenv "DISPLAY")))
+ x-command-line-resources
+ ;; Exit Emacs with fatal error if this fails and we
+ ;; are the initial display.
+ (eq initial-window-system 'x))
+
+ (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
+ x-cut-buffer-max))
+
+ ;; Setup the default fontset.
+ (setup-default-fontset)
+
+ ;; Create the standard fontset.
+ (create-fontset-from-fontset-spec standard-fontset-spec t)
+
+ ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
+ (create-fontset-from-x-resource)
+
+ ;; Try to create a fontset from a font specification which comes
+ ;; from initial-frame-alist, default-frame-alist, or X resource.
+ ;; A font specification in command line argument (i.e. -fn XXXX)
+ ;; should be already in default-frame-alist as a `font'
+ ;; parameter. However, any font specifications in site-start
+ ;; library, user's init file (.emacs), and default.el are not
+ ;; yet handled here.
+
+ (let ((font (or (cdr (assq 'font initial-frame-alist))
+ (cdr (assq 'font default-frame-alist))
+ (x-get-resource "font" "Font")))
+ xlfd-fields resolved-name)
+ (if (and font
+ (not (query-fontset font))
+ (setq resolved-name (x-resolve-font-name font))
+ (setq xlfd-fields (x-decompose-font-name font)))
+ (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
+ (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
+ ;; Create a fontset from FONT. The fontset name is
+ ;; generated from FONT.
+ (create-fontset-from-ascii-font font resolved-name "startup"))))
+
- ;; Sun expects the menu bar cut and paste commands to use the clipboard.
- ;; This has ,? to match both on Sunos and on Solaris.
- (if (string-match "Sun Microsystems,? Inc\\."
- (x-server-vendor))
- (menu-bar-enable-clipboard))
-
+ ;; Apply a geometry resource to the initial frame. Put it at the end
+ ;; of the alist, so that anything specified on the command line takes
+ ;; precedence.
+ (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
+ parsed)
+ (if res-geometry
+ (progn
+ (setq parsed (x-parse-geometry res-geometry))
+ ;; If the resource specifies a position,
+ ;; call the position and size "user-specified".
+ (if (or (assq 'top parsed) (assq 'left parsed))
+ (setq parsed (cons '(user-position . t)
+ (cons '(user-size . t) parsed))))
+ ;; All geometry parms apply to the initial frame.
+ (setq initial-frame-alist (append initial-frame-alist parsed))
+ ;; The size parms apply to all frames.
+ (if (assq 'height parsed)
+ (setq default-frame-alist
+ (cons (cons 'height (cdr (assq 'height parsed)))
+ default-frame-alist)))
+ (if (assq 'width parsed)
+ (setq default-frame-alist
+ (cons (cons 'width (cdr (assq 'width parsed)))
+ default-frame-alist))))))
+
+ ;; Check the reverseVideo resource.
+ (let ((case-fold-search t))
+ (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
+ (if (and rv
+ (string-match "^\\(true\\|yes\\|on\\)$" rv))
+ (setq default-frame-alist
+ (cons '(reverse . t) default-frame-alist)))))
-;;; Turn off window-splitting optimization; X is usually fast enough
-;;; that this is only annoying.
-(setq split-window-keep-point t)
+ ;; Set x-selection-timeout, measured in milliseconds.
+ (let ((res-selection-timeout
+ (x-get-resource "selectionTimeout" "SelectionTimeout")))
+ (setq x-selection-timeout 20000)
+ (if res-selection-timeout
+ (setq x-selection-timeout (string-to-number res-selection-timeout))))
-;; Don't show the frame name; that's redundant with X.
-(setq-default mode-line-frame-identification " ")
+ ;; XXX This is wrong in general with multi-tty support.
+ (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
+ global-map)
-;; Motif direct handling of f10 wasn't working right,
-;; So temporarily we've turned it off in lwlib-Xm.c
-;; and turned the Emacs f10 back on.
-;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
-;; (if (featurep 'motif)
-;; (global-set-key [f10] 'ignore))
+ ;; XXX This is wrong in general with multi-tty support.
+ (add-hook 'suspend-hook 'x-win-suspend-error)
-;; Turn on support for mouse wheels.
-(mouse-wheel-mode 1)
+ ;; Arrange for the kill and yank functions to set and check the clipboard.
+ (setq interprogram-cut-function 'x-select-text)
+ (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
-;; Enable CLIPBOARD copy/paste through menu bar commands.
-(menu-bar-enable-clipboard)
+ ;; Turn off window-splitting optimization; X is usually fast enough
+ ;; that this is only annoying.
+ (setq split-window-keep-point t)
-;; Override Paste so it looks at CLIPBOARD first.
-(defun x-clipboard-yank ()
- "Insert the clipboard contents, or the last stretch of killed text."
- (interactive)
- (let ((clipboard-text (x-get-selection 'CLIPBOARD))
- (x-select-enable-clipboard t))
- (if (and clipboard-text (> (length clipboard-text) 0))
- (kill-new clipboard-text))
- (yank)))
+ ;; Motif direct handling of f10 wasn't working right,
+ ;; So temporarily we've turned it off in lwlib-Xm.c
+ ;; and turned the Emacs f10 back on.
+ ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
+ ;; (if (featurep 'motif)
+ ;; (global-set-key [f10] 'ignore))
+
+ ;; Turn on support for mouse wheels.
+ (mouse-wheel-mode 1)
+
++ ;; Enable CLIPBOARD copy/paste through menu bar commands.
++ (menu-bar-enable-clipboard)
++
++ ;; Override Paste so it looks at CLIPBOARD first.
++ (define-key menu-bar-edit-menu [paste]
++ (cons "Paste" (cons "Paste text from clipboard or kill ring"
++ 'x-clipboard-yank)))
++
+ (setq x-initialized t))
+
+(add-to-list 'handle-args-function-alist '(x . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
-(define-key menu-bar-edit-menu [paste]
- (cons "Paste" (cons "Paste text from clipboard or kill ring"
- 'x-clipboard-yank)))
+(provide 'x-win)
;;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78
;;; x-win.el ends here
}
/* Adjust y to the offset in the row to start drawing the bitmap. */
- p.y += (row->height - p.h) / 2;
+ if (period == 0)
+ p.y += (row->height - p.h) / 2;
+ else if (period == -2)
+ {
+ p.h = fringe_bitmaps[which].height;
+ p.y += (row->visible_height - p.h);
+ }
- rif->draw_fringe_bitmap (w, row, &p);
+ FRAME_RIF (f)->draw_fringe_bitmap (w, row, &p);
}
/* Draw fringe bitmaps for glyph row ROW on window W. Call this
start = end = whole = 0;
/* Indicate what this scroll bar ought to be displaying now. */
- set_vertical_scroll_bar_hook (w, end - start, whole, start);
+ if (FRAME_DISPLAY (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
+ (*FRAME_DISPLAY (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
+ (w, end - start, whole, start);
}
+ #ifdef HAVE_WINDOW_SYSTEM
+
+ /* Recalculate the bitmaps to show in the fringes of window W.
+ If FORCE_P is 0, only mark rows with modified bitmaps for update in
+ redraw_fringe_bitmaps_p; else mark all rows for update. */
+
+ int
+ update_window_fringes (w, force_p)
+ struct window *w;
+ int force_p;
+ {
+ struct glyph_row *row, *cur = 0;
+ int yb = window_text_bottom_y (w);
+ int rn, nrows = w->current_matrix->nrows;
+ int y;
+ int redraw_p = 0;
+ Lisp_Object ind;
+
+ if (w->pseudo_window_p)
+ return 0;
+
+ if (!MINI_WINDOW_P (w)
+ && (ind = XBUFFER (w->buffer)->indicate_buffer_boundaries, !NILP (ind)))
+ {
+ int do_eob = 1, do_bob = 1;
+
+ for (y = 0, rn = 0;
+ y < yb && rn < nrows;
+ y += row->height, ++rn)
+ {
+ unsigned indicate_bob_p, indicate_top_line_p;
+ unsigned indicate_eob_p, indicate_bottom_line_p;
+
+ row = w->desired_matrix->rows + rn;
+ if (!row->enabled_p)
+ row = w->current_matrix->rows + rn;
+
+ indicate_bob_p = row->indicate_bob_p;
+ indicate_top_line_p = row->indicate_top_line_p;
+ indicate_eob_p = row->indicate_eob_p;
+ indicate_bottom_line_p = row->indicate_bottom_line_p;
+
+ row->indicate_bob_p = row->indicate_top_line_p = 0;
+ row->indicate_eob_p = row->indicate_bottom_line_p = 0;
+
+ if (MATRIX_ROW_START_CHARPOS (row) <= BUF_BEGV (XBUFFER (w->buffer)))
+ row->indicate_bob_p = do_bob, do_bob = 0;
+ else if (EQ (ind, Qt)
+ && (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) == rn)
+ row->indicate_top_line_p = 1;
+
+ if (MATRIX_ROW_END_CHARPOS (row) >= BUF_ZV (XBUFFER (w->buffer)))
+ row->indicate_eob_p = do_eob, do_eob = 0;
+ else if (EQ (ind, Qt)
+ && y + row->height >= yb)
+ row->indicate_bottom_line_p = 1;
+
+ if (indicate_bob_p != row->indicate_bob_p
+ || indicate_top_line_p != row->indicate_top_line_p
+ || indicate_eob_p != row->indicate_eob_p
+ || indicate_bottom_line_p != row->indicate_bottom_line_p)
+ row->redraw_fringe_bitmaps_p = 1;
+ }
+ }
+
+ for (y = 0, rn = 0;
+ y < yb && rn < nrows;
+ y += row->height, rn++)
+ {
+ enum fringe_bitmap_type left, right;
+
+ row = w->desired_matrix->rows + rn;
+ cur = w->current_matrix->rows + rn;
+ if (!row->enabled_p)
+ row = cur;
+
+ /* Decide which bitmap to draw in the left fringe. */
+ if (WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
+ left = NO_FRINGE_BITMAP;
+ else if (row->overlay_arrow_p)
+ left = OVERLAY_ARROW_BITMAP;
+ else if (row->truncated_on_left_p)
+ left = LEFT_TRUNCATION_BITMAP;
+ else if (MATRIX_ROW_CONTINUATION_LINE_P (row))
+ left = CONTINUATION_LINE_BITMAP;
+ else if (row->indicate_empty_line_p)
+ left = ZV_LINE_BITMAP;
+ else if (row->indicate_bob_p)
+ left = FIRST_LINE_BITMAP;
+ else
+ left = NO_FRINGE_BITMAP;
+
+ /* Decide which bitmap to draw in the right fringe. */
+ if (WINDOW_RIGHT_FRINGE_WIDTH (w) == 0)
+ right = NO_FRINGE_BITMAP;
+ else if (row->truncated_on_right_p)
+ right = RIGHT_TRUNCATION_BITMAP;
+ else if (row->continued_p)
+ right = CONTINUED_LINE_BITMAP;
+ else if (row->indicate_eob_p)
+ right = LAST_LINE_BITMAP;
+ else if (row->indicate_top_line_p)
+ right = UP_ARROW_BITMAP;
+ else if (row->indicate_bottom_line_p)
+ right = DOWN_ARROW_BITMAP;
+ else if (row->indicate_empty_line_p && WINDOW_LEFT_FRINGE_WIDTH (w) == 0)
+ right = ZV_LINE_BITMAP;
+ else
+ right = NO_FRINGE_BITMAP;
+
+ if (force_p
+ || row->y != cur->y
+ || row->visible_height != cur->visible_height
+ || left != cur->left_fringe_bitmap
+ || right != cur->right_fringe_bitmap
+ || cur->redraw_fringe_bitmaps_p)
+ {
+ redraw_p = row->redraw_fringe_bitmaps_p = cur->redraw_fringe_bitmaps_p = 1;
+ cur->left_fringe_bitmap = left;
+ cur->right_fringe_bitmap = right;
+ }
+
+ row->left_fringe_bitmap = left;
+ row->right_fringe_bitmap = right;
+ }
+
+ return redraw_p;
+ }
+
+ #endif /* HAVE_WINDOW_SYSTEM */
+
/* Redisplay leaf window WINDOW. JUST_THIS_ONE_P non-zero means only
selected_window is redisplayed.
if (run.height)
{
- struct frame *f = XFRAME (WINDOW_FRAME (w));
update_begin (f);
- rif->update_window_begin_hook (w);
- rif->clear_window_mouse_face (w);
- rif->scroll_run_hook (w, &run);
- rif->update_window_end_hook (w, 0, 0);
+ FRAME_RIF (f)->update_window_begin_hook (w);
+ FRAME_RIF (f)->clear_window_mouse_face (w);
+ FRAME_RIF (f)->scroll_run_hook (w, &run);
+ FRAME_RIF (f)->update_window_end_hook (w, 0, 0);
update_end (f);
}