;;; Commentary:
;;; Code:
+
(eval-when-compile (require 'cl-lib))
-(or (featurep 'pgtk)
- (error "%s: Loading pgtk-win.el but not compiled for pure Gtk+-3."
- invocation-name))
+(unless (featurep 'pgtk)
+ (error "%s: Loading pgtk-win.el but not compiled with PGTK."
+ invocation-name))
;; Documentation-purposes only: actually loaded in loadup.el.
(require 'term/common-win)
(require 'fontset)
(require 'dnd)
-(defgroup pgtk nil
- "Pure-GTK specific features."
- :group 'environment)
-
-;;;; Command line argument handling.
-
(defvar x-invocation-args)
-;; Set in term/common-win.el; currently unused by Gtk's x-open-connection.
(defvar x-command-line-resources)
-
-;; pgtkterm.c.
(defvar pgtk-input-file)
-
-(declare-function pgtk-use-im-context "pgtkim.c")
(defvar pgtk-use-im-context-on-new-connection)
-(defun pgtk-handle-nxopen (_switch &optional temp)
- (setq unread-command-events (append unread-command-events
- (if temp '(pgtk-open-temp-file)
- '(pgtk-open-file)))
- pgtk-input-file (append pgtk-input-file (list (pop x-invocation-args)))))
-
-(defun pgtk-handle-nxopentemp (switch)
- (pgtk-handle-nxopen switch t))
-
-(defun pgtk-ignore-1-arg (_switch)
- (setq x-invocation-args (cdr x-invocation-args)))
-
-;;;; File handling.
-
+(declare-function pgtk-use-im-context "pgtkim.c")
(declare-function pgtk-hide-emacs "pgtkfns.c" (on))
-
(defun pgtk-drag-n-drop (event &optional new-frame force-text)
"Edit the files listed in the drag-n-drop EVENT.
Switch to a buffer editing the last file dropped."
(dnd-insert-text window 'private data)
(dnd-handle-one-url window 'private url-or-string))))
-
(defun pgtk-drag-n-drop-other-frame (event)
"Edit the files listed in the drag-n-drop EVENT, in other frames.
May create new frames, or reuse existing ones. The frame editing
(pgtk-drag-n-drop event t t))
(global-set-key [drag-n-drop] 'pgtk-drag-n-drop)
-(global-set-key [C-drag-n-drop] 'pgtk-drag-n-drop-other-frame)
-(global-set-key [M-drag-n-drop] 'pgtk-drag-n-drop-as-text)
-(global-set-key [C-M-drag-n-drop] 'pgtk-drag-n-drop-as-text-other-frame)
-
-;;;; Frame-related functions.
-
-;; pgtkterm.c
-(defvar pgtk-alternate-modifier)
-(defvar pgtk-right-alternate-modifier)
-(defvar pgtk-right-command-modifier)
-(defvar pgtk-right-control-modifier)
-
-;; You say tomAYto, I say tomAHto..
-(with-no-warnings
- (defvaralias 'pgtk-option-modifier 'pgtk-alternate-modifier)
- (defvaralias 'pgtk-right-option-modifier 'pgtk-right-alternate-modifier))
-
-(defun pgtk-do-hide-emacs ()
- (interactive)
- (pgtk-hide-emacs t))
-
-(declare-function pgtk-hide-others "pgtkfns.c" ())
-
-(defun pgtk-do-hide-others ()
- (interactive)
- (pgtk-hide-others))
-
-(declare-function pgtk-emacs-info-panel "pgtkfns.c" ())
-
-(defun pgtk-do-emacs-info-panel ()
- (interactive)
- (pgtk-emacs-info-panel))
-
-(defun pgtk-next-frame ()
- "Switch to next visible frame."
- (interactive)
- (other-frame 1))
-
-(defun pgtk-prev-frame ()
- "Switch to previous visible frame."
- (interactive)
- (other-frame -1))
-
-;; Frame will be focused anyway, so select it
-;; (if this is not done, mode line is dimmed until first interaction)
-;; FIXME: Sounds like we're working around a bug in the underlying code.
-(add-hook 'after-make-frame-functions 'select-frame)
-
-(defvar tool-bar-mode)
-(declare-function tool-bar-mode "tool-bar" (&optional arg))
-
-;; Based on a function by David Reitter <dreitter@inf.ed.ac.uk> ;
-;; see https://lists.gnu.org/archive/html/emacs-devel/2005-09/msg00681.html .
-(defun pgtk-toggle-toolbar (&optional frame)
- "Switches the tool bar on and off in frame FRAME.
- If FRAME is nil, the change applies to the selected frame."
- (interactive)
- (modify-frame-parameters
- frame (list (cons 'tool-bar-lines
- (if (> (or (frame-parameter frame 'tool-bar-lines) 0) 0)
- 0 1)) ))
- (if (not tool-bar-mode) (tool-bar-mode t)))
-
-
-;;;; Dialog-related functions.
-
-;; Ask user for confirm before printing. Due to Kevin Rodgers.
-(defun pgtk-print-buffer ()
- "Interactive front-end to `print-buffer': asks for user confirmation first."
- (interactive)
- (if (and (called-interactively-p 'interactive)
- (or (listp last-nonmenu-event)
- (and (char-or-string-p (event-basic-type last-command-event))
- (memq 'super (event-modifiers last-command-event)))))
- (let ((last-nonmenu-event (if (listp last-nonmenu-event)
- last-nonmenu-event
- ;; Fake it:
- `(mouse-1 POSITION 1))))
- (if (y-or-n-p (format "Print buffer %s? " (buffer-name)))
- (print-buffer)
- (error "Canceled")))
- (print-buffer)))
-
-;;;; Font support.
-
-;; Needed for font listing functions under both backend and normal
-(setq scalable-fonts-allowed t)
-
-;; Default fontset. This is mainly here to show how a fontset
-;; can be set up manually. Ordinarily, fontsets are auto-created whenever
-;; a font is chosen by
-(defvar pgtk-standard-fontset-spec
- ;; Only some code supports this so far, so use uglier XLFD version
- ;; "-pgtk-*-*-*-*-*-10-*-*-*-*-*-fontset-standard,latin:Courier,han:Kai"
- (mapconcat 'identity
- '("-*-Monospace-*-*-*-*-10-*-*-*-*-*-fontset-standard"
- "latin:-*-Courier-*-*-*-*-10-*-*-*-*-*-iso10646-1")
- ",")
- "String of fontset spec of the standard fontset.
-This defines a fontset consisting of the Courier and other fonts.
-See the documentation of `create-fontset-from-fontset-spec' for the format.")
-
-
-;;;; Pasteboard support.
-
-(define-obsolete-function-alias 'pgtk-store-cut-buffer-internal
- 'gui-set-selection "24.1")
-
-
-(defun pgtk-copy-including-secondary ()
- (interactive)
- (call-interactively 'kill-ring-save)
- (gui-set-selection 'SECONDARY (buffer-substring (point) (mark t))))
-
-(defun pgtk-paste-secondary ()
- (interactive)
- (insert (gui-get-selection 'SECONDARY)))
-
(defun pgtk-suspend-error ()
- ;; Don't allow suspending if any of the frames are PGTK frames.
+ "Don't allow suspending if any of the frames are PGTK frames."
(if (memq 'pgtk (mapcar 'window-system (frame-list)))
(error "Cannot suspend Emacs while a PGTK GUI frame exists")))
-
-
(defvar pgtk-initialized nil
"Non-nil if pure-GTK windowing has been initialized.")
(display &optional xrm-string must-succeed))
(declare-function pgtk-set-resource "pgtkfns.c" (owner name value))
-;; Do the actual pure-GTK Windows setup here; the above code just
-;; defines functions and variables that we use now.
+;; Do the actual window system setup here; the above code just defines
+;; functions and variables that we use now.
(cl-defmethod window-system-initialization (&context (window-system pgtk)
&optional display)
- "Initialize Emacs for pure-GTK windowing."
+ "Initialize the PGTK window system.
+WINDOW-SYSTEM is, aptly, `pgtk'.
+DISPLAY is the name of the display Emacs should connect to."
(cl-assert (not pgtk-initialized))
;; PENDING: not needed?
(create-default-fontset)
;; Create the standard fontset.
(condition-case err
- (create-fontset-from-fontset-spec pgtk-standard-fontset-spec t)
+ (create-fontset-from-fontset-spec standard-fontset-spec t)
(error (display-warning
'initialization
(format "Creation of the standard fontset failed: %s" err)
(define-key special-event-map [preedit-text] 'pgtk-preedit-text)
-(add-hook 'after-init-hook
- (function
- (lambda ()
- (when (eq window-system 'pgtk)
- (pgtk-use-im-context pgtk-use-im-context-on-new-connection)))))
-
+(defun pgtk-use-im-context-handler ()
+ "Set up input context usage after Emacs initialization."
+ (when (eq window-system 'pgtk)
+ (pgtk-use-im-context pgtk-use-im-context-on-new-connection)))
-;;;
+(add-hook 'after-init-hook #'pgtk-use-im-context-handler)
(defcustom x-gtk-stock-map
(mapcar (lambda (arg)
}
}
-/*
- * This is not a flip context in the same sense as gpu rendering
- * scences, it only occurs when a new context was required due to a
- * resize or other fundamental change. This is called when that
- * context's surface has completed drawing
- */
+/* This is not a flip context in the same sense as gpu rendering
+ scenes, it only occurs when a new context was required due to a
+ resize or other fundamental change. This is called when that
+ context's surface has completed drawing. */
static void
flip_cr_context (struct frame *f)
char *
get_keysym_name (int keysym)
-/* --------------------------------------------------------------------------
- Called by keyboard.c. Not sure if the return val is important, except
- that it be unique.
- -------------------------------------------------------------------------- */
{
- static char value[16];
- sprintf (value, "%d", keysym);
- return value;
+ return gdk_keyval_name (keysym);
}
void
gtk_widget_get_size_request (FRAME_GTK_WIDGET (f), &pixelwidth,
&pixelheight);
-#if 0
- if (pixelwise)
- {
- pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
- pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
- }
- else
- {
- pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, width);
- pixelheight = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, height);
- }
-#else
pixelwidth = width;
pixelheight = height;
-#endif
-
-#if 0
- frame_size_history_add
- (f, Qx_set_window_size_1, width, height,
- list5 (Fcons (make_fixnum (pixelwidth), make_fixnum (pixelheight)),
- Fcons (make_fixnum (pixelwidth), make_fixnum (pixelheight)),
- make_fixnum (f->border_width),
- make_fixnum (FRAME_PGTK_TITLEBAR_HEIGHT (f)),
- make_fixnum (FRAME_TOOLBAR_HEIGHT (f))));
-#endif
for (GtkWidget * w = FRAME_GTK_WIDGET (f); w != NULL;
w = gtk_widget_get_parent (w))
switch (scroll)
{
case GTK_SCROLL_JUMP:
-#if 0
- /* Buttons 1 2 or 3 must be grabbed. */
- if (FRAME_DISPLAY_INFO (f)->grabbed != 0
- && FRAME_DISPLAY_INFO (f)->grabbed < (1 << 4))
-#endif
- {
- if (bar->horizontal)
- {
- part = scroll_bar_horizontal_handle;
- whole = (int) (gtk_adjustment_get_upper (adj) -
- gtk_adjustment_get_page_size (adj));
- portion = min ((int) value, whole);
- bar->dragging = portion;
- }
- else
- {
- part = scroll_bar_handle;
- whole = gtk_adjustment_get_upper (adj) -
- gtk_adjustment_get_page_size (adj);
- portion = min ((int) value, whole);
- bar->dragging = portion;
- }
+ if (bar->horizontal)
+ {
+ part = scroll_bar_horizontal_handle;
+ whole = (int) (gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_page_size (adj));
+ portion = min ((int) value, whole);
+ bar->dragging = portion;
+ }
+ else
+ {
+ part = scroll_bar_handle;
+ whole = gtk_adjustment_get_upper (adj) -
+ gtk_adjustment_get_page_size (adj);
+ portion = min ((int) value, whole);
+ bar->dragging = portion;
}
break;
case GTK_SCROLL_STEP_BACKWARD:
xg_display_close (dpyinfo->gdpy);
- /* Do not close the connection here because it's already closed
- by X(t)CloseDisplay (Bug#18403). */
dpyinfo->gdpy = NULL;
}