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

From: "arthur.miller.no1" <[email-masked]>
Date: Wed, 11 Jan 2017 15:59:59 +0100

Aha thanks for clarifications. I didn't dive enough into src so I missed those other funcrions called before a frame is made.
I had from beginnig nil and t as values for my decor var, but I realized I could use 1 and 0 too so I did :). It works fine to switch it off/on manually.
I am away from home untill friday so it will have to wait before I can play more with emacs. Also if you going to merge your code into master on git soon, then I will probably abandon my changes and use yours :).
Skickat från min Samsung-enhet

-------- Originalmeddelande --------
Från: martin rudalics <[email-masked]> 
Datum: 2017-01-11  14:55  (GMT+01:00) 
Till: Arthur Miller <[email-masked]> 
Kopia: Clément Pit--Claudel <[email-masked]>, Eli Zaretskii <[email-masked]>, [email-masked] 
Rubrik: Re: bug#25408: Remove Decorations Around Emacs Frame (Windows OS) 

 > (add-to-list 'default-frame-alist '(undecorated . 0))
 > (setq default-frame-alist '((undecorated . 0)))
 > (setq initial-frame-alist '((undecorated . 0)))
 >
 > But that does not give any effect at all.

"0" is a quite misleading value ;-) See below.

But I think I understand what happens.  In fact, I haven't told you the
whole story: In Fx_create_frame I do additionally

   tem = x_get_arg (dpyinfo, parameters, Qundecorated, NULL, NULL,
		       RES_TYPE_BOOLEAN);
   FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);

somewhere _before_ w32_window (f, window_prompting, minibuffer_only)
gets called.  And in w32_createwindow I have

   else if (FRAME_UNDECORATED (f))
     {
       f->output_data.w32->dwStyle = ~WS_THICKFRAME & ~WS_CAPTION;

       /* If we want a thin border, specify it here.  */
       if (NUMBERP (border_width) && (XINT (border_width) > 0))
	f->output_data.w32->dwStyle =
	  f->output_data.w32->dwStyle | WS_BORDER;
     }

before any other f->output_data.w32->dwStyle assignment and certainly
before the

   FRAME_W32_WINDOW (f) = hwnd
     = CreateWindow (EMACS_CLASS,
		    f->namebuf,
		    f->output_data.w32->dwStyle,
		    ...

call.  Just make sure that any time you set f->output_data.w32->dwStyle
you don't overrule a previous assignment.  (I haven't sent you a patch
because I have completely redesigned the assignments to this component
and it probably would distract more than provide any help.)  This way

(add-to-list 'default-frame-alist '(undecorated . t))
(setq default-frame-alist '((undecorated . t)))
(setq initial-frame-alist '((undecorated . t)))

should all work.

BTW, you can also do

       f->output_data.w32->dwStyle = WS_POPUP;

because the only thing Windows forbids in this context is to set
WS_POPUP for an existing overlapped window (IIRC).

 > (defvar decor 0)
 > (defun toggle-frame-decor ()
 >    (interactive)
 >    (progn
 >     (modify-frame-parameters (selected-frame) `((undecorated . ,'decor)))

You likely mean

      (modify-frame-parameters (selected-frame) `((undecorated . ,decor)))

here.  And probably you want to do the following calculation

 >     (if (= decor 0)
 >         (setq decor 1)
 >       (setq decor 0))))

before calling ‘modify-frame-parameters’ so the latter will see the new
value.  But even this won't work because you want to toggle beween nil
and non-nil so

(devfar decor nil)

and

(setq decor (not decor))

are more appropriate.

martin