unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* x-export-frames for non-Cairo builds
@ 2018-01-25 23:25 Clément Pit-Claudel
  2018-01-26  8:08 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Clément Pit-Claudel @ 2018-01-25 23:25 UTC (permalink / raw)
  To: Emacs developers

Hi emacs-devel,

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)
    {
      struct frame *f = decode_window_system_frame(frame);
      int width = FRAME_PIXEL_WIDTH (f);
      int height = FRAME_PIXEL_HEIGHT (f);
      printf("W, H: %d, %d\n", width, height);

      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);

      return Qnil;
    }

However, I have multiple questions:

* Assuming proper error checking, documentation, and adjustments, would there be interest in merging this?
* IIUC, this code is GTK3-only.  On GTK2, it should be possible to use gdk_pixbuf_get_from_drawable, right? (or is it gdk_pixbuf_xlib_get_from_drawable?).  Both of these gave me linker errors, however.
* Where should this code go? Should it be merged into x-export-frames?
* Is this the right way to capture a screenshot of an Emacs frame in GTK?  Or is there a faster way? (for example, can I defer part of the work of creating the pixbuf, maybe by getting a GdkImage first, and converting later?  I'm hoping to reduce the latency of the screenshot-taking process, even if it requires some post-processing)

Thanks!
Clément.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-02 10:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-01-26 18:56     ` Eli Zaretskii
2018-01-26 23:13       ` Clément Pit-Claudel
2018-02-02 10:30         ` Eli Zaretskii

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).