ch11ng / exwm

Emacs X Window Manager
2.85k stars 134 forks source link

Creating frame via `emacsclient` in desktop file freezes Emacs #751

Closed linux40 closed 4 years ago

linux40 commented 4 years ago

I wish to view images in Emacs, while my default alpha rate of frame is 90% which is not decent for viewing an image.

So I try to create a opaque frame via emacsclient -c -F "((alpha . (100 . 100)))" some.jpg and it works in terminal.

But when it comes to push it into a desktop file as follows and open a image file (e.g. using xdg-open), it freezes Emacs.

[Desktop Entry]
Name=EmacsclientImg
GenericName=Image Viewer
Comment=Image Viewer
MimeType=image/bmp;image/g3fax;image/gif;image/x-fits;image/x-pcx;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-psd;image/x-sgi;image/x-tga;image/x-xbitmap;image/x-xwindowdump;image/x-xcf;image/x-compressed-xcf;image/x-gimp-gbr;image/x-gimp-pat;image/x-gimp-gih;image/tiff;image/jpeg;image/x-psp;image/png;image/x-icon;image/x-xpixmap;image/x-exr;image/x-webp;image/heif;image/heic;image/svg+xml;image/x-wmf;image/jp2;image/x-xcursor;
Exec=emacsclient -c -F "((alpha . (100 . 100)))" %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;

Everything goes well when -c is removed, but I could not get an opaque frame in this situation.

My EXWM version is 0.23 and Emacs version is 27.0.91.

linux40 commented 4 years ago

Finally I created an opaque frame via image-mode-hook. Feel free to close this issue, or you want to achieve creating frame from a desktop file.

medranocalvo commented 4 years ago

Thank you for your report.

Well, it would be good getting .desktop files to work with emacsclient in a way that frame parameters can be set. It can be useful to users of EXWM. On the other hand, it is out of scope for EXWM, in the sense that as long as it works for regular Emacs it should work for EXWM.

If someone gets it to work, we should add it to the Wiki. Till then, I'm closing this issue.

As for your image-mode-hook customization, do you think that it can be useful for other users that want to achieve your same goal? If so, could you add it to the newly created https://github.com/ch11ng/exwm/wiki/Cookbook wiki page?

ch11ng commented 4 years ago

One problem is whenever you create a new Emacs frame it becomes a new EXWM workspace. Unless that's what is intended you may instead want to preserve a opaque workspace specifically for such use.

linux40 commented 4 years ago

It doesn't matter whether frames will become workspaces. The thing I want is an opaque background. My customization is just:

;; -*- lexical-binding: t -*-

(let (frame)
  (add-hook 'image-mode-hook
            (lambda () (let ((buffer (current-buffer)))
                         (unless (and frame (frame-live-p frame))
                           (setq frame (make-frame '((alpha . (100 . 100))))))
                         (select-frame frame) (switch-to-buffer buffer)))))

But it does have a problem. If I close the workspace without killing the image buffer, an opaque workspace will not be created again.

And I'm going to make mode line display the resolution of images.

medranocalvo commented 4 years ago

I understand. It think this is quite particular, and not any longer related to EXWM.

I'm closing the ticket, but feel free to reopen if you find issues.