2012-11-30 06:38:34 -08:00
|
|
|
/**
|
|
|
|
* @addtogroup Optional_Look
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @defgroup Module_Shot Screenshot
|
|
|
|
*
|
|
|
|
* Takes screen shots and can submit them to http://enlightenment.org
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
2011-05-27 23:53:44 -07:00
|
|
|
#include "e.h"
|
2015-07-08 12:12:44 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
# include "screenshooter-client-protocol.h"
|
|
|
|
#endif
|
2012-07-23 00:18:52 -07:00
|
|
|
#include <time.h>
|
2015-07-08 12:12:44 -07:00
|
|
|
#include <sys/mman.h>
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static E_Module *shot_module = NULL;
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
static E_Action *border_act = NULL, *act = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
static E_Int_Menu_Augmentation *maug = NULL;
|
2012-07-19 03:02:26 -07:00
|
|
|
static Ecore_Timer *timer, *border_timer = NULL;
|
2014-11-02 18:35:13 -08:00
|
|
|
static Evas_Object *win = NULL;
|
2012-12-14 08:02:03 -08:00
|
|
|
E_Confirm_Dialog *cd = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
static Evas_Object *o_bg = NULL, *o_box = NULL, *o_content = NULL;
|
|
|
|
static Evas_Object *o_event = NULL, *o_img = NULL, *o_hlist = NULL;
|
|
|
|
static int quality = 90;
|
|
|
|
static int screen = -1;
|
|
|
|
#define MAXZONES 64
|
|
|
|
static Evas_Object *o_rectdim[MAXZONES] = { NULL };
|
2011-05-29 16:45:40 -07:00
|
|
|
static Evas_Object *o_radio_all = NULL;
|
2011-05-29 02:45:19 -07:00
|
|
|
static Evas_Object *o_radio[MAXZONES] = { NULL };
|
2011-05-27 23:53:44 -07:00
|
|
|
static Evas_Object *o_fsel = NULL;
|
|
|
|
static Evas_Object *o_label = NULL;
|
|
|
|
static Evas_Object *o_entry = NULL;
|
|
|
|
static unsigned char *fdata = NULL;
|
|
|
|
static int fsize = 0;
|
|
|
|
static Ecore_Con_Url *url_up = NULL;
|
|
|
|
static Eina_List *handlers = NULL;
|
|
|
|
static char *url_ret = NULL;
|
2012-07-19 03:31:34 -07:00
|
|
|
static E_Dialog *fsel_dia = NULL;
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
static E_Client_Menu_Hook *border_hook = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
Eina_Bool copy_done = EINA_FALSE;
|
|
|
|
static struct screenshooter *_wl_screenshooter;
|
|
|
|
static Eina_List *_outputs;
|
|
|
|
struct screenshooter_output
|
|
|
|
{
|
|
|
|
struct wl_output *output;
|
|
|
|
struct wl_buffer *buffer;
|
|
|
|
int x, y, w, h;
|
2015-08-12 17:19:18 -07:00
|
|
|
uint32_t id;
|
2015-07-08 12:12:44 -07:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-03-18 15:09:09 -07:00
|
|
|
static void _file_select_ok_cb(void *data EINA_UNUSED, E_Dialog *dia);
|
|
|
|
static void _file_select_cancel_cb(void *data EINA_UNUSED, E_Dialog *dia);
|
2012-07-19 03:31:34 -07:00
|
|
|
|
2012-09-22 07:13:31 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_win_cancel_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
|
2012-09-22 07:13:31 -07:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
static void
|
|
|
|
_wl_cb_screenshot_done(void *data EINA_UNUSED, struct screenshooter *screenshooter EINA_UNUSED)
|
|
|
|
{
|
|
|
|
copy_done = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct screenshooter_listener _screenshooter_listener =
|
|
|
|
{
|
|
|
|
_wl_cb_screenshot_done
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_output_cb_handle_geometry(void *data EINA_UNUSED, struct wl_output *wl_output, int x, int y, int pw EINA_UNUSED, int ph EINA_UNUSED, int subpixel EINA_UNUSED, const char *make EINA_UNUSED, const char *model EINA_UNUSED, int transform EINA_UNUSED)
|
|
|
|
{
|
|
|
|
struct screenshooter_output *output;
|
|
|
|
|
|
|
|
output = wl_output_get_user_data(wl_output);
|
|
|
|
if ((output) && (wl_output == output->output))
|
|
|
|
{
|
|
|
|
output->x = x;
|
|
|
|
output->y = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_output_cb_handle_mode(void *data EINA_UNUSED, struct wl_output *wl_output, uint32_t flags, int w, int h, int refresh EINA_UNUSED)
|
|
|
|
{
|
|
|
|
struct screenshooter_output *output;
|
|
|
|
|
|
|
|
output = wl_output_get_user_data(wl_output);
|
|
|
|
if ((output) &&
|
|
|
|
((wl_output == output->output) && (flags & WL_OUTPUT_MODE_CURRENT)))
|
|
|
|
{
|
|
|
|
output->w = w;
|
|
|
|
output->h = h;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_output_cb_handle_done(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_output_cb_handle_scale(void *data EINA_UNUSED, struct wl_output *output EINA_UNUSED, int32_t scale EINA_UNUSED)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_output_listener _output_listener =
|
|
|
|
{
|
|
|
|
_wl_output_cb_handle_geometry,
|
|
|
|
_wl_output_cb_handle_mode,
|
|
|
|
_wl_output_cb_handle_done,
|
|
|
|
_wl_output_cb_handle_scale
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2014-11-02 18:35:13 -08:00
|
|
|
_win_delete_cb()
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
win = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_on_focus_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (obj == o_content) e_widget_focused_object_clear(o_box);
|
|
|
|
else if (o_content) e_widget_focused_object_clear(o_content);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev = event;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-03-13 10:00:57 -07:00
|
|
|
if (!strcmp(ev->key, "Tab"))
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
if (evas_key_modifier_is_set(evas_key_modifier_get(evas_object_evas_get(win)), "Shift"))
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (e_widget_focus_get(o_box))
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(o_box, 0))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(o_content, 0);
|
|
|
|
if (!e_widget_focus_get(o_content))
|
|
|
|
e_widget_focus_set(o_box, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(o_content, 0))
|
|
|
|
e_widget_focus_set(o_box, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (e_widget_focus_get(o_box))
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(o_box, 1))
|
|
|
|
{
|
|
|
|
e_widget_focus_set(o_content, 1);
|
|
|
|
if (!e_widget_focus_get(o_content))
|
|
|
|
e_widget_focus_set(o_box, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!e_widget_focus_jump(o_content, 1))
|
|
|
|
e_widget_focus_set(o_box, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-13 10:00:57 -07:00
|
|
|
else if (((!strcmp(ev->key, "Return")) ||
|
|
|
|
(!strcmp(ev->key, "KP_Enter")) ||
|
|
|
|
(!strcmp(ev->key, "space"))))
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o = NULL;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
if ((o_content) && (e_widget_focus_get(o_content)))
|
2014-07-01 03:51:04 -07:00
|
|
|
o = e_widget_focused_object_get(o_content);
|
2011-05-27 23:53:44 -07:00
|
|
|
else
|
2014-07-01 03:51:04 -07:00
|
|
|
o = e_widget_focused_object_get(o_box);
|
2011-05-27 23:53:44 -07:00
|
|
|
if (o) e_widget_activate(o);
|
2014-07-01 03:51:04 -07:00
|
|
|
}
|
2014-03-13 10:00:57 -07:00
|
|
|
else if (!strcmp(ev->key, "Escape"))
|
2012-09-22 07:13:31 -07:00
|
|
|
_win_cancel_cb(NULL, NULL);
|
2014-07-01 03:51:04 -07:00
|
|
|
}
|
2011-05-27 23:53:44 -07:00
|
|
|
|
2012-07-19 03:31:34 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_save_key_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event)
|
2012-07-19 03:31:34 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Key_Down *ev = event;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
2014-03-13 10:00:57 -07:00
|
|
|
if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
|
2012-08-02 05:19:11 -07:00
|
|
|
_file_select_ok_cb(NULL, fsel_dia);
|
2014-03-13 10:00:57 -07:00
|
|
|
else if (!strcmp(ev->key, "Escape"))
|
2012-08-02 05:19:11 -07:00
|
|
|
_file_select_cancel_cb(NULL, fsel_dia);
|
2014-07-01 03:51:04 -07:00
|
|
|
}
|
2012-07-19 03:31:34 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_screen_change_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Zone *z;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-03-18 14:34:31 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, z)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (screen == -1)
|
2014-07-01 03:51:04 -07:00
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 0);
|
2011-05-27 23:53:44 -07:00
|
|
|
else if (screen == (int)z->num)
|
2014-07-01 03:51:04 -07:00
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 0);
|
2011-05-27 23:53:44 -07:00
|
|
|
else
|
2014-07-01 03:51:04 -07:00
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 200);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_save_to(const char *file)
|
|
|
|
{
|
|
|
|
char opts[256];
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-03-13 09:33:35 -07:00
|
|
|
if (eina_str_has_extension(file, ".png"))
|
2014-07-01 03:51:04 -07:00
|
|
|
snprintf(opts, sizeof(opts), "compress=%i", 9);
|
2011-05-27 23:53:44 -07:00
|
|
|
else
|
2014-07-01 03:51:04 -07:00
|
|
|
snprintf(opts, sizeof(opts), "quality=%i", quality);
|
2011-05-27 23:53:44 -07:00
|
|
|
if (screen == -1)
|
|
|
|
{
|
2014-01-21 04:21:13 -08:00
|
|
|
if (o_img)
|
|
|
|
{
|
|
|
|
if (!evas_object_image_save(o_img, file, NULL, opts))
|
2014-07-01 03:51:04 -07:00
|
|
|
e_util_dialog_show(_("Error saving screenshot file"),
|
|
|
|
_("Path: %s"), file);
|
2014-01-21 04:21:13 -08:00
|
|
|
}
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Evas_Object *o;
|
|
|
|
Eina_List *l;
|
|
|
|
E_Zone *z = NULL;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-03-18 14:34:31 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, z)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (screen == (int)z->num) break;
|
|
|
|
z = NULL;
|
|
|
|
}
|
|
|
|
if (z)
|
|
|
|
{
|
|
|
|
unsigned char *src, *dst, *s, *d;
|
2014-01-21 04:21:13 -08:00
|
|
|
int sstd, dstd, y;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = evas_object_image_add(evas_object_evas_get(o_img));
|
|
|
|
evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888);
|
|
|
|
evas_object_image_alpha_set(o, EINA_FALSE);
|
|
|
|
evas_object_image_size_set(o, z->w, z->h);
|
2014-01-21 04:21:13 -08:00
|
|
|
dstd = evas_object_image_stride_get(o);
|
2011-05-27 23:53:44 -07:00
|
|
|
src = evas_object_image_data_get(o_img, EINA_FALSE);
|
|
|
|
sstd = evas_object_image_stride_get(o_img);
|
|
|
|
dst = evas_object_image_data_get(o, EINA_TRUE);
|
2014-01-21 04:21:13 -08:00
|
|
|
if ((dstd > 0) && (sstd > 0) && (src) && (dst))
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2014-01-21 04:21:13 -08:00
|
|
|
d = dst;
|
|
|
|
for (y = z->y; y < z->y + z->h; y++)
|
|
|
|
{
|
|
|
|
s = src + (sstd * y) + (z->x * 4);
|
|
|
|
memcpy(d, s, z->w * 4);
|
|
|
|
d += dstd;
|
|
|
|
}
|
|
|
|
if (!evas_object_image_save(o, file, NULL, opts))
|
2014-07-01 03:51:04 -07:00
|
|
|
e_util_dialog_show(_("Error saving screenshot file"),
|
|
|
|
_("Path: %s"), file);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
2012-09-11 16:01:32 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_del(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_file_select_ok_cb(void *data EINA_UNUSED, E_Dialog *dia)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
const char *file;
|
|
|
|
|
2012-07-19 03:31:34 -07:00
|
|
|
dia = fsel_dia;
|
2011-05-27 23:53:44 -07:00
|
|
|
file = e_widget_fsel_selection_path_get(o_fsel);
|
2015-07-06 06:37:52 -07:00
|
|
|
if ((!file) || (!file[0]) ||
|
|
|
|
((!eina_str_has_extension(file, ".jpg")) &&
|
|
|
|
(!eina_str_has_extension(file, ".png"))))
|
2012-07-17 03:48:30 -07:00
|
|
|
{
|
|
|
|
e_util_dialog_show
|
2014-07-01 03:51:04 -07:00
|
|
|
(_("Error - Unknown format"),
|
|
|
|
_("File has an unspecified extension.<br>"
|
|
|
|
"Please use '.jpg' or '.png' extensions<br>"
|
|
|
|
"only as other formats are not<br>"
|
|
|
|
"supported currently."));
|
2012-07-17 03:48:30 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
_save_to(file);
|
2011-05-27 23:53:44 -07:00
|
|
|
if (dia) e_util_defer_object_del(E_OBJECT(dia));
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2012-07-19 03:31:34 -07:00
|
|
|
fsel_dia = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_file_select_cancel_cb(void *data EINA_UNUSED, E_Dialog *dia)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (dia) e_util_defer_object_del(E_OBJECT(dia));
|
2012-07-19 03:31:34 -07:00
|
|
|
fsel_dia = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
2012-08-24 07:19:55 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_file_select_del_cb(void *d EINA_UNUSED)
|
2012-08-24 07:19:55 -07:00
|
|
|
{
|
|
|
|
fsel_dia = NULL;
|
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_win_save_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
Evas_Object *o;
|
|
|
|
Evas_Coord mw, mh;
|
2012-07-19 03:31:34 -07:00
|
|
|
int mask = 0;
|
2012-07-23 00:18:52 -07:00
|
|
|
time_t tt;
|
|
|
|
struct tm *tm;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
time(&tt);
|
|
|
|
tm = localtime(&tt);
|
|
|
|
if (quality == 100)
|
|
|
|
strftime(buf, sizeof(buf), "shot-%Y-%m-%d_%H-%M-%S.png", tm);
|
|
|
|
else
|
|
|
|
strftime(buf, sizeof(buf), "shot-%Y-%m-%d_%H-%M-%S.jpg", tm);
|
2014-11-02 18:35:13 -08:00
|
|
|
fsel_dia = dia = e_dialog_new(NULL, "E", "_e_shot_fsel");
|
2014-12-22 06:02:05 -08:00
|
|
|
e_dialog_resizable_set(dia, EINA_TRUE);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_dialog_title_set(dia, _("Select screenshot save location"));
|
2014-11-02 18:35:13 -08:00
|
|
|
o = e_widget_fsel_add(evas_object_evas_get(dia->win), "desktop", "/",
|
2015-07-06 06:37:52 -07:00
|
|
|
buf, NULL, NULL, NULL, NULL, NULL, 1);
|
2012-08-24 07:19:55 -07:00
|
|
|
e_object_del_attach_func_set(E_OBJECT(dia), _file_select_del_cb);
|
2015-04-27 12:39:43 -07:00
|
|
|
e_widget_fsel_window_set(o, dia->win);
|
2011-05-27 23:53:44 -07:00
|
|
|
o_fsel = o;
|
|
|
|
evas_object_show(o);
|
|
|
|
e_widget_size_min_get(o, &mw, &mh);
|
|
|
|
e_dialog_content_set(dia, o, mw, mh);
|
2012-06-25 23:43:22 -07:00
|
|
|
e_dialog_button_add(dia, _("Save"), NULL,
|
2011-05-27 23:53:44 -07:00
|
|
|
_file_select_ok_cb, NULL);
|
|
|
|
e_dialog_button_add(dia, _("Cancel"), NULL,
|
|
|
|
_file_select_cancel_cb, NULL);
|
2014-11-02 18:35:13 -08:00
|
|
|
elm_win_center(dia->win, 1, 1);
|
|
|
|
o = evas_object_rectangle_add(evas_object_evas_get(dia->win));
|
2015-07-06 06:37:52 -07:00
|
|
|
if (!evas_object_key_grab(o, "Return", mask, ~mask, 0))
|
|
|
|
printf("grab err\n");
|
2012-07-19 03:31:34 -07:00
|
|
|
mask = 0;
|
2015-07-06 06:37:52 -07:00
|
|
|
if (!evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0))
|
|
|
|
printf("grab err\n");
|
2012-08-02 05:19:11 -07:00
|
|
|
mask = 0;
|
2015-07-06 06:37:52 -07:00
|
|
|
if (!evas_object_key_grab(o, "Escape", mask, ~mask, 0))
|
|
|
|
printf("grab err\n");
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN,
|
|
|
|
_save_key_down_cb, NULL);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_share_done(void)
|
|
|
|
{
|
2012-11-12 02:28:00 -08:00
|
|
|
E_FREE_LIST(handlers, ecore_event_handler_del);
|
2011-05-27 23:53:44 -07:00
|
|
|
o_label = NULL;
|
2012-11-12 02:28:00 -08:00
|
|
|
E_FREE(url_ret);
|
2013-03-15 06:35:46 -07:00
|
|
|
E_FREE_FUNC(url_up, ecore_con_url_free);
|
2015-01-15 02:43:24 -08:00
|
|
|
url_up = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_upload_ok_cb(void *data EINA_UNUSED, E_Dialog *dia)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
// ok just hides dialog and does background upload
|
|
|
|
o_label = NULL;
|
|
|
|
if (dia) e_util_defer_object_del(E_OBJECT(dia));
|
2012-11-12 02:28:00 -08:00
|
|
|
if (!win) return;
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_upload_cancel_cb(void *data EINA_UNUSED, E_Dialog *dia)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2012-06-25 23:43:22 -07:00
|
|
|
o_label = NULL;
|
2011-05-27 23:53:44 -07:00
|
|
|
if (dia) e_util_defer_object_del(E_OBJECT(dia));
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2012-06-25 23:43:22 -07:00
|
|
|
_share_done();
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2015-03-18 15:09:09 -07:00
|
|
|
_upload_data_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
Ecore_Con_Event_Url_Data *ev = event;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
if (ev->url_con != url_up) return EINA_TRUE;
|
|
|
|
if ((o_label) && (ev->size < 1024))
|
|
|
|
{
|
|
|
|
char *txt = alloca(ev->size + 1);
|
2011-05-28 00:40:15 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
memcpy(txt, ev->data, ev->size);
|
|
|
|
txt[ev->size] = 0;
|
2013-03-27 05:26:15 -07:00
|
|
|
/*
|
2011-05-28 00:40:15 -07:00
|
|
|
printf("GOT %i bytes: '%s'\n", ev->size, txt);
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ev->size; i++) printf("%02x.", ev->data[i]);
|
|
|
|
printf("\n");
|
|
|
|
*/
|
2011-05-27 23:53:44 -07:00
|
|
|
if (!url_ret) url_ret = strdup(txt);
|
|
|
|
else
|
2014-07-01 03:51:04 -07:00
|
|
|
{
|
2011-05-27 23:53:44 -07:00
|
|
|
char *n;
|
2013-03-27 05:26:15 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
n = malloc(strlen(url_ret) + ev->size + 1);
|
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
strcpy(n, url_ret);
|
2012-08-26 14:34:25 -07:00
|
|
|
free(url_ret);
|
2011-05-27 23:53:44 -07:00
|
|
|
strcat(n, txt);
|
|
|
|
url_ret = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2015-03-18 15:09:09 -07:00
|
|
|
_upload_progress_cb(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2013-03-15 06:35:46 -07:00
|
|
|
size_t total, current;
|
2011-05-27 23:53:44 -07:00
|
|
|
Ecore_Con_Event_Url_Progress *ev = event;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
2013-03-15 06:35:46 -07:00
|
|
|
if (ev->url_con != url_up) return ECORE_CALLBACK_RENEW;
|
|
|
|
total = ev->up.total;
|
|
|
|
current = ev->up.now;
|
2011-05-27 23:53:44 -07:00
|
|
|
if (o_label)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
2012-07-14 13:50:21 -07:00
|
|
|
char *buf_now, *buf_total;
|
|
|
|
|
2013-03-15 06:35:46 -07:00
|
|
|
buf_now = e_util_size_string_get(current);
|
|
|
|
buf_total = e_util_size_string_get(total);
|
2015-07-06 06:37:52 -07:00
|
|
|
snprintf(buf, sizeof(buf), _("Uploaded %s / %s"), buf_now, buf_total);
|
2012-07-14 13:50:21 -07:00
|
|
|
E_FREE(buf_now);
|
|
|
|
E_FREE(buf_total);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_label_text_set(o_label, buf);
|
|
|
|
}
|
2013-03-15 06:35:46 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2015-03-18 15:09:09 -07:00
|
|
|
_upload_complete_cb(void *data, int ev_type EINA_UNUSED, void *event)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2013-03-15 06:35:46 -07:00
|
|
|
int status;
|
2011-05-27 23:53:44 -07:00
|
|
|
Ecore_Con_Event_Url_Complete *ev = event;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
2013-03-15 06:35:46 -07:00
|
|
|
if (ev->url_con != url_up) return ECORE_CALLBACK_RENEW;
|
|
|
|
status = ev->status;
|
2012-11-12 02:28:00 -08:00
|
|
|
|
|
|
|
if (data)
|
|
|
|
e_widget_disabled_set(data, 1);
|
2013-03-15 06:35:46 -07:00
|
|
|
if (status != 200)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2013-03-15 06:35:46 -07:00
|
|
|
e_util_dialog_show(_("Error - Upload Failed"),
|
2014-07-01 03:51:04 -07:00
|
|
|
_("Upload failed with status code:<br>"
|
|
|
|
"%i"), status);
|
2011-05-27 23:53:44 -07:00
|
|
|
_share_done();
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
if ((o_entry) && (url_ret))
|
|
|
|
e_widget_entry_text_set(o_entry, url_ret);
|
|
|
|
_share_done();
|
2013-03-15 06:35:46 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
2012-11-12 02:28:00 -08:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_win_share_del(void *data EINA_UNUSED)
|
2012-11-12 02:28:00 -08:00
|
|
|
{
|
2015-07-06 06:37:52 -07:00
|
|
|
if (handlers)
|
|
|
|
ecore_event_handler_data_set(eina_list_last_data_get(handlers), NULL);
|
2012-11-12 02:28:00 -08:00
|
|
|
_upload_cancel_cb(NULL, NULL);
|
2012-12-14 08:02:03 -08:00
|
|
|
if (cd) e_object_del(E_OBJECT(cd));
|
2012-11-12 02:28:00 -08:00
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_win_share_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
Evas_Object *o, *ol;
|
|
|
|
Evas_Coord mw, mh;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
FILE *f;
|
2012-12-09 23:13:55 -08:00
|
|
|
int i, fd = -1;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-12-09 23:13:55 -08:00
|
|
|
srand(time(NULL));
|
|
|
|
for (i = 0; i < 10240; i++)
|
|
|
|
{
|
|
|
|
int v = rand();
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-12-09 23:13:55 -08:00
|
|
|
if (quality == 100)
|
|
|
|
snprintf(buf, sizeof(buf), "/tmp/e-shot-%x.png", v);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "/tmp/e-shot-%x.jpg", v);
|
|
|
|
fd = open(buf, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
|
|
|
if (fd >= 0) break;
|
|
|
|
}
|
|
|
|
if (fd < 0)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2012-08-26 12:41:34 -07:00
|
|
|
e_util_dialog_show(_("Error - Can't create file"),
|
|
|
|
_("Cannot create temporary file '%s': %s"),
|
|
|
|
buf, strerror(errno));
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2011-05-27 23:53:44 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
_save_to(buf);
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2012-12-09 23:13:55 -08:00
|
|
|
f = fdopen(fd, "rb");
|
2011-05-27 23:53:44 -07:00
|
|
|
if (!f)
|
|
|
|
{
|
2012-08-26 12:41:34 -07:00
|
|
|
e_util_dialog_show(_("Error - Can't open file"),
|
|
|
|
_("Cannot open temporary file '%s': %s"),
|
|
|
|
buf, strerror(errno));
|
2011-05-27 23:53:44 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
fseek(f, 0, SEEK_END);
|
|
|
|
fsize = ftell(f);
|
|
|
|
if (fsize < 1)
|
|
|
|
{
|
2012-08-26 12:41:34 -07:00
|
|
|
e_util_dialog_show(_("Error - Bad size"),
|
|
|
|
_("Cannot get size of file '%s'"),
|
|
|
|
buf);
|
2011-05-27 23:53:44 -07:00
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rewind(f);
|
2012-12-21 13:31:13 -08:00
|
|
|
free(fdata);
|
2011-05-27 23:53:44 -07:00
|
|
|
fdata = malloc(fsize);
|
|
|
|
if (!fdata)
|
|
|
|
{
|
2012-08-26 12:41:34 -07:00
|
|
|
e_util_dialog_show(_("Error - Can't allocate memory"),
|
|
|
|
_("Cannot allocate memory for picture: %s"),
|
|
|
|
strerror(errno));
|
2011-05-27 23:53:44 -07:00
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fread(fdata, fsize, 1, f) != 1)
|
|
|
|
{
|
2012-08-26 12:41:34 -07:00
|
|
|
e_util_dialog_show(_("Error - Can't read picture"),
|
|
|
|
_("Cannot read picture"));
|
|
|
|
E_FREE(fdata);
|
2011-05-27 23:53:44 -07:00
|
|
|
fclose(f);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
ecore_file_unlink(buf);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
_share_done();
|
2013-03-15 06:35:46 -07:00
|
|
|
|
2015-07-06 06:37:52 -07:00
|
|
|
E_LIST_HANDLER_APPEND(handlers, ECORE_CON_EVENT_URL_DATA,
|
|
|
|
_upload_data_cb, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, ECORE_CON_EVENT_URL_PROGRESS,
|
|
|
|
_upload_progress_cb, NULL);
|
2013-03-15 06:35:46 -07:00
|
|
|
|
2015-04-11 15:55:58 -07:00
|
|
|
url_up = ecore_con_url_new("https://www.enlightenment.org/shot.php");
|
2012-02-08 05:26:08 -08:00
|
|
|
// why use http 1.1? proxies like squid don't handle 1.1 posts with expect
|
|
|
|
// like curl uses by default, so go to 1.0 and this all works dandily
|
|
|
|
// out of the box
|
|
|
|
ecore_con_url_http_version_set(url_up, ECORE_CON_URL_HTTP_VERSION_1_0);
|
2011-05-27 23:53:44 -07:00
|
|
|
ecore_con_url_post(url_up, fdata, fsize, "application/x-e-shot");
|
2014-11-02 18:35:13 -08:00
|
|
|
dia = e_dialog_new(NULL, "E", "_e_shot_share");
|
2014-12-22 06:02:05 -08:00
|
|
|
e_dialog_resizable_set(dia, EINA_TRUE);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_dialog_title_set(dia, _("Uploading screenshot"));
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
o = e_widget_list_add(evas_object_evas_get(dia->win), 0, 0);
|
2011-05-27 23:53:44 -07:00
|
|
|
ol = o;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
o = e_widget_label_add(evas_object_evas_get(dia->win), _("Uploading ..."));
|
2011-05-27 23:53:44 -07:00
|
|
|
o_label = o;
|
|
|
|
e_widget_list_object_append(ol, o, 0, 0, 0.5);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
o = e_widget_label_add(evas_object_evas_get(dia->win),
|
2011-05-27 23:53:44 -07:00
|
|
|
_("Screenshot is available at this location:"));
|
|
|
|
e_widget_list_object_append(ol, o, 0, 0, 0.5);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-01-11 09:20:38 -08:00
|
|
|
o = e_widget_entry_add(dia->win, NULL, NULL, NULL, NULL);
|
2011-05-27 23:53:44 -07:00
|
|
|
o_entry = o;
|
|
|
|
e_widget_list_object_append(ol, o, 1, 0, 0.5);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_size_min_get(ol, &mw, &mh);
|
|
|
|
e_dialog_content_set(dia, ol, mw, mh);
|
2012-06-25 23:43:22 -07:00
|
|
|
e_dialog_button_add(dia, _("Hide"), NULL, _upload_ok_cb, NULL);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_dialog_button_add(dia, _("Cancel"), NULL, _upload_cancel_cb, NULL);
|
2012-11-12 02:28:00 -08:00
|
|
|
e_object_del_attach_func_set(E_OBJECT(dia), _win_share_del);
|
2015-07-06 06:37:52 -07:00
|
|
|
E_LIST_HANDLER_APPEND(handlers, ECORE_CON_EVENT_URL_COMPLETE,
|
|
|
|
_upload_complete_cb,
|
|
|
|
eina_list_last_data_get(dia->buttons));
|
2014-11-02 18:35:13 -08:00
|
|
|
elm_win_center(dia->win, 1, 1);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
|
2012-12-14 08:02:03 -08:00
|
|
|
static void
|
|
|
|
_win_share_confirm_del(void *d EINA_UNUSED)
|
|
|
|
{
|
|
|
|
cd = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_win_share_confirm_yes(void *d EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_win_share_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_win_share_confirm_cb(void *d EINA_UNUSED, void *d2 EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (cd) return;
|
|
|
|
cd = e_confirm_dialog_show(_("Confirm Share"), NULL,
|
2014-07-01 03:51:04 -07:00
|
|
|
_("This image will be uploaded<br>"
|
|
|
|
"to enlightenment.org. It will be publicly visible."),
|
2015-07-06 06:37:52 -07:00
|
|
|
_("Confirm"), _("Cancel"),
|
|
|
|
_win_share_confirm_yes, NULL,
|
2014-07-01 03:51:04 -07:00
|
|
|
NULL, NULL, _win_share_confirm_del, NULL);
|
2012-12-14 08:02:03 -08:00
|
|
|
}
|
|
|
|
|
2011-05-29 02:45:19 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_rect_down_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
2011-05-29 02:45:19 -07:00
|
|
|
{
|
|
|
|
Evas_Event_Mouse_Down *ev = event_info;
|
|
|
|
Eina_List *l;
|
|
|
|
E_Zone *z;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-29 02:45:19 -07:00
|
|
|
if (ev->button != 1) return;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-29 16:45:40 -07:00
|
|
|
e_widget_radio_toggle_set(o_radio_all, 0);
|
2015-03-18 14:34:31 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, z)
|
2011-05-29 02:45:19 -07:00
|
|
|
{
|
|
|
|
if (obj == o_rectdim[z->num])
|
|
|
|
{
|
|
|
|
screen = z->num;
|
|
|
|
e_widget_radio_toggle_set(o_radio[z->num], 1);
|
|
|
|
}
|
2011-05-29 16:45:40 -07:00
|
|
|
else
|
|
|
|
e_widget_radio_toggle_set(o_radio[z->num], 0);
|
2011-05-29 02:45:19 -07:00
|
|
|
}
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-03-18 14:34:31 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, z)
|
2011-05-29 02:45:19 -07:00
|
|
|
{
|
|
|
|
if (screen == -1)
|
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 0);
|
|
|
|
else if (screen == (int)z->num)
|
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 0);
|
|
|
|
else
|
|
|
|
evas_object_color_set(o_rectdim[z->num], 0, 0, 0, 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2015-07-08 12:12:44 -07:00
|
|
|
_save_dialog_show(E_Zone *zone, E_Client *ec, const char *params, void *dst, int sw, int sh)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
Evas *evas, *evas2;
|
|
|
|
Evas_Object *o, *oa, *op, *ol;
|
|
|
|
Evas_Modifier_Mask mask;
|
|
|
|
E_Radio_Group *rg;
|
2015-07-08 12:12:44 -07:00
|
|
|
int w, h;
|
2013-01-23 01:07:02 -08:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
win = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-11-02 18:35:13 -08:00
|
|
|
evas = evas_object_evas_get(win);
|
|
|
|
elm_win_title_set(win, _("Where to put Screenshot..."));
|
|
|
|
evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _win_delete_cb, NULL);
|
|
|
|
elm_win_center(win, 1, 1);
|
|
|
|
ecore_evas_name_class_set(e_win_ee_get(win), "E", "_shot_dialog");
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-01-14 22:13:45 -08:00
|
|
|
o = elm_layout_add(e_win_evas_win_get(evas));
|
2014-11-02 18:35:13 -08:00
|
|
|
elm_win_resize_object_add(win, o);
|
2011-05-27 23:53:44 -07:00
|
|
|
o_bg = o;;
|
|
|
|
e_theme_edje_object_set(o, "base/theme/dialog", "e/widgets/dialog/main");
|
|
|
|
evas_object_show(o);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = e_widget_list_add(evas, 0, 0);
|
|
|
|
o_content = o;
|
2015-01-14 22:13:45 -08:00
|
|
|
elm_object_part_content_set(o_bg, "e.swallow.content", o);
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
w = sw / 4;
|
2011-05-27 23:53:44 -07:00
|
|
|
if (w < 220) w = 220;
|
2012-07-19 03:02:26 -07:00
|
|
|
h = (w * sh) / sw;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = e_widget_aspect_add(evas, w, h);
|
|
|
|
oa = o;
|
|
|
|
o = e_widget_preview_add(evas, w, h);
|
|
|
|
op = o;
|
|
|
|
|
|
|
|
evas2 = e_widget_preview_evas_get(op);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = evas_object_image_filled_add(evas2);
|
|
|
|
o_img = o;
|
|
|
|
evas_object_image_colorspace_set(o, EVAS_COLORSPACE_ARGB8888);
|
|
|
|
evas_object_image_alpha_set(o, EINA_FALSE);
|
2012-07-19 03:02:26 -07:00
|
|
|
evas_object_image_size_set(o, sw, sh);
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_image_data_copy_set(o, dst);
|
2015-07-08 12:12:44 -07:00
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
evas_object_image_data_update_add(o, 0, 0, sw, sh);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_preview_extern_object_set(op, o);
|
|
|
|
evas_object_show(o);
|
|
|
|
|
|
|
|
evas_object_show(op);
|
|
|
|
evas_object_show(oa);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_aspect_child_set(oa, op);
|
|
|
|
e_widget_list_object_append(o_content, oa, 0, 0, 0.5);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = e_widget_list_add(evas, 1, 1);
|
|
|
|
o_hlist = o;
|
|
|
|
|
|
|
|
o = e_widget_framelist_add(evas, _("Quality"), 0);
|
|
|
|
ol = o;
|
|
|
|
|
|
|
|
rg = e_widget_radio_group_new(&quality);
|
|
|
|
o = e_widget_radio_add(evas, _("Perfect"), 100, rg);
|
|
|
|
e_widget_framelist_object_append(ol, o);
|
|
|
|
o = e_widget_radio_add(evas, _("High"), 90, rg);
|
|
|
|
e_widget_framelist_object_append(ol, o);
|
|
|
|
o = e_widget_radio_add(evas, _("Medium"), 70, rg);
|
|
|
|
e_widget_framelist_object_append(ol, o);
|
|
|
|
o = e_widget_radio_add(evas, _("Low"), 50, rg);
|
|
|
|
e_widget_framelist_object_append(ol, o);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_list_object_append(o_hlist, ol, 1, 0, 0.5);
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
if (zone)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2012-07-19 03:02:26 -07:00
|
|
|
screen = -1;
|
2015-03-18 14:34:31 -07:00
|
|
|
if (eina_list_count(e_comp->zones) > 1)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
2012-07-19 03:02:26 -07:00
|
|
|
Eina_List *l;
|
|
|
|
E_Zone *z;
|
|
|
|
int i;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
o = e_widget_framelist_add(evas, _("Screen"), 0);
|
|
|
|
ol = o;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
rg = e_widget_radio_group_new(&screen);
|
|
|
|
o = e_widget_radio_add(evas, _("All"), -1, rg);
|
|
|
|
o_radio_all = o;
|
2015-07-06 06:37:52 -07:00
|
|
|
evas_object_smart_callback_add(o, "changed",
|
|
|
|
_screen_change_cb, NULL);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_framelist_object_append(ol, o);
|
2012-07-19 03:02:26 -07:00
|
|
|
i = 0;
|
2015-03-18 14:34:31 -07:00
|
|
|
EINA_LIST_FOREACH(e_comp->zones, l, z)
|
2012-07-19 03:02:26 -07:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
if (z->num >= MAXZONES) continue;
|
|
|
|
snprintf(buf, sizeof(buf), "%i", z->num);
|
|
|
|
o = e_widget_radio_add(evas, buf, z->num, rg);
|
|
|
|
o_radio[z->num] = o;
|
2015-07-06 06:37:52 -07:00
|
|
|
evas_object_smart_callback_add(o, "changed",
|
|
|
|
_screen_change_cb, NULL);
|
2012-07-19 03:02:26 -07:00
|
|
|
e_widget_framelist_object_append(ol, o);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
o = evas_object_rectangle_add(evas2);
|
2014-07-01 03:51:04 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
2012-07-19 03:02:26 -07:00
|
|
|
_rect_down_cb, NULL);
|
|
|
|
o_rectdim[z->num] = o;
|
|
|
|
evas_object_color_set(o, 0, 0, 0, 0);
|
|
|
|
evas_object_show(o);
|
|
|
|
evas_object_geometry_get(o_img, NULL, NULL, &w, &h);
|
2015-07-06 06:37:52 -07:00
|
|
|
evas_object_move(o, (z->x * w) / sw, (z->y * h) / sh);
|
|
|
|
evas_object_resize(o, (z->w * w) / sw, (z->h * h) / sh);
|
2012-07-19 03:02:26 -07:00
|
|
|
i++;
|
|
|
|
}
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
e_widget_list_object_append(o_hlist, ol, 1, 0, 0.5);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
e_widget_list_object_append(o_content, o_hlist, 0, 0, 0.5);
|
|
|
|
|
|
|
|
o = o_content;
|
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2014-06-07 09:29:17 -07:00
|
|
|
evas_object_size_hint_min_set(o, w, h);
|
2015-01-14 22:13:45 -08:00
|
|
|
elm_object_part_content_set(o_bg, "e.swallow.content", o);
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_show(o);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = e_widget_list_add(evas, 1, 1);
|
|
|
|
o_box = o;
|
|
|
|
e_widget_on_focus_hook_set(o, _on_focus_cb, NULL);
|
2015-01-14 22:13:45 -08:00
|
|
|
elm_object_part_content_set(o_bg, "e.swallow.buttons", o);
|
2011-05-27 23:53:44 -07:00
|
|
|
|
|
|
|
o = e_widget_button_add(evas, _("Save"), NULL, _win_save_cb, win, NULL);
|
|
|
|
e_widget_list_object_append(o_box, o, 1, 0, 0.5);
|
2015-07-06 06:37:52 -07:00
|
|
|
o = e_widget_button_add(evas, _("Share"), NULL,
|
|
|
|
_win_share_confirm_cb, win, NULL);
|
2011-05-27 23:53:44 -07:00
|
|
|
e_widget_list_object_append(o_box, o, 1, 0, 0.5);
|
|
|
|
o = e_widget_button_add(evas, _("Cancel"), NULL, _win_cancel_cb, win, NULL);
|
|
|
|
e_widget_list_object_append(o_box, o, 1, 0, 0.5);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = o_box;
|
|
|
|
e_widget_size_min_get(o, &w, &h);
|
2014-06-07 09:29:17 -07:00
|
|
|
evas_object_size_hint_min_set(o, w, h);
|
2015-01-14 22:13:45 -08:00
|
|
|
elm_object_part_content_set(o_bg, "e.swallow.buttons", o);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
o = evas_object_rectangle_add(evas);
|
|
|
|
o_event = o;
|
|
|
|
mask = 0;
|
|
|
|
if (!evas_object_key_grab(o, "Tab", mask, ~mask, 0)) printf("grab err\n");
|
|
|
|
mask = evas_key_modifier_mask_get(evas, "Shift");
|
|
|
|
if (!evas_object_key_grab(o, "Tab", mask, ~mask, 0)) printf("grab err\n");
|
|
|
|
mask = 0;
|
|
|
|
if (!evas_object_key_grab(o, "Return", mask, ~mask, 0)) printf("grab err\n");
|
|
|
|
mask = 0;
|
|
|
|
if (!evas_object_key_grab(o, "KP_Enter", mask, ~mask, 0)) printf("grab err\n");
|
2012-07-19 03:31:34 -07:00
|
|
|
mask = 0;
|
|
|
|
if (!evas_object_key_grab(o, "space", mask, ~mask, 0)) printf("grab err\n");
|
2012-09-22 07:13:31 -07:00
|
|
|
mask = 0;
|
|
|
|
if (!evas_object_key_grab(o, "Escape", mask, ~mask, 0)) printf("grab err\n");
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, NULL);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2015-01-14 22:13:45 -08:00
|
|
|
evas_object_size_hint_min_get(o_bg, &w, &h);
|
2011-05-27 23:53:44 -07:00
|
|
|
evas_object_resize(o_bg, w, h);
|
2014-11-02 18:35:13 -08:00
|
|
|
evas_object_resize(win, w, h);
|
|
|
|
evas_object_size_hint_min_set(win, w, h);
|
|
|
|
evas_object_size_hint_max_set(win, 99999, 99999);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-01-21 04:21:13 -08:00
|
|
|
if (params)
|
|
|
|
{
|
|
|
|
char smode[128], squal[128], sscreen[128];
|
|
|
|
|
|
|
|
if (sscanf(params, "%100s %100s %100s", smode, squal, sscreen) == 3)
|
|
|
|
{
|
|
|
|
screen = -1;
|
2014-01-21 19:27:00 -08:00
|
|
|
if ((zone) && (!strcmp(sscreen, "current"))) screen = zone->num;
|
2014-01-21 04:21:13 -08:00
|
|
|
else if (!strcmp(sscreen, "all")) screen = -1;
|
|
|
|
else screen = atoi(sscreen);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-01-21 04:21:13 -08:00
|
|
|
quality = 90;
|
|
|
|
if (!strcmp(squal, "perfect")) quality = 100;
|
|
|
|
else if (!strcmp(squal, "high")) quality = 90;
|
|
|
|
else if (!strcmp(squal, "medium")) quality = 70;
|
|
|
|
else if (!strcmp(squal, "low")) quality = 50;
|
|
|
|
else quality = atoi(squal);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-01-21 04:21:13 -08:00
|
|
|
if (!strcmp(smode, "save")) _win_save_cb(NULL, NULL);
|
|
|
|
else if (!strcmp(smode, "share")) _win_share_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-02 18:35:13 -08:00
|
|
|
evas_object_show(win);
|
2014-01-21 04:21:13 -08:00
|
|
|
e_win_client_icon_set(win, "screenshot");
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2014-01-21 04:21:13 -08:00
|
|
|
if (!e_widget_focus_get(o_bg)) e_widget_focus_set(o_box, 1);
|
2015-04-13 12:47:23 -07:00
|
|
|
if (ec)
|
2015-04-14 15:39:58 -07:00
|
|
|
{
|
|
|
|
E_Client *c = e_win_client_get(win);
|
|
|
|
|
|
|
|
if (c) evas_object_layer_set(c->frame, ec->layer);
|
|
|
|
}
|
2014-01-21 04:21:13 -08:00
|
|
|
}
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
static struct wl_buffer *
|
|
|
|
_create_shm_buffer(struct wl_shm *_shm, int width, int height, void **data_out)
|
|
|
|
{
|
|
|
|
char filename[] = "wayland-shm-XXXXXX";
|
|
|
|
Eina_Tmpstr *tmpfile = NULL;
|
|
|
|
struct wl_shm_pool *pool;
|
|
|
|
struct wl_buffer *buffer;
|
|
|
|
int fd, size, stride;
|
|
|
|
void *data;
|
|
|
|
|
|
|
|
fd = eina_file_mkstemp(filename, &tmpfile);
|
|
|
|
if (fd < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "open %s failed: %m\n", tmpfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
stride = width * 4;
|
|
|
|
size = stride * height;
|
|
|
|
if (ftruncate(fd, size) < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "ftruncate failed: %m\n");
|
|
|
|
close(fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
|
|
|
unlink(tmpfile);
|
|
|
|
eina_tmpstr_del(tmpfile);
|
|
|
|
|
|
|
|
if (data == MAP_FAILED)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "mmap failed: %m\n");
|
|
|
|
close(fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool = wl_shm_create_pool(_shm, fd, size);
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
buffer =
|
|
|
|
wl_shm_pool_create_buffer(pool, 0, width, height, stride,
|
|
|
|
WL_SHM_FORMAT_ARGB8888);
|
|
|
|
wl_shm_pool_destroy(pool);
|
|
|
|
|
|
|
|
*data_out = data;
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
_wl_shot_now(E_Zone *zone, E_Client *ec, const char *params)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
Eina_List *l;
|
|
|
|
struct screenshooter_output *output;
|
|
|
|
struct wl_shm *shm;
|
|
|
|
int x, y, sw, sh, i;
|
|
|
|
int ostride, bstride;
|
2015-07-15 15:09:15 -07:00
|
|
|
unsigned char *dst, *d, *s;
|
2015-07-08 12:12:44 -07:00
|
|
|
|
|
|
|
if ((win) || (url_up)) return;
|
|
|
|
if ((!zone) && (!ec)) return;
|
2015-07-08 12:41:23 -07:00
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
if (zone)
|
|
|
|
{
|
|
|
|
sw = e_comp->w;
|
|
|
|
sh = e_comp->h;
|
|
|
|
x = y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x = ec->x, y = ec->y, sw = ec->w, sh = ec->h;
|
|
|
|
x = E_CLAMP(x, ec->zone->x, ec->zone->x + ec->zone->w);
|
|
|
|
y = E_CLAMP(y, ec->zone->y, ec->zone->y + ec->zone->h);
|
|
|
|
sw = E_CLAMP(sw, 1, ec->zone->x + ec->zone->w - x);
|
|
|
|
sh = E_CLAMP(sh, 1, ec->zone->y + ec->zone->h - y);
|
|
|
|
}
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
shm = e_comp_wl->wl.shm ?: ecore_wl_shm_get();
|
2015-07-08 12:12:44 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_outputs, l, output)
|
|
|
|
{
|
2015-07-09 09:37:42 -07:00
|
|
|
if ((!zone) &&
|
|
|
|
(!E_CONTAINS(output->x, output->y, output->w, output->h,
|
|
|
|
x, y, sw, sh)))
|
|
|
|
continue;
|
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
output->buffer =
|
|
|
|
_create_shm_buffer(shm, output->w, output->h, &output->data);
|
|
|
|
|
|
|
|
screenshooter_shoot(_wl_screenshooter, output->output, output->buffer);
|
|
|
|
|
|
|
|
copy_done = EINA_FALSE;
|
|
|
|
while (!copy_done)
|
|
|
|
ecore_main_loop_iterate();
|
|
|
|
}
|
|
|
|
|
|
|
|
bstride = sw * sizeof(int);
|
|
|
|
dst = malloc(bstride * sh);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_outputs, l, output)
|
|
|
|
{
|
2015-07-09 09:37:42 -07:00
|
|
|
if ((!zone) &&
|
|
|
|
(!E_CONTAINS(output->x, output->y, output->w, output->h,
|
|
|
|
x, y, sw, sh)))
|
|
|
|
continue;
|
|
|
|
|
2015-07-08 12:12:44 -07:00
|
|
|
ostride = output->w * sizeof(int);
|
|
|
|
s = output->data;
|
2015-07-09 09:37:42 -07:00
|
|
|
if (zone)
|
2015-07-08 12:12:44 -07:00
|
|
|
{
|
2015-07-09 09:37:42 -07:00
|
|
|
d = dst + (output->y * bstride + output->x * sizeof(int));
|
|
|
|
for (i = 0; i < output->h; i++)
|
|
|
|
{
|
|
|
|
memcpy(d, s, ostride);
|
|
|
|
d += bstride;
|
|
|
|
s += ostride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
d = dst;
|
|
|
|
for (i = y; i < (y + sh); i++)
|
|
|
|
{
|
2015-07-15 15:09:15 -07:00
|
|
|
s = output->data;
|
|
|
|
s += (i * ostride) + (x * sizeof(int));
|
2015-07-09 09:37:42 -07:00
|
|
|
memcpy(d, s, bstride);
|
|
|
|
d += bstride;
|
|
|
|
}
|
2015-07-08 12:12:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_save_dialog_show(zone, ec, params, dst, sw, sh);
|
|
|
|
|
|
|
|
free(dst);
|
|
|
|
#else
|
|
|
|
(void)zone;
|
|
|
|
(void)ec;
|
|
|
|
(void)params;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_x_shot_now(E_Zone *zone, E_Client *ec, const char *params)
|
|
|
|
{
|
2015-09-22 10:54:28 -07:00
|
|
|
#ifdef HAVE_WAYLAND_ONLY
|
|
|
|
(void)zone;
|
|
|
|
(void)ec;
|
|
|
|
(void)params;
|
|
|
|
#else
|
2015-07-08 12:12:44 -07:00
|
|
|
Ecore_X_Image *img;
|
|
|
|
unsigned char *src;
|
|
|
|
unsigned int *dst;
|
|
|
|
int bpl = 0, rows = 0, bpp = 0, sw, sh;
|
|
|
|
int x, y, w, h;
|
|
|
|
Ecore_X_Window xwin;
|
|
|
|
Ecore_X_Visual visual;
|
|
|
|
Ecore_X_Display *display;
|
|
|
|
Ecore_X_Screen *scr;
|
|
|
|
Ecore_X_Window_Attributes watt;
|
|
|
|
Ecore_X_Colormap colormap;
|
|
|
|
int depth;
|
|
|
|
|
|
|
|
if ((win) || (url_up)) return;
|
|
|
|
if ((!zone) && (!ec)) return;
|
|
|
|
if (zone)
|
|
|
|
{
|
|
|
|
xwin = e_comp->root;
|
|
|
|
w = sw = e_comp->w;
|
|
|
|
h = sh = e_comp->h;
|
|
|
|
x = y = 0;
|
|
|
|
if (!ecore_x_window_attributes_get(xwin, &watt)) return;
|
|
|
|
visual = watt.visual;
|
|
|
|
depth = watt.depth;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xwin = e_comp->ee_win;
|
|
|
|
x = ec->x, y = ec->y, sw = ec->w, sh = ec->h;
|
|
|
|
w = sw;
|
|
|
|
h = sh;
|
|
|
|
x = E_CLAMP(x, ec->zone->x, ec->zone->x + ec->zone->w);
|
|
|
|
y = E_CLAMP(y, ec->zone->y, ec->zone->y + ec->zone->h);
|
|
|
|
sw = E_CLAMP(sw, 1, ec->zone->x + ec->zone->w - x);
|
|
|
|
sh = E_CLAMP(sh, 1, ec->zone->y + ec->zone->h - y);
|
|
|
|
visual = e_pixmap_visual_get(ec->pixmap);
|
|
|
|
depth = ec->depth;
|
|
|
|
}
|
|
|
|
img = ecore_x_image_new(w, h, visual, depth);
|
|
|
|
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;
|
|
|
|
|
|
|
|
int n = fscanf(f, "%llu", &max);
|
|
|
|
if ((n > 0) && (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);
|
|
|
|
}
|
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
int max;
|
|
|
|
size_t len = sizeof(max);
|
|
|
|
|
|
|
|
if (!sysctlbyname("kern.ipc.shmmax", &max, &len, NULL, 0))
|
|
|
|
{
|
|
|
|
if (max && (max < (w * h * sizeof(int))))
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Screenshot Error"),
|
|
|
|
_("SHMMAX is too small to take screenshot.<br>"
|
|
|
|
"Consider increasing kern.ipc.shmmax to a value larger than %llu"),
|
|
|
|
(long long unsigned int)(w * h * sizeof(int)));
|
|
|
|
dialog = EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#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();
|
|
|
|
colormap = ecore_x_default_colormap_get(display, scr);
|
|
|
|
dst = malloc(sw * sh * sizeof(int));
|
|
|
|
ecore_x_image_to_argb_convert(src, bpp, bpl, colormap, visual,
|
|
|
|
0, 0, sw, sh,
|
|
|
|
dst, (sw * sizeof(int)), 0, 0);
|
|
|
|
|
|
|
|
_save_dialog_show(zone, ec, params, dst, sw, sh);
|
|
|
|
|
|
|
|
free(dst);
|
|
|
|
ecore_x_image_free(img);
|
2015-09-22 10:54:28 -07:00
|
|
|
#endif
|
2015-07-08 12:12:44 -07:00
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_shot_delay(void *data)
|
|
|
|
{
|
|
|
|
timer = NULL;
|
2015-07-08 12:22:08 -07:00
|
|
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
2015-07-08 12:12:44 -07:00
|
|
|
_x_shot_now(data, NULL, NULL);
|
|
|
|
else
|
|
|
|
_wl_shot_now(data, NULL, NULL);
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_shot_delay_border(void *data)
|
|
|
|
{
|
|
|
|
border_timer = NULL;
|
2015-07-08 12:22:08 -07:00
|
|
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
2015-07-08 12:12:44 -07:00
|
|
|
_x_shot_now(NULL, data, NULL);
|
|
|
|
else
|
|
|
|
_wl_shot_now(NULL, data, NULL);
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
static void
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
_shot_border(E_Client *ec)
|
2012-07-19 03:02:26 -07:00
|
|
|
{
|
|
|
|
if (border_timer) ecore_timer_del(border_timer);
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
border_timer = ecore_timer_add(1.0, _shot_delay_border, ec);
|
2012-07-19 03:02:26 -07:00
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
|
|
|
_shot(E_Zone *zone)
|
|
|
|
{
|
|
|
|
if (timer) ecore_timer_del(timer);
|
|
|
|
timer = ecore_timer_add(1.0, _shot_delay, zone);
|
|
|
|
}
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_mod_menu_border_cb(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
|
2012-07-19 03:02:26 -07:00
|
|
|
{
|
|
|
|
_shot_border(data);
|
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_mod_menu_cb(void *data EINA_UNUSED, E_Menu *m, E_Menu_Item *mi EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
if (m->zone) _shot(m->zone);
|
|
|
|
}
|
|
|
|
|
2012-07-19 03:02:26 -07:00
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_mod_action_border_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
|
2012-07-19 03:02:26 -07:00
|
|
|
{
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
E_Client *ec;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
ec = e_client_focused_get();
|
|
|
|
if (!ec) return;
|
2012-07-19 03:02:26 -07:00
|
|
|
if (border_timer)
|
2014-07-01 03:51:04 -07:00
|
|
|
{
|
|
|
|
ecore_timer_del(border_timer);
|
|
|
|
border_timer = NULL;
|
|
|
|
}
|
2015-07-08 12:22:08 -07:00
|
|
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
2015-07-08 12:12:44 -07:00
|
|
|
_x_shot_now(NULL, ec, NULL);
|
|
|
|
else
|
|
|
|
_wl_shot_now(NULL, ec, NULL);
|
2012-07-19 03:02:26 -07:00
|
|
|
}
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
static void
|
2014-01-21 04:21:13 -08:00
|
|
|
_e_mod_action_cb(E_Object *obj, const char *params)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
E_Zone *zone = NULL;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
if (obj)
|
|
|
|
{
|
2015-03-19 13:03:51 -07:00
|
|
|
if (obj->type == E_COMP_TYPE)
|
2015-03-13 14:19:17 -07:00
|
|
|
zone = e_zone_current_get();
|
2011-05-27 23:53:44 -07:00
|
|
|
else if (obj->type == E_ZONE_TYPE)
|
2014-07-01 03:51:04 -07:00
|
|
|
zone = ((E_Zone *)obj);
|
2011-05-27 23:53:44 -07:00
|
|
|
else
|
2015-03-13 14:47:36 -07:00
|
|
|
zone = e_zone_current_get();
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
2015-03-13 14:47:36 -07:00
|
|
|
if (!zone) zone = e_zone_current_get();
|
2011-05-27 23:53:44 -07:00
|
|
|
if (!zone) return;
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
E_FREE_FUNC(timer, ecore_timer_del);
|
2015-07-08 12:22:08 -07:00
|
|
|
if (e_comp->comp_type == E_PIXMAP_TYPE_X)
|
2015-07-08 12:12:44 -07:00
|
|
|
_x_shot_now(zone, NULL, params);
|
|
|
|
else
|
|
|
|
_wl_shot_now(zone, NULL, params);
|
2012-07-19 03:02:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_bd_hook(void *d EINA_UNUSED, E_Client *ec)
|
2012-07-19 03:02:26 -07:00
|
|
|
{
|
|
|
|
E_Menu_Item *mi;
|
|
|
|
E_Menu *m;
|
|
|
|
Eina_List *l;
|
2015-07-06 06:37:52 -07:00
|
|
|
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
if (!ec->border_menu) return;
|
|
|
|
if (ec->iconic || (ec->desk != e_desk_current_get(ec->zone))) return;
|
|
|
|
m = ec->border_menu;
|
2012-07-19 03:02:26 -07:00
|
|
|
|
|
|
|
/* position menu item just before first separator */
|
|
|
|
EINA_LIST_FOREACH(m->items, l, mi)
|
|
|
|
if (mi->separator) break;
|
|
|
|
if ((!mi) || (!mi->separator)) return;
|
|
|
|
l = eina_list_prev(l);
|
|
|
|
mi = eina_list_data_get(l);
|
|
|
|
if (!mi) return;
|
|
|
|
|
|
|
|
mi = e_menu_item_new_relative(m, mi);
|
|
|
|
e_menu_item_label_set(mi, _("Take Shot"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "screenshot");
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_menu_item_callback_set(mi, _e_mod_menu_border_cb, ec);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-03-18 15:09:09 -07:00
|
|
|
_e_mod_menu_add(void *data EINA_UNUSED, E_Menu *m)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
E_Menu_Item *mi;
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
mi = e_menu_item_new(m);
|
|
|
|
e_menu_item_label_set(mi, _("Take Screenshot"));
|
|
|
|
e_util_menu_item_theme_icon_set(mi, "screenshot");
|
|
|
|
e_menu_item_callback_set(mi, _e_mod_menu_cb, NULL);
|
|
|
|
}
|
|
|
|
|
2015-08-12 17:19:18 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
static Ecore_Event_Handler *wl_global_handler;
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_wl_init()
|
|
|
|
{
|
|
|
|
Eina_Inlist *globals;
|
|
|
|
Ecore_Wl_Global *global;
|
|
|
|
struct wl_registry *reg;
|
|
|
|
|
2015-08-13 13:05:57 -07:00
|
|
|
reg = e_comp_wl->wl.registry ?: ecore_wl_registry_get();
|
|
|
|
if (e_comp_wl->wl.registry)
|
|
|
|
globals = e_comp_wl->wl.globals;
|
2015-08-12 17:19:18 -07:00
|
|
|
else
|
|
|
|
globals = ecore_wl_globals_get();
|
|
|
|
if (!globals)
|
|
|
|
{
|
|
|
|
if (!wl_global_handler)
|
|
|
|
{
|
2015-08-13 13:05:57 -07:00
|
|
|
if (e_comp_wl->wl.registry)
|
2015-08-12 17:19:18 -07:00
|
|
|
wl_global_handler = ecore_event_handler_add(E_EVENT_WAYLAND_GLOBAL_ADD,
|
|
|
|
(Ecore_Event_Handler_Cb)_wl_init, NULL);
|
|
|
|
else
|
|
|
|
wl_global_handler = ecore_event_handler_add(ECORE_WL_EVENT_INTERFACES_BOUND,
|
|
|
|
(Ecore_Event_Handler_Cb)_wl_init, NULL);
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
EINA_INLIST_FOREACH(globals, global)
|
|
|
|
{
|
|
|
|
if ((!_wl_screenshooter) && (!strcmp(global->interface, "screenshooter")))
|
|
|
|
{
|
|
|
|
_wl_screenshooter =
|
|
|
|
wl_registry_bind(reg, global->id,
|
|
|
|
&screenshooter_interface, global->version);
|
|
|
|
|
|
|
|
if (_wl_screenshooter)
|
|
|
|
screenshooter_add_listener(_wl_screenshooter,
|
|
|
|
&_screenshooter_listener,
|
|
|
|
_wl_screenshooter);
|
|
|
|
}
|
|
|
|
else if (!strcmp(global->interface, "wl_output"))
|
|
|
|
{
|
|
|
|
struct screenshooter_output *output;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_outputs, l, output)
|
|
|
|
if (output->id == global->id) return ECORE_CALLBACK_RENEW;
|
|
|
|
output = calloc(1, sizeof(*output));
|
|
|
|
if (output)
|
|
|
|
{
|
|
|
|
output->output =
|
|
|
|
wl_registry_bind(reg, global->id,
|
|
|
|
&wl_output_interface, global->version);
|
|
|
|
_outputs = eina_list_append(_outputs, output);
|
|
|
|
wl_output_add_listener(output->output,
|
|
|
|
&_output_listener, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
/* module setup */
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API E_Module_Api e_modapi =
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
E_MODULE_API_VERSION,
|
|
|
|
"Shot"
|
|
|
|
};
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void *
|
2011-05-27 23:53:44 -07:00
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2012-11-12 02:28:00 -08:00
|
|
|
if (!ecore_con_url_init())
|
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Shot Error"),
|
|
|
|
_("Cannot initialize network"));
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
e_module_delayed_set(m, 1);
|
2014-07-01 03:51:04 -07:00
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
shot_module = m;
|
|
|
|
act = e_action_add("shot");
|
|
|
|
if (act)
|
|
|
|
{
|
|
|
|
act->func.go = _e_mod_action_cb;
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Screen"), N_("Take Screenshot"),
|
2014-01-21 04:21:13 -08:00
|
|
|
"shot", NULL,
|
2015-01-15 02:43:24 -08:00
|
|
|
"syntax: [share|save [perfect|high|medium|low|QUALITY current|all|SCREEN-NUM]", 1);
|
2011-05-27 23:53:44 -07:00
|
|
|
}
|
2012-07-19 03:02:26 -07:00
|
|
|
border_act = e_action_add("border_shot");
|
|
|
|
if (border_act)
|
|
|
|
{
|
|
|
|
border_act->func.go = _e_mod_action_border_cb;
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_set(N_("Window : Actions"), N_("Take Shot"),
|
2014-01-21 04:21:13 -08:00
|
|
|
"border_shot", NULL,
|
2015-01-15 02:43:24 -08:00
|
|
|
"syntax: [share|save perfect|high|medium|low|QUALITY all|current]", 1);
|
2012-07-19 03:02:26 -07:00
|
|
|
}
|
2011-05-27 23:53:44 -07:00
|
|
|
maug = e_int_menus_menu_augmentation_add_sorted
|
2014-07-01 03:51:04 -07:00
|
|
|
("main/2", _("Take Screenshot"), _e_mod_menu_add, NULL, NULL, NULL);
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
border_hook = e_int_client_menu_hook_add(_bd_hook, NULL);
|
2015-07-08 12:12:44 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_WAYLAND
|
2015-08-12 17:19:18 -07:00
|
|
|
if (e_comp->comp_type != E_PIXMAP_TYPE_X)
|
|
|
|
_wl_init();
|
2015-07-08 12:12:44 -07:00
|
|
|
#endif
|
|
|
|
|
2011-05-27 23:53:44 -07:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2015-03-18 15:09:09 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
_share_done();
|
2014-11-02 18:35:13 -08:00
|
|
|
E_FREE_FUNC(win, evas_object_del);
|
2013-02-19 04:58:25 -08:00
|
|
|
E_FREE_FUNC(cd, e_object_del);
|
2011-05-27 23:53:44 -07:00
|
|
|
if (timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(timer);
|
|
|
|
timer = NULL;
|
|
|
|
}
|
|
|
|
if (maug)
|
|
|
|
{
|
|
|
|
e_int_menus_menu_augmentation_del("main/2", maug);
|
|
|
|
maug = NULL;
|
|
|
|
}
|
|
|
|
if (act)
|
|
|
|
{
|
2012-12-16 08:58:17 -08:00
|
|
|
e_action_predef_name_del("Screen", "Take Screenshot");
|
2011-05-27 23:53:44 -07:00
|
|
|
e_action_del("shot");
|
|
|
|
act = NULL;
|
|
|
|
}
|
2015-08-12 17:19:18 -07:00
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
E_FREE_FUNC(wl_global_handler, ecore_event_handler_del);
|
|
|
|
#endif
|
2011-05-27 23:53:44 -07:00
|
|
|
shot_module = NULL;
|
compositor rewrite / charlie-foxtrot situation
huge fustercluck commit because there wasn't really a way to separate out the changes. better to just rip it all out at once.
* compositor and window management completely rewritten. this was the goal for E19, but it pretty much required everything existing to be scrapped since it wasn't optimized, streamlined, or sensible. now instead of having the compositor strapped to the window manager like an outboard motor, it's housed more like an automobile engine.
** various comp structs have been merged into other places (eg. E_Comp_Zone is now just part of E_Zone where applicable), leading to a large deduplication of attributes
** awful E_Comp_Win is totally dead, having been replaced with e_comp_object smart objects which work just like normal canvas objects
** protocol-specific window management and compositor functionality is now kept exclusively in backend files
** e_pixmap api provides generic client finding and rendering api
** screen/xinerama screens are now provided directly by compositor on startup and re-set on change
** e_comp_render_update finally replaced with eina_tiler
** wayland compositor no longer creates X windows
** compositor e_layout removed entirely
* e_container is gone. this was made unnecessary in E18, but I kept it to avoid having too much code churn in one release. its sole purpose was to catch some events and handle window stacking, both of which are now just done by the compositor infra
* e_manager is just for screensaver and keybind stuff now, possibly remove later?
* e_border is gone along with a lot of its api. e_client has replaced it, and e_client has been rewritten completely; some parts may be similar, but the design now relies upon having a functional compositor
** window configuration/focus functions are all removed. all windows are now managed solely with evas_object_X functions on the "frame" member of a client, just as any other canvas object can be managed.
*** do NOT set interceptors on a client's comp_object. seriously.
* startup order rewritten: compositor now starts much earlier, other things just use attrs and members of the compositor
* ecore_x_pointer_xy_get usage replaced with ecore_evas_pointer_xy_get
* e_popup is totally gone, existing usage replaced by e_comp_object_util_add where applicable, otherwise just placed normally on the canvas
* deskmirror is (more) broken for now
* illume is totally fucked
* Ecore_X_Window replaced with Ecore_Window in most cases
* edge binding XWindows replaced with regular canvas objects
* some E_Win functionality has changed such that delete callbacks are now correctly called in ALL cases. various dialogs have been updated to not crash as a result
comp files and descriptions:
e_comp.c - overall compositor functions, rendering/update loop, shape cutting
e_comp_x.c - X window management and compositor functionality
e_comp_wl.c - Wayland surface management and compositor functionality
e_comp_canvas.c - general compositor canvas functions and utilities
e_comp_object.c - E_Client->frame member for managing clients as Evas_Objects, utility functions for adding objects to the compositor rendering systems
additional authors: ivan.briano@intel.com
feature: new compositor
removal: e_border, e_container, e_popup
2014-01-14 17:19:12 -08:00
|
|
|
e_int_client_menu_hook_del(border_hook);
|
2012-11-12 02:28:00 -08:00
|
|
|
ecore_con_url_shutdown();
|
2011-05-27 23:53:44 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API int
|
2015-03-18 15:09:09 -07:00
|
|
|
e_modapi_save(E_Module *m EINA_UNUSED)
|
2011-05-27 23:53:44 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|