bug-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Arthur Miller
Subject: bug#25408: Remove Decorations Around Emacs Frame (Windows OS)
Date: Wed, 11 Jan 2017 09:15:03 +0100

I am beggin of pardon, but I found that sometimes, just sometimes, even switching
decorations on leaves some cosmetic issues. I took a screenshot and upload it to
imgur: http://imgur.com/a/kCW8j . It is same issue as with putting decorations on.
Adding that PostMessage to send wm_size after the if-else statement solves it in
all cases.

2017-01-11 8:50 GMT+01:00 Arthur Miller <arthur.miller.no1@gmail.com>:
Aha, my last message ended somehow in bad spot in message tree. I
appologize for inconvenience.

2017-01-11 8:48 GMT+01:00 Arthur Miller <arthur.miller.no1@gmail.com>:
There is a slightly cosmetic issue with above function. When one switches back on decorations,
the frame will not resize properly and minibuffer will be not visible. It's there but just
covered by frame. Just resizing emacs framefixes it.

Adding call to PostMessage(hwnd, WM_SIZE,0,0) in Martins function fixes it.

void
x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
{
  HWND hwnd = FRAME_W32_WINDOW (f);
  DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);
  /*Lisp_Object border_width = Fcdr (Fassq (Qborder_width, f->param_alist));*/
  /*Lisp_Object undecorated = Fcdr (Fassq (Qundecorated, f->param_alist));*/

  block_input ();
  if (!NILP (new_value) && !FRAME_UNDECORATED (f))
    {
      dwStyle = (dwStyle & ~WS_THICKFRAME & ~WS_CAPTION);

      SetWindowLong (hwnd, GWL_STYLE, dwStyle);
      SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
                    SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
                    | SWP_FRAMECHANGED);
      FRAME_UNDECORATED (f) = true;
    }
  else if (!NILP (new_value) && FRAME_UNDECORATED (f))
    {
      SetWindowLong (hwnd, GWL_STYLE, dwStyle | WS_THICKFRAME | WS_CAPTION
                     | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU);
      SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
                    SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
                    | SWP_FRAMECHANGED);
      PostMessage(hwnd, WM_SIZE,0,0);
      FRAME_UNDECORATED (f) = false;
    }
  unblock_input ();
}


2017-01-11 8:24 GMT+01:00 Arthur Miller <arthur.miller.no1@gmail.com>:
I appologize, I was too fast to answer, I made a bad call from modify-frame-parameters
when I tested it. It works like a charm as you say it in english. I have also changed
the else-if statement in Martins method to else if (!NILP (new_value) && FRAME_UNDECORATED (f))
(check for !NILP) so I can switch back decorations. It works. Thanks all, it was great
exercise to learn a bit of emacs internals and to make a simple hack.

2017-01-11 8:08 GMT+01:00 Arthur Miller <arthur.miller.no1@gmail.com>:
"We call it "Losedows" or "Lose OS", because if you use it, you lose
your freedom.

We're glad if Emacs gives you a taste of freedom, but a taste is
all it can give you.  To escape from Microsoft's power, you need to
stop using Losedows."

Haha :-) Indeed.

I do run Arch Linux otherwise, but I do some consulting with programming
databases and GUIs in access & spss and I also play some games
occasionally, so I still need losedows. I know I could run it in wine and
pass through vga, but I feel a bit too old for that :).

This was a great excursion in Emacs src code. I added above mention
method to my w32fns.c, added FRAME_DECORATED() macro to frame.h
a boolean_bf undecorated :1, to frame struct, initiated it to false in "make_frame"
added an entry to frame_parms: {"undecorated",        SYMBOL_INDEX (Qundecorated)},
added connecction to w32_frame_parm_handlers[] to x_set_undecorated at same
place where symbol is declared in frame_parms (last in the list), added an
INLINE void fset_undecorated( ... ) to frame.h (not sure if it is needed), and now
I can change my new param with lisp from emacs, but my connection seem
never to be called.

By the way, I think world is better without borders, so I have modified Martin's
x_set_undecorated to

void
x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
{
  HWND hwnd = FRAME_W32_WINDOW (f);
  DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);
  /*Lisp_Object border_width = Fcdr (Fassq (Qborder_width, f->param_alist));*/
  /*Lisp_Object undecorated = Fcdr (Fassq (Qundecorated, f->param_alist));*/

  block_input ();
  if (!NILP (new_value) && !FRAME_UNDECORATED (f))
    {
      dwStyle = (dwStyle & ~WS_THICKFRAME & ~WS_CAPTION);
      SetWindowLong (hwnd, GWL_STYLE, dwStyle);
      SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
                    SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
                    | SWP_FRAMECHANGED);
      FRAME_UNDECORATED (f) = true;
    }
  else if (NILP (new_value) && FRAME_UNDECORATED (f))
    {
      SetWindowLong (hwnd, GWL_STYLE, dwStyle | WS_THICKFRAME | WS_CAPTION
                     | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU);
      SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0,
                    SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
                    | SWP_FRAMECHANGED);
      FRAME_UNDECORATED (f) = false;
    }
  unblock_input ();
}

So it should just switch on "undecorated" param and ignore borders (at least I hope). I am not sure where do
I have to make change more to get it to work.

2017-01-10 21:39 GMT+01:00 Clément Pit--Claudel <clement.pit@gmail.com>:
On 2017-01-10 13:27, Eli Zaretskii wrote:
> Then I suggest to add this to Emacs.  That some wm's ignore it is not
> a reason to avoid having the feature for those that don't ignore it.

Indeed, it would be wonderful!







reply via email to

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