discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=1ac25835dbcb2452ec4154945e941e0c210f24c8

commit 1ac25835dbcb2452ec4154945e941e0c210f24c8
Author: Mike Blumenkrantz <[email protected]>
Date:   Fri May 9 10:35:10 2014 -0400

    screenshot now displays a helpful error message when it fails
    
    now that larger xinerama setups are getting more common, it's also the case 
that shm creation is more likely to fail due to SHMMAX defaults only working on 
displays smaller than than 8,388,609 total pixels. in this case, we print a 
helpful error message so the user can (optionally) increase SHMMAX
---
 src/modules/shot/e_mod_main.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c
index 4d34f29..f61483e 100644
--- a/src/modules/shot/e_mod_main.c
+++ b/src/modules/shot/e_mod_main.c
@@ -653,7 +653,36 @@ _shot_now(E_Zone *zone, E_Client *ec, const char *params)
         depth = ec->depth;
      }
    img = ecore_x_image_new(w, h, visual, depth);
-   ecore_x_image_get(img, xwin, x, y, 0, 0, sw, sh);
+   if (!ecore_x_image_get(img, xwin, x, y, 0, 0, sw, sh))
+     {
+        Eina_Bool dialog = EINA_FALSE;
+        ecore_x_image_free(img);
+#ifdef __linux__
+        FILE *f;
+
+        f = fopen("/proc/sys/kernel/shmmax", "r");
+        if (f)
+          {
+             long long unsigned int max = 0;
+
+             fscanf(f, "%llu", &max);
+             if (max && (max < (w * h * sizeof(int))))
+               {
+                  e_util_dialog_show(_("Screenshot Error"),
+                                      _("SHMMAX is too small to take 
screenshot.<br>"
+                                        "Consider increasing 
/proc/sys/kernel/shmmax to a value larger than %llu"),
+                                        (long long unsigned int)(w * h * 
sizeof(int)));
+                  dialog = EINA_TRUE;
+               }
+             fclose(f);
+          }
+#endif
+        if (!dialog)
+          e_util_dialog_show(_("Screenshot Error"),
+                             _("SHM creation failed.<br>"
+                               "Ensure your system has enough RAM free and 
your user has sufficient permissions."));
+        return;
+     }
    src = ecore_x_image_data_get(img, &bpl, &rows, &bpp);
    display = ecore_x_display_get();
    scr = ecore_x_default_screen_get();

-- 


Reply via email to