unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
@ 2016-02-12 15:01 Clément Pit--Claudel
  2016-02-13  2:15 ` Chris Feng
  2016-02-15 10:57 ` martin rudalics
  0 siblings, 2 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-12 15:01 UTC (permalink / raw)
  To: Emacs developers; +Cc: Stefan Monnier, Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 1792 bytes --]

Hi emacs-devel,

TL;DR: How do I create a frame without a border, in the style of x_create_tip_frame (called by x-show-tip in the C sources), from Elisp?

I'm looking at ways in which we could use real tooptip popups instead of overlays to display company-mode completion lists. This would have many advantages, including better interaction with font sizes, no issues with recursive display specs, good support for variable-width fonts, and so on. I believe Stefan has spoken in favour of that approach in the past, too.

The natural candidate for this task is x-show-tip, and it probably meets most of the requirements; but not all. In particular, there can be at most one tooltip displayed at any time; this means that we'd break other packages that display tooltips while completion is ongoing. Examples include company-quickhelp, which displays documentation for the currently selected entry next to completion candidates.

`x-show-tip` is currently implemented in C; as far as I can see, however, it essentially creates a frame and displays it at a given location; given this, I thought it would be possible to reimplement it in ELisp. Unfortunately, I've been hitting a wall when it comes to displaying a borderless frame. I asked on https://emacs.stackexchange.com/questions/20167/how-do-i-create-a-borderless-frame, to no avail. 

My original guess was that the relevant part of the C code was this call:

  x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER);

Unfortunately, neither (set-frame-param (selected-frame) 'border-width 0) nor (make-frame '((border-width . 0))) (both inspired from the call above) yield a borderless frame.

Is there a way to create a borderless frame from Elisp?

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-12 15:01 Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Clément Pit--Claudel
@ 2016-02-13  2:15 ` Chris Feng
  2016-02-13  3:35   ` Clément Pit--Claudel
  2016-02-15 10:57 ` martin rudalics
  1 sibling, 1 reply; 28+ messages in thread
From: Chris Feng @ 2016-02-13  2:15 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: Emacs developers

> TL;DR: How do I create a frame without a border, in the style of x_create_tip_frame (called by x-show-tip in the C sources), from Elisp?
>
> I'm looking at ways in which we could use real tooptip popups instead of overlays to display company-mode completion lists. This would have many advantages, including better interaction with font sizes, no issues with recursive display specs, good support for variable-width fonts, and so on. I believe Stefan has spoken in favour of that approach in the past, too.
>
> The natural candidate for this task is x-show-tip, and it probably meets most of the requirements; but not all. In particular, there can be at most one tooltip displayed at any time; this means that we'd break other packages that display tooltips while completion is ongoing. Examples include company-quickhelp, which displays documentation for the currently selected entry next to completion candidates.
>
> `x-show-tip` is currently implemented in C; as far as I can see, however, it essentially creates a frame and displays it at a given location; given this, I thought it would be possible to reimplement it in ELisp. Unfortunately, I've been hitting a wall when it comes to displaying a borderless frame. I asked on https://emacs.stackexchange.com/questions/20167/how-do-i-create-a-borderless-frame, to no avail.
>
> My original guess was that the relevant part of the C code was this call:
>
>   x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
>
> Unfortunately, neither (set-frame-param (selected-frame) 'border-width 0) nor (make-frame '((border-width . 0))) (both inspired from the call above) yield a borderless frame.

I think the relevant part in 'x_create_tip_frame' is actually:

  attrs.override_redirect = True;

What you want to do is to remove the decoration added by the window
manager.  So you need to set the override-redirect flag on that X
window.

> Is there a way to create a borderless frame from Elisp?

You may have a look at XELB (available on ELPA).  The following code
should create a frame without decoration.

  (require 'xcb)

  (setq frame (make-frame '((visibility . nil))))

  (let ((window (string-to-number (frame-parameter frame 'outer-window-id)))
        (connection (xcb:connect-to-socket)))
    (xcb:+request connection
        (make-instance 'xcb:ChangeWindowAttributes
                       :window window
                       :value-mask xcb:CW:OverrideRedirect
                       :override-redirect 1))
    (xcb:flush connection)
    (xcb:disconnect connection))

  (make-frame-visible frame)



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-13  2:15 ` Chris Feng
@ 2016-02-13  3:35   ` Clément Pit--Claudel
  2016-02-13  3:57     ` Chris Feng
  2016-02-14 14:05     ` Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Stefan Monnier
  0 siblings, 2 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-13  3:35 UTC (permalink / raw)
  To: Chris Feng; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]

On 02/12/2016 09:15 PM, Chris Feng wrote:
> I think the relevant part in 'x_create_tip_frame' is actually:
> 
>   attrs.override_redirect = True;
> 
> What you want to do is to remove the decoration added by the window
> manager.  So you need to set the override-redirect flag on that X
> window.

You're right; thanks! I was navigating the C sources and reached that conclusion as your email came :)

It doesn't seem that there's any Elisp level facility to customize this flag, unfortunately. This means in particular that unless we patch the C sources, there won't be a cross platform solution to this issue, right?

I've started thinking at what a patch would look like; presumably the idea would be to expose the functionality of x_create_tip_frame to Elisp, moving parts of x_show_tip into that function. I could try coming up with a patch, if this is deemed useful.

There's one thing that confuses me, however: some code related to tooltips seems to be duplicated between xfns.c, w32fns.c, etc; are these files auto-generated? Or should I prepare a patch that adjusts all copies of that code?

>> Is there a way to create a borderless frame from Elisp?
> 
> You may have a look at XELB (available on ELPA).  The following code
> should create a frame without decoration.
> 
>   (require 'xcb)
> 
>   (setq frame (make-frame '((visibility . nil))))
> 
>   (let ((window (string-to-number (frame-parameter frame 'outer-window-id)))
>         (connection (xcb:connect-to-socket)))
>     (xcb:+request connection
>         (make-instance 'xcb:ChangeWindowAttributes
>                        :window window
>                        :value-mask xcb:CW:OverrideRedirect
>                        :override-redirect 1))
>     (xcb:flush connection)
>     (xcb:disconnect connection))
> 
>   (make-frame-visible frame)

This is really neat, actually :) Thanks a lot! It works great on my machine.
I'd still like to find a cross-platform solution, though; company isn't X-specific. Am I right to think that this will only work on GNU/Linux?

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-13  3:35   ` Clément Pit--Claudel
@ 2016-02-13  3:57     ` Chris Feng
  2016-02-16 20:12       ` Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?) Clément Pit--Claudel
  2016-02-14 14:05     ` Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Stefan Monnier
  1 sibling, 1 reply; 28+ messages in thread
From: Chris Feng @ 2016-02-13  3:57 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: Emacs developers

> It doesn't seem that there's any Elisp level facility to customize this flag, unfortunately. This means in particular that unless we patch the C sources, there won't be a cross platform solution to this issue, right?

I'm afraid so.

> I've started thinking at what a patch would look like; presumably the idea would be to expose the functionality of x_create_tip_frame to Elisp, moving parts of x_show_tip into that function. I could try coming up with a patch, if this is deemed useful.
>
> There's one thing that confuses me, however: some code related to tooltips seems to be duplicated between xfns.c, w32fns.c, etc; are these files auto-generated? Or should I prepare a patch that adjusts all copies of that code?

Those files contain implementations for different platforms.  You need
to patch all of them.

The override-redirect flag is X-specific actually.

> This is really neat, actually :) Thanks a lot! It works great on my machine.
> I'd still like to find a cross-platform solution, though; company isn't X-specific. Am I right to think that this will only work on GNU/Linux?

Yes, and perhaps other platforms running X11.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-13  3:35   ` Clément Pit--Claudel
  2016-02-13  3:57     ` Chris Feng
@ 2016-02-14 14:05     ` Stefan Monnier
  2016-02-14 16:44       ` Eli Zaretskii
  2016-02-16 20:06       ` Clément Pit--Claudel
  1 sibling, 2 replies; 28+ messages in thread
