emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add function to make frame topmost?


From: David De La Harpe Golden
Subject: Re: Add function to make frame topmost?
Date: Fri, 30 Apr 2010 23:32:14 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109)

Stefan:
>
> I see, thanks.  I don't know if there's a word for such things
> under X11 (I guess we should ask the freedesktop guys).

Not affiliated with freedesktop as such, just familiar with specs:

ITYM "Always on top" or "above other windows", or technically asking that _NET_WM_STATE include _NET_WM_STATE_ABOVE

N.B. For "normal" windows (such as ordinary emacs frames), this is something usually configured by the user via the window manager's menu, setting it within emacs for normal frames would not be something I would particularly want or need to do, though possible (*** below), and setting it for special framey things is not AFAIK a good idea (following):

http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#STACKINGORDER

[lennart]
> My use case for something like this is reminders that pops up at a
> certain times.

Note that X11 apps (or more usually the gui toolkit the app uses) specify the purpose of the window in higher-level terms _NET_WM_WINDOW_TYPE, like "this is a tooltip", "this is a notification" _NET_WM_WINDOW_TYPE_TOOLTIP, _NET_WM_WINDOW_TYPE_NOTIFICATION
etc.

The window manager then places it in the appropriate stacking group, among other things:

"""
This property SHOULD be used by the window manager in determining the decoration, stacking position and other behavior of the window.
"""

The greater diversity in window management on X11 than windoze
makes observing such things pretty important - "this is a notification" may make a whole lot more sense to a tiling wm than "above plz k thx".

Please note that abusing _NET_WM_STATE for attention purposes is specifically highlighted as a What Not To Do in the spec:

"""
_NET_WM_STATE_ABOVE and _NET_WM_STATE_BELOW are mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs (the Urgency hint should be used in that case, see the section called “Urgency”).'
"""


***
One can certainly do this from within emacs as per the spec (note you
do this for mapped windows by sending a client message to the root window). Note however, that window managers may refuse an app's request to be always on top.

(defun x-toggle-frame-always-on-top (&optional frame)
    (x-send-client-message
     frame 0 frame "_NET_WM_STATE" 32
     ;; _NET_WM_STATE_REMOVE = 0
     ;; _NET_WM_STATE_ADD = 1
     ;; _NET_WM_STATE_TOGGLE = 2
     '(2 "_NET_WM_STATE_ABOVE" 0 1)))






reply via email to

[Prev in Thread] Current Thread [Next in Thread]