Subject: Re: bug#25408: Remove Decorations Around Emacs Frame (Windows OS)

From: Clément Pit--Claudel <[email-masked]>
Date: Sat, 11 Feb 2017 16:02:35 -0500

On 2017-02-11 09:27, martin rudalics wrote:
> If you are on GNU/Linux or Windows then please apply the attached patch
> synch-frames.diff to your current version of master and rebuild.  If you
> succeeded doing that, start emacs -Q and continue reading.

Thanks! The patch applied cleanly and everything compiled fine.

> To remove a frame's decorations, use the frame parameter `undecorated'

This works great.

> To make a new frame undecorated use
> (make-frame '((undecorated . t)))

This works great too.

> If everything works as intended and your only interest
> was to make frames without decorations, you can finish reading here.

Everything up to that point worked great :)

> Usually, the position of a frame's native rectangle doesn't change when
> adding/removing decorations.  If you want to change it, use the `left'
> and `top' frame parameters.

That works fine.

> If you think you need to remove/add individual parts of the decorations
> (titlebar, buttons, external borders) post your wishes here.  Some
> window managers might be able to do that.

I haven't needed this yet :)

> The rest of this text is concerned with describing additional features.
> If some of them don't work on your system, please tell me, usually they
> need a compliant window manager as well.

Thanks.  Maybe this is a good time to introduce my use case: I'd like to replace company-mode's overlay-based "tooltips" with proper tooltip-like frames.  show-x-tooltip almost works for that purpose, but not quite: most importantly, there can at any time only be at most one pop-up.

> To make a frame not show up on the taskbar use the
> frame parameter `skip-taskbar'

✓

> To make a new frame not receive focus initially or when deiconified, use
> the frame parameter `no-focus-on-map'

✓, although if I create a frame with no-focus-on-map I then need a call to raise-frame to raise it — even if its z-group is 'above.  Maybe when z-group is "above" the frame should be automatically raised?

> Usually this works but if you are using a focus follows mouse policy you
> might have to specify the `no-accept-focus' parameter as well as in
> 
> (make-frame '((no-focus-on-map . t) (no-accept-focus . t)))

✓

> If you want to avoid that C-x 5 o switches to a specific frame, set
> that frame's `no-other-frame' parameter as in

✓

> A second group of parameters/functions is concerned with maintaining and
> investigating the stacking order of frames.  The `z-group' parameter
> allows to put a frame in a separate group above or (not on Windows)
> below all other frames that are not in the same group.  For example
> 
> (set-frame-parameter nil 'z-group 'above)

✓, although it would be nice to automatically raise the frame when x-group is above.  I can call raise-frame, but it doesn't work correctly when the frame is invisible (and setting the visibility to t before raising the frame doesn't work either).

> For normal (non-child) frames there's a new hook `move-frame-functions'
> called after a frame was moved so you can also synchronize the movements
> of two top-level frames.

Cool.  I should use this to make sure the popup stays around.

> If the functions/parameters described here work sufficiently well, I'll
> post a number of toy algorithms that show how to synchronize two frames
> in a way that always shows one frame at a specified position on top of
> the other.

I think this is wonderful work; thanks so much for doing all this.

I've posted the code I used to test this with company.  f you eval this and run M-x company-tooltip--add-advice, completion should use an x frame in addition to its regular overlay-based tooltips.  This works very nicely, except for a few problems listed below:

* Creating a frame is rather slow; the following is an excerpt of a profile:

               - make-frame                                       442  29%
                - frame-creation-function                         440  29%
                 - apply                                          440  29%
                  - #<compiled 0x4862dd>                          440  29%
                   - x-create-frame-with-faces                    440  29%
                    - face-set-after-frame-default                307  20%
                     - face-spec-recalc                           276  18%
                      - make-face-x-resource-internal             217  14%
                       - set-face-attributes-from-resources       213  14%
                        - set-face-attribute-from-resource        190  12%
                         - face-name                              126   8%
                          + check-face                            118   7%
                      + face-spec-reset-face                       44   2%
                      + face-spec-set-2                             7   0%
                       set-face-attribute                           8   0%
                  normal-erase-is-backspace-setup-frame                  2   0%

* Frames with z-group set to 'above are not automatically raised when no-focus-on-map is set, so I need to call x-raise-frame on them; this doesn't work when they are invisible (instead it makes them visible without raising them, it seems).

* Creating a frame / making it visible uses my WM's frame creating animation — is there a way to disable this (x-show-tip doesn't have it)?

Thanks again for all this cool stuff! It would be great to use proper frames for company's completion popups.