From: Stefan Monnier @ 2016-02-14 14:05 UTC (permalink / raw)
  To: emacs-devel

> There's one thing that confuses me, however: some code related to tooltips
> seems to be duplicated between xfns.c, w32fns.c, etc;

Indeed.  This sucks, but it's where we're at.
The amount of duplication between *menu.c is probably even worse.

> are these files auto-generated?

Wishful thinking :-(


        Stefan




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-14 14:05     ` Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Stefan Monnier
@ 2016-02-14 16:44       ` Eli Zaretskii
  2016-02-14 17:19         ` Stefan Monnier
  2016-02-16 20:06       ` Clément Pit--Claudel
  1 sibling, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2016-02-14 16:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Sun, 14 Feb 2016 09:05:20 -0500
> 
> > There's one thing that confuses me, however: some code related to tooltips
> > seems to be duplicated between xfns.c, w32fns.c, etc;
> 
> Indeed.  This sucks, but it's where we're at.

The differences make the job of avoiding duplication a non-trivial
job.  Volunteers and patches are very welcome.

> The amount of duplication between *menu.c is probably even worse.

No, that one was fixed a few releases ago.  The common code is in
menu.c.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-14 16:44       ` Eli Zaretskii
@ 2016-02-14 17:19         ` Stefan Monnier
  2016-02-14 18:00           ` Eli Zaretskii
  0 siblings, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2016-02-14 17:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

>> The amount of duplication between *menu.c is probably even worse.
> No, that one was fixed a few releases ago.  The common code is in
> menu.c.

Oh, indeed, I had completely forgotten about that.  Is it me or the sun
is shining a bit brighter suddenly?


        Stefan



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-14 17:19         ` Stefan Monnier
@ 2016-02-14 18:00           ` Eli Zaretskii
  0 siblings, 0 replies; 28+ messages in thread
From: Eli Zaretskii @ 2016-02-14 18:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: emacs-devel@gnu.org
> Date: Sun, 14 Feb 2016 12:19:13 -0500
> 
> >> The amount of duplication between *menu.c is probably even worse.
> > No, that one was fixed a few releases ago.  The common code is in
> > menu.c.
> 
> Oh, indeed, I had completely forgotten about that.  Is it me or the sun
> is shining a bit brighter suddenly?

The sun, of course.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-12 15:01 Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Clément Pit--Claudel
  2016-02-13  2:15 ` Chris Feng
@ 2016-02-15 10:57 ` martin rudalics
  2016-02-15 13:31   ` Stefan Monnier
  2016-02-16 20:05   ` Clément Pit--Claudel
  1 sibling, 2 replies; 28+ messages in thread
From: martin rudalics @ 2016-02-15 10:57 UTC (permalink / raw)
  To: Clément Pit--Claudel, Emacs developers; +Cc: Stefan Monnier, Dmitry Gutov

 > TL;DR: How do I create a frame without a border, in the style of
 > x_create_tip_frame (called by x-show-tip in the C sources), from
 > Elisp?

What is a border?  ‘x_create_tip_frame’ creates a frame with up to two
types of borders, the one specified via the ‘internal-border-width’ and
the other one specified via the ‘border-width’ frame parameter (where
the latter is AFAICT used for tooltips only).  At the same time,
‘x_create_tip_frame’ tries to suppress decorations of the window manager
which is probably what you want.

 > I'm looking at ways in which we could use real tooptip popups instead
 > of overlays to display company-mode completion lists. This would have
 > many advantages, including better interaction with font sizes, no
 > issues with recursive display specs, good support for variable-width
 > fonts, and so on. I believe Stefan has spoken in favour of that
 > approach in the past, too.

Is there any reason you cannot use menus for this purpose?

 > The natural candidate for this task is x-show-tip, and it probably
 > meets most of the requirements; but not all. In particular, there can
 > be at most one tooltip displayed at any time; this means that we'd
 > break other packages that display tooltips while completion is
 > ongoing. Examples include company-quickhelp, which displays
 > documentation for the currently selected entry next to completion
 > candidates.
 >
 > `x-show-tip` is currently implemented in C; as far as I can see,
 > however, it essentially creates a frame and displays it at a given
 > location; given this, I thought it would be possible to reimplement it
 > in ELisp. Unfortunately, I've been hitting a wall when it comes to
 > displaying a borderless frame. I asked on
 > https://emacs.stackexchange.com/questions/20167/how-do-i-create-a-borderless-frame,
 > to no avail.

‘x-show-tip’ is highly tailored to emulating "conventional" tooltips and
strongly tied to ‘x-hide-tip’.  Parts of its implementation (in
particular the Lucid menubar issue) are highly fragile, so better don't
tinker with it.  Also a reimplementation in ELisp hardly makes sense
because the API calls are used to hide the implementation details wrt
X11 and Windows.  You can't use the ‘border-width’ parameter with the
latter so we have to emulate the X11 behavior somehow with the
"thin-line" border approach provided by the Windows API.  And the
GTK/OSX tooltips will behave specially anyway.

 > My original guess was that the relevant part of the C code was this call:
 >
 >    x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
 >
 > Unfortunately, neither (set-frame-param (selected-frame) 'border-width
 > 0) nor (make-frame '((border-width . 0))) (both inspired from the call
 > above) yield a borderless frame.

These are overridden by the window manager.  ‘border-width’ is the most
obscure of our frame parameters, it's implementation is beyond our
control.  You can set it via ‘tooltip-frame-parameters’ and then it is
usually honored for X11 tooltips (but not on Windows).

 > Is there a way to create a borderless frame from Elisp?

If a truly borderless frame is what you want, we can do that for X11 and
Windows.  GTK has ‘gtk_window_set_decorated’ and we could try using that
as well.  I have no idea how to do that on OSX, maybe Anders has.

You would, however, have to say how a borderless frame should look like.
At least the Windows tooltip frame is _not_ borderless.  And on X11 I
wouldn't know how to remove caption and borders separately.  IIUC you
can only remove them both or neither.

martin




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-15 10:57 ` martin rudalics
@ 2016-02-15 13:31   ` Stefan Monnier
  2016-02-16 20:06     ` Clément Pit--Claudel
  2016-02-16 20:05   ` Clément Pit--Claudel
  1 sibling, 1 reply; 28+ messages in thread
From: Stefan Monnier @ 2016-02-15 13:31 UTC (permalink / raw)
  To: martin rudalics; +Cc: Dmitry Gutov, Clément Pit--Claudel, Emacs developers

> Is there any reason you cannot use menus for this purpose?

IIRC menus have been used for that, but they can't be controlled finely
enough (they're provided by the toolkit), so you can't make it so the
user can keep typing while the menu is displayed (and refine the
content of the menu as the user types).


        Stefan



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-15 10:57 ` martin rudalics
  2016-02-15 13:31   ` Stefan Monnier
@ 2016-02-16 20:05   ` Clément Pit--Claudel
  2016-02-16 21:33     ` Johan Bockgård
  2016-02-17  9:12     ` martin rudalics
  1 sibling, 2 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 20:05 UTC (permalink / raw)
  To: martin rudalics, Emacs developers; +Cc: Stefan Monnier, Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 4778 bytes --]

