unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: x-export-frames for non-Cairo builds
Date: Fri, 26 Jan 2018 11:08:17 -0500	[thread overview]
Message-ID: <dc5ae7c7-73e1-72c8-58b7-6f80a68c6aae@gmail.com> (raw)
In-Reply-To: <83372tm491.fsf@gnu.org>

On 2018-01-26 03:08, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <cpitclaudel@gmail.com>
>> Date: Thu, 25 Jan 2018 18:25:55 -0500
>>
>> I'd like to capture screenshots of Emacs frames from inside Emacs (currently I use `import' or `xwd', but they don't always work well).
>> On Cairo there's x-export-frame, but I don't think there's an equivalent function for other builds.
>>
>> The following draft seems to work nicely for me (on GTK3)
>>
>>     DEFUN ("x-export-png", Fx_export_png, Sx_export_png, 0, 1, 0,
>>            doc: /* Save FRAME as 'screenshot.png'. */)
>>          (Lisp_Object frame)
>>     {
> 
> Please, not another x-FOO function that is very likely to have 4
> different implementations.  Instead, please define a single function
> whose name does NOT start with "x-", and make it have a GTK-specific
> and a Cairo-specific implementation, which (the implementations)
> ideally should not be exported to Lisp.

Thanks; understood. I will prepare a patch.

>>       GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
>>       GdkPixbuf *pb = gdk_pixbuf_get_from_window(w, 0, 0, width, height);
>>       gdk_pixbuf_save (pb, "/tmp/screenshot.png", "png", NULL, NULL);
> 
> That hard-coded file name is a no-no. 

Yes, of course.  Sorry if it was unclear that I didn't intend to propose to merge this code as-is ^^

> The function should probably
> accept an optional file name, and by default use some defcustom, which
> I think should be a relative file name, i.e. created in the current
> directory.  AFAIU, the image format should also be an optional
> argument (even though not all GUI frames will support that).

OK, these are great ideas.  But do you think it's better to save the image, rather than what x-export-frame currently does?

>> * Assuming proper error checking, documentation, and adjustments, would there be interest in merging this?
> 
> Yes.  Implementations for other window-systems are welcome.

Super.

>> * Where should this code go? Should it be merged into x-export-frames?
> 
> frame.c looks like the best place to me.

Great.

I hope someone can comment on gdk_pixbuf_get_from_drawable/gdk_pixbuf_xlib_get_from_drawable :)

Thanks again,
Clément.



  parent reply	other threads:[~2018-01-26 16:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25 23:25 x-export-frames for non-Cairo builds Clément Pit-Claudel
2018-01-26  8:08 ` Eli Zaretskii
2018-01-26 14:45   ` Stefan Monnier
2018-01-26 16:08   ` Clément Pit-Claudel [this message]
2018-01-26 18:56     ` Eli Zaretskii
2018-01-26 23:13       ` Clément Pit-Claudel
2018-02-02 10:30         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc5ae7c7-73e1-72c8-58b7-6f80a68c6aae@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).