[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58. Functions Specific to the X Window System

XEmacs provides the concept of devices, which generalizes connections to an X server, a TTY device, etc. Most information about an X server that XEmacs is connected to can be determined through general console and device functions. See section Consoles and Devices. However, there are some features of the X Window System that do not generalize well, and they are covered specially here.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58.1 X Selections

The X server records a set of selections which permit transfer of data between application programs. The various selections are distinguished by selection types, represented in XEmacs by symbols. X clients including XEmacs can read or set the selection for any given type.

Function: x-own-selection data &optional type

This function sets a “selection” in the X server. It takes two arguments: a value, data, and the selection type type to assign it to. data may be a string, a cons of two markers, or an extent. In the latter cases, the selection is considered to be the text between the markers, or between the extent’s endpoints.

Each possible type has its own selection value, which changes independently. The usual values of type are PRIMARY and SECONDARY; these are symbols with upper-case names, in accord with X Windows conventions. The default is PRIMARY.

(In FSF Emacs, this function is called x-set-selection and takes different arguments.)

Function: x-get-selection

This function accesses selections set up by XEmacs or by other X clients. It returns the value of the current primary selection.

Function: x-disown-selection &optional secondary-p

Assuming we own the selection, this function disowns it. If secondary-p is non-nil, the secondary selection instead of the primary selection is discarded.

The X server also has a set of numbered cut buffers which can store text or other data being moved between applications. Cut buffers are considered obsolete, but XEmacs supports them for the sake of X clients that still use them.

Function: x-get-cutbuffer &optional n

This function returns the contents of cut buffer number n. (This function is called x-get-cut-buffer in FSF Emacs.)

Function: x-store-cutbuffer string &optional push

This function stores string into the first cut buffer (cut buffer 0).

Normally, the contents of the first cut buffer are simply replaced by string. However, if optional argument push is non-nil, the cut buffers are rotated. This means that the previous value of the first cut buffer moves to the second cut buffer, and the second to the third, and so on, moving the other values down through the series of cut buffers, kill-ring-style. There are 8 cut buffers altogether.

Cut buffers are considered obsolete; you should use selections instead.

This function has no effect if support for cut buffers was not compiled in.

This function is called x-set-cut-buffer in FSF Emacs.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58.2 X Server

This section describes how to access and change the overall status of the X server XEmacs is using.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58.2.1 Resources

Function: default-x-device

This function return the default X device for resourcing. This is the first-created X device that still exists.

Function: x-get-resource name class type &optional locale device noerror

This function retrieves a resource value from the X resource manager.

The resource names passed to this function are looked up relative to the locale.

If you want to search for a subresource, you just need to specify the resource levels in name and class. For example, name could be ‘"modeline.attributeFont"’, and class"Face.AttributeFont"’.

Specifically,

  1. If locale is a buffer, a call
     
        (x-get-resource "foreground" "Foreground" 'string some-buffer)
    

    is an interface to a C call something like

     
        XrmGetResource (db, "xemacs.buffer.buffer-name.foreground",
                            "Emacs.EmacsLocaleType.EmacsBuffer.Foreground",
                            "String");
    
  2. If locale is a frame, a call
     
        (x-get-resource "foreground" "Foreground" 'string some-frame)
    

    is an interface to a C call something like

     
        XrmGetResource (db, "xemacs.frame.frame-name.foreground",
                            "Emacs.EmacsLocaleType.EmacsFrame.Foreground",
                            "String");
    
  3. If locale is a device, a call
     
        (x-get-resource "foreground" "Foreground" 'string some-device)
    

    is an interface to a C call something like

     
        XrmGetResource (db, "xemacs.device.device-name.foreground",
                            "Emacs.EmacsLocaleType.EmacsDevice.Foreground",
                            "String");
    
  4. If locale is the symbol global, a call
     
        (x-get-resource "foreground" "Foreground" 'string 'global)
    

    is an interface to a C call something like

     
        XrmGetResource (db, "xemacs.foreground",
                            "Emacs.Foreground",
                            "String");
    

Note that for global, no prefix is added other than that of the application itself; thus, you can use this locale to retrieve arbitrary application resources, if you really want to.

The returned value of this function is nil if the queried resource is not found. If type is string, a string is returned, and if it is integer, an integer is returned. If type is boolean, then the returned value is the list (t) for true, (nil) for false, and is nil to mean “unspecified”.

Function: x-put-resource resource-line &optional device

This function adds a resource to the resource database for device. resource-line specifies the resource to add and should be a standard resource specification.

Variable: x-emacs-application-class

This variable holds The X application class of the XEmacs process. This controls, among other things, the name of the “app-defaults” file that XEmacs will use. For changes to this variable to take effect, they must be made before the connection to the X server is initialized, that is, this variable may only be changed before XEmacs is dumped, or by setting it in the file ‘lisp/term/x-win.el’.

By default, this variable is nil at startup. When the connection to the X server is first initialized, the X resource database will be consulted and the value will be set according to whether any resources are found for the application class “XEmacs”.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58.2.2 Data about the X Server

This section describes functions and a variable that you can use to get information about the capabilities and origin of the X server corresponding to a particular device. The device argument is generally optional and defaults to the selected device.

Function: x-server-version &optional device

This function returns the list of version numbers of the X server device is on. The returned value is a list of three integers: the major and minor version numbers of the X protocol in use, and the vendor-specific release number.

Function: x-server-vendor &optional device

This function returns the vendor supporting the X server device is on.

Function: x-display-visual-class &optional device

This function returns the visual class of the display device is on. The value is one of the symbols static-gray, gray-scale, static-color, pseudo-color, true-color, and direct-color. (Note that this is different from previous versions of XEmacs, which returned StaticGray, GrayScale, etc.)


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

58.2.3 Restricting Access to the Server by Other Apps

Function: x-grab-keyboard &optional device

This function grabs the keyboard on the given device (defaulting to the selected one). So long as the keyboard is grabbed, all keyboard events will be delivered to XEmacs—it is not possible for other X clients to eavesdrop on them. Ungrab the keyboard with x-ungrab-keyboard (use an unwind-protect). Returns t if the grab was successful; nil otherwise.

Function: x-ungrab-keyboard &optional device

This function releases a keyboard grab made with x-grab-keyboard.

Function: x-grab-pointer &optional device cursor ignore-keyboard

This function grabs the pointer and restricts it to its current window. If optional device argument is nil, the selected device will be used. If optional cursor argument is non-nil, change the pointer shape to that until x-ungrab-pointer is called (it should be an object returned by the make-cursor function). If the second optional argument ignore-keyboard is non-nil, ignore all keyboard events during the grab. Returns t if the grab is successful, nil otherwise.

Function: x-ungrab-pointer &optional device

This function releases a pointer grab made with x-grab-pointer. If optional first arg device is nil the selected device is used. If it is t the pointer will be released on all X devices.



[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Aidan Kehoe on December 27, 2016 using texi2html 1.82.