On 02/15/2016 05:57 AM, martin rudalics wrote:
>> TL;DR: How do I create a frame without a border, in the style of
>> x_create_tip_frame (called by x-show-tip in the C sources), from
>> Elisp?
> 
> What is a border?  ‘x_create_tip_frame’ creates a frame with up to two
> types of borders, the one specified via the ‘internal-border-width’ and
> the other one specified via the ‘border-width’ frame parameter (where
> the latter is AFAICT used for tooltips only).  At the same time,
> ‘x_create_tip_frame’ tries to suppress decorations of the window manager
> which is probably what you want.

Sorry for being unclear. I mean the frame chrome, that is the title bar and minimize, maximize and close buttons.

>> I'm looking at ways in which we could use real tooptip popups instead
>> of overlays to display company-mode completion lists. This would have
>> many advantages, including better interaction with font sizes, no
>> issues with recursive display specs, good support for variable-width
>> fonts, and so on. I believe Stefan has spoken in favour of that
>> approach in the past, too.
> 
> Is there any reason you cannot use menus for this purpose?

I guess it depends on what you mean by menu. Right now, menus don't have the features that I listed above AFAICT (for example, can they display faces? Can they use the same font fallback mechanisms as Emacs?).

>> The natural candidate for this task is x-show-tip, and it probably
>> meets most of the requirements; but not all. In particular, there can
>> be at most one tooltip displayed at any time; this means that we'd
>> break other packages that display tooltips while completion is
>> ongoing. Examples include company-quickhelp, which displays
>> documentation for the currently selected entry next to completion
>> candidates.
>>
>> `x-show-tip` is currently implemented in C; as far as I can see,
>> however, it essentially creates a frame and displays it at a given
>> location; given this, I thought it would be possible to reimplement it
>> in ELisp. Unfortunately, I've been hitting a wall when it comes to
>> displaying a borderless frame. I asked on
>> https://emacs.stackexchange.com/questions/20167/how-do-i-create-a-borderless-frame,
>> to no avail.
> 
> ‘x-show-tip’ is highly tailored to emulating "conventional" tooltips and
> strongly tied to ‘x-hide-tip’.  Parts of its implementation (in
> particular the Lucid menubar issue) are highly fragile, so better don't
> tinker with it.  

