Bug#1033471: maximize* commands don't work for Emacs is working for GNOME (Debian Stable (devilspie2_0.43-4_amd64.deb) + MATE installed from tasksel), and MATE (Debian Unstable (devilspie2_0.43-5_amd6

2023-05-13 Thread David Hedlund

###

* Debian Stable (devilspie2_0.43-4_amd64.deb) + MATE installed from tasksel


   *    Works!: Open GNOME. Open $ devilspie in the terminal. Open
   emacs. It actually opens maximized!*

        Note that MATE is required. Without MATE: Debian Stable 
(devilspie2_0.43-4_amd64.deb). Open GNOME. Cannot run $ devilspie in the 
terminal: "An X11 display is required for devilspie2."[1]


    Does not work: Open MATE. Open $ devilspie in the terminal. Open 
emacs. The Emacs window is not maximized.



* Debian Testing (devilspie2_0.43-5_amd64.deb) + MATE installed from tasksel

   Does not work: Open GNOME. Cannot run $ devilspie in the terminal: 
"An X11 display is required for devilspie2."[1]


   Does not work: Open MATE. Open $ devilspie in the terminal. Open 
emacs. The Emacs window is not maximized.



* Debian Unstable (devilspie2_0.43-5_amd64.deb) + MATE installed from 
tasksel


   Does not work: Open GNOME. Cannot run $ devilspie in the terminal: 
"An X11 display is required for devilspie2."[1]



   Works!: Open MATE. Open $ devilspie in the terminal. Open
   emacs. It actually opens maximized!




References

1: Devilspie2 fails to run under Xwayland - 
http://savannah.nongnu.org/bugs/?46746




Bug#1033471: maximize* commands don't work for Emacs

2023-03-25 Thread David Hedlund

Package: devilspie2
Version: 0.42

###
Affected devilspie2 commands

The command that I'm describing in the sections below is maximize(). However, 
I've also failed with these maximize* commands for Emacs:
- maximize_horizontally()
- maximize_vertically()

#
Background

"To avoid the slightly distracting visual effect of Emacs starting with its default 
frame size and then growing to fullscreen, you can add..." - Emacs FAQ

I added this to .emacs:
```
;; Cirumvent the visual distracting effect caused by: `(add-to-list 
'default-frame-alist '(fullscreen . maximized))` that is added later
(setq frame-resize-pixelwise t)
(set-frame-position (selected-frame) 0 0)
(set-frame-size (selected-frame) (display-pixel-width) (display-pixel-height) t)
;; (display-pixel-width) and (display-pixel-height) above will detect the 
correct resolution, they can be replaced with their values or half their values 
if you want to experiment with them.


;; Maximize the frame
(add-to-list 'default-frame-alist '(fullscreen . maximized))
```

However, the hack did not remove the/visually distracting effect/, so I decided 
to give devilspie2 a shot instead:

#
devilspie2 setup

Add this to ~/.config/devilspie2/test.lua:
```
debug_print("Window Name: " .. get_window_name())
debug_print("Application name: " .. get_application_name())
debug_print("WM_CLASS: " .. get_class_instance_name())
debug_print("Window Class: " .. get_window_class())

if (get_class_instance_name() == "mate-terminal") then maximize(); end -- works
if (get_class_instance_name() == "emacs") then
  maximize(); -- does not work
  set_window_workspace(2); -- works!
end
```

Then run: `devilspie2 --debug &`

Open mate-terminal, it will give you this output in the terminal:
```
Window Name: Terminal
Application name: Terminal
WM_CLASS: mate-terminal
Window Class: Mate-terminal
```

Open Emacs, it will give you this output in the terminal:
```
Window Name: emacs@username-System-Product-Name
Application name: emacs
WM_CLASS: emacs
Window Class: Emacs
```

devilspie2 moved the Emacs window to the second workspace in the DE, and it 
maximized the mate-terminal.
However, it did not maximize Emacs (without error reports). With a more 
profound evaluation, it actually
maximized the Emacs window 2 out of 100 times when I opened multiple devilspie2 
sessions (I could not reproduce this by re-opening Emacs 100 times in a single 
session):
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times. <-- Maximized the first time I 
opened it (5 devilspie2 sessions open)
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times. <-- Maximized the first time I 
opened it (6 devilspie2 sessions open)
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.
- Ctrl+C, open another session:
- devilspie2 --debug &
- open emacs. close emacs. Repeat 10 times.