GTK/GDK Algorithm to take full screenshots of all monitors
Asked Answered
W

1

2

I'm fairly new to the whole GTK game and want to create an algorithm to take screen shot of all monitors.

I was thinking something along these lines:

  1. gdk_display_manager_list_displays
  2. each display can have multiple screens (screens means monitors?) so use gdk_display_get_n_screens to get monitors per display from 1
  3. get root gtk window of all screens from 2
  4. create new Pixbuf for each root gtk window for each screen from 3 with gdk_pixbuf_new
  5. fill each pixbuf from 4 with gdk_pixbuf_get_from_drawable for each respective root window from 3 for each respective screen from 2 for each respective display from 1 (may need to gdk_drawable_get_size and gdk_window_get_origin for each for args to pixbuf)
  6. gdk_pixbuf_get_pixels for each pixbuf

Is this a workable solution?

Winebibber answered 9/5, 2015 at 22:7 Comment(3)
I think it can work. Here is a link: git.xfce.org/apps/xfce4-screenshooter/tree/lib/…Diplodocus
Thanks @Diplodocus ! I wrote this version up here in js-ctypes: github.com/Noitidart/NativeShot/blob/gdk-experimental/modules/… however its getting null when i try gdk3 method of gdk_pixbuf_get_from_window and its crashing when i try gdk2 method of gdk_pixbuf_get_from_drawable :(Winebibber
My comment was too long so I posted an answer. I think the solution will involve a lot of trial and error on your side though.Diplodocus
D
1

If you are sure cRootWin is not NULL and cWidth and cHeight are greater than 0 then you should check for some additional problem mentioned by the doc.

A wild guess is your program does not have enough memory to store the pixmap (typically 6 Mb). I would try to allocate the 12 Mb just to see if this is the case.

Diplodocus answered 19/5, 2015 at 6:57 Comment(1)
Thanks @ntd!! This helps ill update you on progres! :)Winebibber

© 2022 - 2024 — McMap. All rights reserved.