I see, thanks.

> Also a reimplementation in ELisp hardly makes sense
> because the API calls are used to hide the implementation details wrt
> X11 and Windows.

I'm focusing on the case where x-gtk-use-system-tooltips is nil, so that tooltips are implemented using  

> You can't use the ‘border-width’ parameter with the
> latter so we have to emulate the X11 behavior somehow with the
> "thin-line" border approach provided by the Windows API.  And the
> GTK/OSX tooltips will behave specially anyway.
> 
>> My original guess was that the relevant part of the C code was this call:
>>
>>    x_default_parameter (f, parms, Qborder_width, make_number (0), "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
>>
>> Unfortunately, neither (set-frame-param (selected-frame) 'border-width
>> 0) nor (make-frame '((border-width . 0))) (both inspired from the call
>> above) yield a borderless frame.
> 
> These are overridden by the window manager.  ‘border-width’ is the most
> obscure of our frame parameters, it's implementation is beyond our
> control.  You can set it via ‘tooltip-frame-parameters’ and then it is
> usually honored for X11 tooltips (but not on Windows).

Does this apply to system tooltips, or tooltips implemented using a full Emacs frame?

>> Is there a way to create a borderless frame from Elisp?
> 
> If a truly borderless frame is what you want, we can do that for X11 and
> Windows.  GTK has ‘gtk_window_set_decorated’ and we could try using that
> as well.  I have no idea how to do that on OSX, maybe Anders has.

Indeed, that's what I'd like. x-show-tip works perfectly for me (it supports fonts, faces, etc. properly), expect for the fact that updating the tooltip text causes it to be closed and reopened.
> 
> You would, however, have to say how a borderless frame should look like.
> At least the Windows tooltip frame is _not_ borderless.  And on X11 I
> wouldn't know how to remove caption and borders separately.  IIUC you
> can only remove them both or neither.

Thanks for clarifying. I'm mostly trying to get something that looks like an Emacs frame with a single window, but without window manager chrome around the frame; only the buffer's text.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-15 13:31   ` Stefan Monnier
@ 2016-02-16 20:06     ` Clément Pit--Claudel
  0 siblings, 0 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 20:06 UTC (permalink / raw)
  To: Stefan Monnier, martin rudalics; +Cc: Dmitry Gutov, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

On 02/15/2016 08:31 AM, Stefan Monnier wrote:
>> Is there any reason you cannot use menus for this purpose?
> 
> IIRC menus have been used for that, but they can't be controlled finely
> enough (they're provided by the toolkit), so you can't make it so the
> user can keep typing while the menu is displayed (and refine the
> content of the menu as the user types).

Indeed, this is one of the issues.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-14 14:05     ` Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Stefan Monnier
  2016-02-14 16:44       ` Eli Zaretskii
@ 2016-02-16 20:06       ` Clément Pit--Claudel
  1 sibling, 0 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 20:06 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

On 02/14/2016 09:05 AM, Stefan Monnier wrote:
>> There's one thing that confuses me, however: some code related to tooltips
>> seems to be duplicated between xfns.c, w32fns.c, etc;
> 
> Indeed.  This sucks, but it's where we're at.
> The amount of duplication between *menu.c is probably even worse.

I see, thanks for the clarification!


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-13  3:57     ` Chris Feng
@ 2016-02-16 20:12       ` Clément Pit--Claudel
  2016-02-16 22:41         ` Chris Feng
  0 siblings, 1 reply; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 20:12 UTC (permalink / raw)
  To: Chris Feng; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1611 bytes --]

On 02/12/2016 10:57 PM, Chris Feng wrote:
>> It doesn't seem that there's any Elisp level facility to customize
>> this flag, unfortunately. This means in particular that unless we
>> patch the C sources, there won't be a cross platform solution to
>> this issue, right?
> 
> I'm afraid so.
> 
>> I've started thinking at what a patch would look like; presumably
>> the idea would be to expose the functionality of x_create_tip_frame
>> to Elisp, moving parts of x_show_tip into that function. I could
>> try coming up with a patch, if this is deemed useful.
>> 
>> There's one thing that confuses me, however: some code related to
>> tooltips seems to be duplicated between xfns.c, w32fns.c, etc; are
>> these files auto-generated? Or should I prepare a patch that
>> adjusts all copies of that code?
> 
> Those files contain implementations for different platforms.  You
> need to patch all of them.
> 
> The override-redirect flag is X-specific actually.

Thanks for clarifying. This makes sense, of course :)

Scaling back on the original intent, then, could we expose to Lisp a way to create a chrome-less frame, presumably in just the same way as the tooltip code does it? Something like `remove_frame_chrome(frame *f)`, which one would call before making a frame visible.

>> This is really neat, actually :) Thanks a lot! It works great on my
>> machine. I'd still like to find a cross-platform solution, though;
>> company isn't X-specific. Am I right to think that this will only
>> work on GNU/Linux?
> 
> Yes, and perhaps other platforms running X11.

Thanks.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-16 20:05   ` Clément Pit--Claudel
@ 2016-02-16 21:33     ` Johan Bockgård
  2016-02-16 22:18       ` Clément Pit--Claudel
  2016-02-17  9:12     ` martin rudalics
  1 sibling, 1 reply; 28+ messages in thread
From: Johan Bockgård @ 2016-02-16 21:33 UTC (permalink / raw)
  To: Clément Pit--Claudel
  Cc: martin rudalics, Dmitry Gutov, Stefan Monnier, Emacs developers

Clément Pit--Claudel <clement.pit@gmail.com> writes:

> Indeed, that's what I'd like. x-show-tip works perfectly for me (it
> supports fonts, faces, etc. properly), expect for the fact that
> updating the tooltip text causes it to be closed and reopened.

Try this:

