[Top][All Lists]

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

Re: x-export-frames for non-Cairo builds

From: Clément Pit-Claudel
Subject: Re: x-export-frames for non-Cairo builds
Date: Fri, 26 Jan 2018 11:08:17 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 2018-01-26 03:08, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <address@hidden>
>> 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.


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


I hope someone can comment on 
gdk_pixbuf_get_from_drawable/gdk_pixbuf_xlib_get_from_drawable :)

Thanks again,

reply via email to

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