(let* ((x-gtk-use-system-tooltips nil)
       (list '("abc" "def" "ghi" "jkl" "mno"))
       (L (length list))
       (n 0)
       (f (lambda ()
            (let ((tmp -1))
              (mapconcat
               (lambda (s)
                 (setq tmp (1+ tmp))
                 (if (= n tmp)
                     (propertize s 'face 'highlight)
                   (propertize s 'face 'default)))
               list "\n"))))
       (offset 0)
       (edges (window-edges nil t t t))
       (xy    (posn-x-y (posn-at-point (point))))
       (left  (+ (car edges)  (car xy) (* (frame-char-width) offset)))
       (top   (+ (cadr edges) (cdr xy) (frame-char-height)))
       (parameters
        (list (cons 'left left) (cons 'top top) '(border-width . 0))))
  (unwind-protect
      (progn (x-show-tip (funcall f) nil parameters most-positive-fixnum)
             (while
                 (progn
                   (with-current-buffer (get-buffer " *tip*")
                     (erase-buffer)
                     (insert (funcall f)))
                   (pcase (read-key)
                     ('down (setq n (mod (1+ n) L)))
                     ('up (setq n (mod (1- n) L)))
                     (_ nil)))))
    (x-hide-tip)))

;; <--  C-x C-e <down>/<up> ...



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-16 21:33     ` Johan Bockgård
@ 2016-02-16 22:18       ` Clément Pit--Claudel
  0 siblings, 0 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 22:18 UTC (permalink / raw)
  To: Johan Bockgård
  Cc: martin rudalics, Dmitry Gutov, Stefan Monnier, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

On 02/16/2016 04:33 PM, Johan Bockgård wrote:
> Clément Pit--Claudel <clement.pit@gmail.com> writes:
> 
>> Indeed, that's what I'd like. x-show-tip works perfectly for me (it
>> supports fonts, faces, etc. properly), expect for the fact that
>> updating the tooltip text causes it to be closed and reopened.
> 
> Try this: ...

Thanks; this is a very clever trick :) Do you think there's a way to work around the other issue that I pointed out in the very first email of this thread?

> (...) there can be at most one tooltip displayed at any 
> time; this means that we'd break other packages that display
> tooltips while completion is ongoing. Examples include
> company-quickhelp, which displays documentation for the currently
> selected entry next to completion candidates.

Cheers,
Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-16 20:12       ` Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?) Clément Pit--Claudel
@ 2016-02-16 22:41         ` Chris Feng
  2016-02-16 22:55           ` Clément Pit--Claudel
  0 siblings, 1 reply; 28+ messages in thread
From: Chris Feng @ 2016-02-16 22:41 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 561 bytes --]

> Scaling back on the original intent, then, could we expose to Lisp a way
to create a chrome-less frame, presumably in just the same way as the
tooltip code does it? Something like `remove_frame_chrome(frame *f)`, which
one would call before making a frame visible.

This will definitely work on X.  Basically an X window manager takes over a
window when it gets mapped (becomes visible).  But I'm not sure if the
procedure is necessary on other platforms.

I think it'd be better if we can control this directly by feeding
`make-frame' a new frame parameter.

[-- Attachment #2: Type: text/html, Size: 630 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-16 22:41         ` Chris Feng
@ 2016-02-16 22:55           ` Clément Pit--Claudel
  2016-02-16 23:14             ` Chris Feng
  0 siblings, 1 reply; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 22:55 UTC (permalink / raw)
  To: Chris Feng; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 820 bytes --]

On 02/16/2016 05:41 PM, Chris Feng wrote:
>> Scaling back on the original intent, then, could we expose to Lisp a way to create a chrome-less frame, presumably in just the same way as the tooltip code does it? Something like `remove_frame_chrome(frame *f)`, which one would call before making a frame visible.
> 
> This will definitely work on X.  Basically an X window manager takes over a window when it gets mapped (becomes visible).  But I'm not sure if the procedure is necessary on other platforms.
> 
> I think it'd be better if we can control this directly by feeding `make-frame' a new frame parameter.

Indeed, that would be nice :)

Can we set this parameter after the corresponding X window has been displayed? Or should this new frame parameter only make sense in make-frame calls?

Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-16 22:55           ` Clément Pit--Claudel
@ 2016-02-16 23:14             ` Chris Feng
  2016-02-16 23:46               ` Clément Pit--Claudel
  0 siblings, 1 reply; 28+ messages in thread
From: Chris Feng @ 2016-02-16 23:14 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

> Can we set this parameter after the corresponding X window has been
displayed? Or should this new frame parameter only make sense in make-frame
calls?

Modifying such a parameter makes little sense I think.  IIRC some existing
frame parameters just work this way.

[-- Attachment #2: Type: text/html, Size: 305 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-16 23:14             ` Chris Feng
@ 2016-02-16 23:46               ` Clément Pit--Claudel
  2016-02-17  9:13                 ` martin rudalics
  0 siblings, 1 reply; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-16 23:46 UTC (permalink / raw)
  To: Chris Feng; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

On 02/16/2016 06:14 PM, Chris Feng wrote:
>> Can we set this parameter after the corresponding X window has been
>> displayed? Or should this new frame parameter only make sense in
>> make-frame calls?
> 
> Modifying such a parameter makes little sense I think.  IIRC some
> existing frame parameters just work this way.

Ok; thanks. So if I understand correctly, the implementation would look like this:

* add a frame parameter to frame_parms in frame.c, say "chromeless"
* add an x_set_chromeless slot in each of frame_parm_handler x_frame_parm_handlers[], frame_parm_handler w32_frame_parm_handlers[], frame_parm_handler ns_frame_parm_handlers[]; for the last two point to 0 for now; for the first one point to a new function x_set_chromeless.
* In x-create-frame, add something like
    x_default_parameter (f, parms, Qchromeless, Qnil,
                         "chromeless", "Chromeless", RES_TYPE_BOOLEAN);

Am I missing steps (in terms of implementation)?

Thanks for your help!
Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-16 20:05   ` Clément Pit--Claudel
  2016-02-16 21:33     ` Johan Bockgård
@ 2016-02-17  9:12     ` martin rudalics
  2016-02-17 14:26       ` Clément Pit--Claudel
  1 sibling, 1 reply; 28+ messages in thread
From: martin rudalics @ 2016-02-17  9:12 UTC (permalink / raw)
  To: Clément Pit--Claudel, Emacs developers; +Cc: Stefan Monnier, Dmitry Gutov

 >> These are overridden by the window manager.  ‘border-width’ is the most
 >> obscure of our frame parameters, it's implementation is beyond our
 >> control.  You can set it via ‘tooltip-frame-parameters’ and then it is
 >> usually honored for X11 tooltips (but not on Windows).
 >
 > Does this apply to system tooltips, or tooltips implemented using a full Emacs frame?

I'm not sure what you mean.  "System tooltips" are only used on GTK
(optionally) and on OS X (unconditionally) and you cannot control their
border width via the ‘border-width’ frame parameter.  "Tooltips
implemented using a full Emacs frame" behave like other frames and for X
these usually obey the ‘border-width’ frame parameter but only at the
time they are created.  You can't change the border width of an existing
frame.

 > Indeed, that's what I'd like. x-show-tip works perfectly for me (it
 > supports fonts, faces, etc. properly), expect for the fact that
 > updating the tooltip text causes it to be closed and reopened.

That's why IMHO tooltips are not useful for your purpose.  What you
probably want is a normal undecorated frame whose lifetime, position,
size, visibility and contents would be completely controlled by you.

martin




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-16 23:46               ` Clément Pit--Claudel
@ 2016-02-17  9:13                 ` martin rudalics
  2016-02-17 13:49                   ` Chris Feng
  2016-02-17 14:57                   ` Clément Pit--Claudel
  0 siblings, 2 replies; 28+ messages in thread
From: martin rudalics @ 2016-02-17  9:13 UTC (permalink / raw)
  To: Clément Pit--Claudel, Chris Feng; +Cc: emacs-devel

 > * add a frame parameter to frame_parms in frame.c, say "chromeless"

I'd prefer "decorated" as in gtk_window_set-decorated.

 > * add an x_set_chromeless slot in each of frame_parm_handler x_frame_parm_handlers[], frame_parm_handler w32_frame_parm_handlers[], frame_parm_handler ns_frame_parm_handlers[]; for the last two point to 0 for now; for the first one point to a new function x_set_chromeless.
 > * In x-create-frame, add something like
 >      x_default_parameter (f, parms, Qchromeless, Qnil,
 >                           "chromeless", "Chromeless", RES_TYPE_BOOLEAN);

For X I doubt that it's always possible to add/remove the decorations of
an existing frame.  For Windows the below works here with

x_default_parameter (f, parameters, Qdecorated, Qnil,
                      "decorated", "Decorated", RES_TYPE_SYMBOL);

martin


void
x_set_decorated (struct frame *f, Lisp_Object decorated, Lisp_Object old_decorated)
{
   HWND hwnd = FRAME_W32_WINDOW (f);
   DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);

   block_input ();
   if (EQ (decorated, Qnone))
     /* Remove caption and border.  */
     SetWindowLong (hwnd, GWL_STYLE, dwStyle & ~WS_CAPTION & ~WS_THICKFRAME);
   else if (EQ (decorated, Qtip_frame))
     /* Retain 1-pixel wide border.  */
     SetWindowLong (hwnd, GWL_STYLE, (dwStyle & ~WS_CAPTION & ~WS_THICKFRAME) | WS_POPUPWINDOW);
   else
     /* Restore decoration.  */
     SetWindowLong (hwnd, GWL_STYLE, dwStyle | WS_CAPTION | WS_THICKFRAME);

   /* Preserve outer position and size as well as Z-order.  */
   SetWindowPos (hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE
		| SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
   unblock_input ();
}



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-17  9:13                 ` martin rudalics
@ 2016-02-17 13:49                   ` Chris Feng
  2016-02-17 14:55                     ` Clément Pit--Claudel
  2016-02-17 14:57                   ` Clément Pit--Claudel
  1 sibling, 1 reply; 28+ messages in thread
From: Chris Feng @ 2016-02-17 13:49 UTC (permalink / raw)
  To: Clément Pit--Claudel, martin rudalics; +Cc: emacs-devel

>> * add a frame parameter to frame_parms in frame.c, say "chromeless"
>
> I'd prefer "decorated" as in gtk_window_set-decorated.

Agree.  We call it "decoration" in X almost exclusively.

>> * add an x_set_chromeless slot in each of frame_parm_handler
>> x_frame_parm_handlers[], frame_parm_handler w32_frame_parm_handlers[],
>> frame_parm_handler ns_frame_parm_handlers[]; for the last two point to 0 for
>> now; for the first one point to a new function x_set_chromeless.
>> * In x-create-frame, add something like
>>      x_default_parameter (f, parms, Qchromeless, Qnil,
>>                           "chromeless", "Chromeless", RES_TYPE_BOOLEAN);

I don't think we need to make this customizable through X resources,
so the fifth and sixth parameters to x_default_parameter should be
NULL.

> For X I doubt that it's always possible to add/remove the decorations of
> an existing frame.

Yes but it may require remapping if it's already mapped.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?
  2016-02-17  9:12     ` martin rudalics
@ 2016-02-17 14:26       ` Clément Pit--Claudel
  0 siblings, 0 replies; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-17 14:26 UTC (permalink / raw)
  To: martin rudalics, Emacs developers; +Cc: Stefan Monnier, Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

On 02/17/2016 04:12 AM, martin rudalics wrote:
>>> These are overridden by the window manager.  ‘border-width’ is the most
>>> obscure of our frame parameters, it's implementation is beyond our
>>> control.  You can set it via ‘tooltip-frame-parameters’ and then it is
>>> usually honored for X11 tooltips (but not on Windows).
>>
>> Does this apply to system tooltips, or tooltips implemented using a full Emacs frame?
> 
> I'm not sure what you mean.  "System tooltips" are only used on GTK
> (optionally) and on OS X (unconditionally) and you cannot control their
> border width via the ‘border-width’ frame parameter.  "Tooltips
> implemented using a full Emacs frame" behave like other frames and for X
> these usually obey the ‘border-width’ frame parameter but only at the
> time they are created.  You can't change the border width of an existing
> frame.

Thanks for this clarification :)

>> Indeed, that's what I'd like. x-show-tip works perfectly for me (it
>> supports fonts, faces, etc. properly), expect for the fact that
>> updating the tooltip text causes it to be closed and reopened.
> 
> That's why IMHO tooltips are not useful for your purpose.  What you
> probably want is a normal undecorated frame whose lifetime, position,
> size, visibility and contents would be completely controlled by you.

Indeed, that seems to be the direction this thread is taking. I'm happy write a patch for that. Thanks for your help!


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-17 13:49                   ` Chris Feng
@ 2016-02-17 14:55                     ` Clément Pit--Claudel
  2016-02-18  1:28                       ` Chris Feng
  0 siblings, 1 reply; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-17 14:55 UTC (permalink / raw)
  To: Chris Feng, martin rudalics; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1467 bytes --]

On 02/17/2016 08:49 AM, Chris Feng wrote:
>>> * add a frame parameter to frame_parms in frame.c, say "chromeless"
>>
>> I'd prefer "decorated" as in gtk_window_set-decorated.
> 
> Agree.  We call it "decoration" in X almost exclusively.
> 
>>> * add an x_set_chromeless slot in each of frame_parm_handler
>>> x_frame_parm_handlers[], frame_parm_handler w32_frame_parm_handlers[],
>>> frame_parm_handler ns_frame_parm_handlers[]; for the last two point to 0 for
>>> now; for the first one point to a new function x_set_chromeless.
>>> * In x-create-frame, add something like
>>>      x_default_parameter (f, parms, Qchromeless, Qnil,
>>>                           "chromeless", "Chromeless", RES_TYPE_BOOLEAN);
> 
> I don't think we need to make this customizable through X resources,
> so the fifth and sixth parameters to x_default_parameter should be
> NULL.

Thanks. I've attached a rough patch draft (that is, frames are decorated by default, but (make-frame '((decorated . nil))) creates an undecorated frame), which works with --with-x-toolkit=none.

>> For X I doubt that it's always possible to add/remove the decorations of
>> an existing frame.
> 
> Yes but it may require remapping if it's already mapped.

Got it; is this why the attached patch doesn't do anything with Gtk? I looked at the Xlib documentation, but I'm not sure how to check if the window is already mapped, and only remap it in that case.

Cheers,
Clément.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Prototype-for-undecorated-frames.patch --]
[-- Type: text/x-diff; name="0001-Prototype-for-undecorated-frames.patch", Size: 3264 bytes --]

From e4cd5c03947a29e73fe7d75167a12ef0b2ed55f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Pit--Claudel?= <clement.pitclaudel@live.com>
Date: Tue, 16 Feb 2016 18:49:57 -0500
Subject: [PATCH] Prototype for undecorated frames

Only works with --with-x-toolkit=none
---
 src/frame.c  |  2 ++
 src/nsfns.m  |  1 +
 src/w32fns.c |  1 +
 src/xfns.c   | 14 ++++++++++++++
 4 files changed, 18 insertions(+)

diff --git a/src/frame.c b/src/frame.c
index 8c86afe..0c74dce 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3065,6 +3065,7 @@ static const struct frame_parm_table frame_parms[] =
   {"fullscreen",                SYMBOL_INDEX (Qfullscreen)},
   {"font-backend",		SYMBOL_INDEX (Qfont_backend)},
   {"alpha",			SYMBOL_INDEX (Qalpha)},
+  {"decorated",			SYMBOL_INDEX (Qdecorated)},
   {"sticky",			SYMBOL_INDEX (Qsticky)},
   {"tool-bar-position",		SYMBOL_INDEX (Qtool_bar_position)},
 };
@@ -4982,6 +4983,7 @@ syms_of_frame (void)
 #endif
 
   DEFSYM (Qalpha, "alpha");
+  DEFSYM (Qdecorated, "decorated");
   DEFSYM (Qauto_lower, "auto-lower");
   DEFSYM (Qauto_raise, "auto-raise");
   DEFSYM (Qborder_color, "border-color");
diff --git a/src/nsfns.m b/src/nsfns.m
index eda94c4..346c1a6 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1006,6 +1006,7 @@ frame_parm_handler ns_frame_parm_handlers[] =
   x_set_fullscreen, /* generic OK */
   x_set_font_backend, /* generic OK */
   x_set_alpha,
+  0, /* x_set_decorated */
   0, /* x_set_sticky */
   0, /* x_set_tool_bar_position */
 };
diff --git a/src/w32fns.c b/src/w32fns.c
index a5018ae..226246b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -9258,6 +9258,7 @@ frame_parm_handler w32_frame_parm_handlers[] =
   x_set_fullscreen,
   x_set_font_backend,
   x_set_alpha,
+  0, /* x_set_decorated */
   0, /* x_set_sticky */
   0, /* x_set_tool_bar_position */
 };
diff --git a/src/xfns.c b/src/xfns.c
index 20ac627..56bae7ce 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3511,6 +3511,8 @@ This function is an internal primitive--use `make-frame' instead.  */)
 		       RES_TYPE_NUMBER);
   x_default_parameter (f, parms, Qalpha, Qnil,
 		       "alpha", "Alpha", RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qdecorated, Qt,
+                       NULL, NULL, RES_TYPE_BOOLEAN);
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   /* Create the menu bar.  */
@@ -5773,6 +5775,17 @@ compute_tip_xy (struct frame *f, Lisp_Object parms, Lisp_Object dx, Lisp_Object
     *root_x = min_x;
 }
 
+void
+x_set_decorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
+{
+  XSetWindowAttributes attributes;
+  attributes.override_redirect = NILP(new_value) ? True : False;
+
+  block_input ();
+  XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                           CWOverrideRedirect, &attributes);
+  unblock_input ();
+}
 
 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
        doc: /* Show STRING in a "tooltip" window on frame FRAME.
@@ -6791,6 +6804,7 @@ frame_parm_handler x_frame_parm_handlers[] =
   x_set_fullscreen,
   x_set_font_backend,
   x_set_alpha,
+  x_set_decorated,
   x_set_sticky,
   x_set_tool_bar_position,
 };
-- 
2.7.1


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-17  9:13                 ` martin rudalics
  2016-02-17 13:49                   ` Chris Feng
@ 2016-02-17 14:57                   ` Clément Pit--Claudel
  2016-02-18 10:51                     ` martin rudalics
  1 sibling, 1 reply; 28+ messages in thread
From: Clément Pit--Claudel @ 2016-02-17 14:57 UTC (permalink / raw)
  To: martin rudalics, Chris Feng; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

On 02/17/2016 04:13 AM, martin rudalics wrote:
>> * add a frame parameter to frame_parms in frame.c, say "chromeless"
> 
> I'd prefer "decorated" as in gtk_window_set-decorated.
> 
>> * add an x_set_chromeless slot in each of frame_parm_handler x_frame_parm_handlers[], frame_parm_handler w32_frame_parm_handlers[], frame_parm_handler ns_frame_parm_handlers[]; for the last two point to 0 for now; for the first one point to a new function x_set_chromeless.
>> * In x-create-frame, add something like
>>      x_default_parameter (f, parms, Qchromeless, Qnil,
>>                           "chromeless", "Chromeless", RES_TYPE_BOOLEAN);
> 
> For X I doubt that it's always possible to add/remove the decorations of
> an existing frame.  For Windows the below works here with
> 
> x_default_parameter (f, parameters, Qdecorated, Qnil,
>                      "decorated", "Decorated", RES_TYPE_SYMBOL);
> (...)

Great, thanks! I will add this to my patch.

Do we need the three states, however? Given that one can separately specify a border width, wouldn't it be enough to have either no caption nor border, or both?

Clément.

 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-17 14:55                     ` Clément Pit--Claudel
@ 2016-02-18  1:28                       ` Chris Feng
  0 siblings, 0 replies; 28+ messages in thread
From: Chris Feng @ 2016-02-18  1:28 UTC (permalink / raw)
  To: Clément Pit--Claudel; +Cc: martin rudalics, emacs-devel

> Got it; is this why the attached patch doesn't do anything with Gtk? I looked at the Xlib documentation, but I'm not sure how to check if the window is already mapped, and only remap it in that case.

You may try to remap it when FRAME_VISIBLE_P returns 0.
XGetWindowAttributes can also be used to get the map state.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?)
  2016-02-17 14:57                   ` Clément Pit--Claudel
@ 2016-02-18 10:51                     ` martin rudalics
  0 siblings, 0 replies; 28+ messages in thread
From: martin rudalics @ 2016-02-18 10:51 UTC (permalink / raw)
  To: Clément Pit--Claudel, Chris Feng; +Cc: emacs-devel

 > Do we need the three states, however? Given that one can separately
 > specify a border width, wouldn't it be enough to have either no
 > caption nor border, or both?

As I tried to explain earlier, on X you apparently cannot "separately
specify a border width" once the window exists (see the corresponding
error in x_set_border_width) and on Windows the ‘border-width’ frame
parameter has no effect anyway.  And frames without border don't look
good.

martin




^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-02-18 10:51 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-12 15:01 Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Clément Pit--Claudel
2016-02-13  2:15 ` Chris Feng
2016-02-13  3:35   ` Clément Pit--Claudel
2016-02-13  3:57     ` Chris Feng
2016-02-16 20:12       ` Creating a "borderless" frame (without WM chrome) (was Re: Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp?) Clément Pit--Claudel
2016-02-16 22:41         ` Chris Feng
2016-02-16 22:55           ` Clément Pit--Claudel
2016-02-16 23:14             ` Chris Feng
2016-02-16 23:46               ` Clément Pit--Claudel
2016-02-17  9:13                 ` martin rudalics
2016-02-17 13:49                   ` Chris Feng
2016-02-17 14:55                     ` Clément Pit--Claudel
2016-02-18  1:28                       ` Chris Feng
2016-02-17 14:57                   ` Clément Pit--Claudel
2016-02-18 10:51                     ` martin rudalics
2016-02-14 14:05     ` Could x-show-tip be reimplemented in Elisp? How does one create borderless frames from Elisp? Stefan Monnier
2016-02-14 16:44       ` Eli Zaretskii
2016-02-14 17:19         ` Stefan Monnier
2016-02-14 18:00           ` Eli Zaretskii
2016-02-16 20:06       ` Clément Pit--Claudel
2016-02-15 10:57 ` martin rudalics
2016-02-15 13:31   ` Stefan Monnier
2016-02-16 20:06     ` Clément Pit--Claudel
2016-02-16 20:05   ` Clément Pit--Claudel
2016-02-16 21:33     ` Johan Bockgård
2016-02-16 22:18       ` Clément Pit--Claudel
2016-02-17  9:12     ` martin rudalics
2016-02-17 14:26       ` Clément Pit--Claudel

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).