ecore_evas/x: Inform WM about borders and shadows

This exploits the existing X Atom "GTK_FRAME_EXTENTS"
This commit is contained in:
Jean-Philippe Andre 2016-10-28 16:48:56 +09:00
parent 63fcd3d831
commit 4722b685cf
7 changed files with 80 additions and 0 deletions

View File

@ -2307,6 +2307,15 @@ EAPI void ecore_evas_screen_dpi_get(const Ecore_Evas *ee, int *xdpi, int
EAPI void ecore_evas_draw_frame_set(Ecore_Evas *ee, Eina_Bool draw_frame) EINA_DEPRECATED;
EAPI Eina_Bool ecore_evas_draw_frame_get(const Ecore_Evas *ee) EINA_DEPRECATED;
/**
* @brief Set shadow geometry for client-side decorations
*
* Note that the framespace contains both a shadow or glow around the window,
* and the window borders (title bar, etc...).
*/
EAPI void ecore_evas_shadow_geometry_set(Ecore_Evas *ee, int x, int y, int w, int h);
EAPI void ecore_evas_shadow_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h);
/**
* @brief Associate the given object to this ecore evas.
*

View File

@ -2236,6 +2236,30 @@ ecore_evas_draw_frame_get(const Ecore_Evas *ee EINA_UNUSED)
return EINA_FALSE;
}
EAPI void
ecore_evas_shadow_geometry_set(Ecore_Evas *ee, int l, int r, int t, int b)
{
ECORE_EVAS_CHECK(ee);
ee->shadow.l = l;
ee->shadow.r = r;
ee->shadow.t = t;
ee->shadow.b = b;
}
EAPI void
ecore_evas_shadow_geometry_get(const Ecore_Evas *ee, int *l, int *r, int *t, int *b)
{
if (l) *l = 0;
if (r) *r = 0;
if (t) *t = 0;
if (b) *b = 0;
ECORE_EVAS_CHECK(ee);
if (l) *l = ee->shadow.l;
if (r) *r = ee->shadow.r;
if (t) *t = ee->shadow.t;
if (b) *b = ee->shadow.b;
}
EAPI void
ecore_evas_pointer_xy_get(const Ecore_Evas *ee, Evas_Coord *x, Evas_Coord *y)
{

View File

@ -205,6 +205,10 @@ struct _Ecore_Evas
int x, y, w, h;
} req;
struct {
int l, r, t, b;
} shadow;
struct {
int x, y;
} mouse;

View File

@ -348,4 +348,7 @@ EAPI extern Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_OPEN; /**< @since 1.18 */
EAPI extern Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_COMPLETED; /**< @since 1.18 */
EAPI extern Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_PROGRESS; /**< @since 1.18 */
EAPI extern Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_STARTED; /**< @since 1.18 */
/* Client-Side Decorations */
EAPI extern Ecore_X_Atom ECORE_X_ATOM_GTK_FRAME_EXTENTS; /**< @since 1.19 */
#endif /* _ECORE_X_ATOMS_H */

View File

@ -378,6 +378,10 @@ EAPI Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_COMPLETED = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_PROGRESS = 0;
EAPI Ecore_X_Atom ECORE_X_ATOM_TEAMWORK_STARTED = 0;
/* Client-Side Decorations */
EAPI Ecore_X_Atom ECORE_X_ATOM_GTK_FRAME_EXTENTS = 0;
//EAPI Ecore_X_Atom ECORE_X_ATOM_NET_WM_OPAQUE_REGION = 0;
typedef struct _Atom_Item Atom_Item;
struct _Atom_Item
@ -706,5 +710,8 @@ const Atom_Item atom_items[] =
{ "_TEAMWORK_COMPLETED", &ECORE_X_ATOM_TEAMWORK_COMPLETED },
{ "_TEAMWORK_PROGRESS", &ECORE_X_ATOM_TEAMWORK_PROGRESS },
{ "_TEAMWORK_STARTED", &ECORE_X_ATOM_TEAMWORK_STARTED },
{ "_GTK_FRAME_EXTENTS", &ECORE_X_ATOM_GTK_FRAME_EXTENTS },
//{ "_NET_WM_OPAQUE_REGION", &ECORE_X_ATOM_NET_WM_OPAQUE_REGION },
};

View File

@ -1370,6 +1370,7 @@ _elm_win_opaque_update(Efl_Ui_Win_Data *sd)
else
ecore_wl2_window_opaque_region_set(sd->wl.win, 0, 0, 0, 0);
/* FIXME: Replace with call to ecore_evas_shadow_geometry_set(). */
ecore_wl2_window_geometry_set(sd->wl.win, ox, oy, ow, oh);
ecore_wl2_window_input_region_set(sd->wl.win, ox, oy, ow, oh);
}
@ -2863,6 +2864,25 @@ super_skip:
efl_gfx_position_set(efl_super(obj, EFL_CANVAS_GROUP_CLASS), x, y);
}
static inline void
_elm_win_frame_geometry_adjust(Efl_Ui_Win_Data *sd)
{
int l = 0, t = 0, r = 0, b = 0;
if (sd->frame_obj)
{
int fw, fh, ox, oy, ow, oh;
evas_object_geometry_get(sd->frame_obj, NULL, NULL, &fw, &fh);
edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
&ox, &oy, &ow, &oh);
l = ox;
t = oy;
r = fw - ow - l;
b = fh - oh - t;
}
ecore_evas_shadow_geometry_set(sd->ee, l, r, t, b);
}
EOLIAN static void
_efl_ui_win_efl_gfx_size_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Coord w, Evas_Coord h)
{
@ -2885,6 +2905,7 @@ _efl_ui_win_efl_gfx_size_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Coord w, Evas_Co
evas_object_image_size_set(sd->img_obj, w, h);
}
_elm_win_frame_geometry_adjust(sd);
if (!sd->response) TRAP(sd, resize, w, h);
efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);
@ -3292,6 +3313,7 @@ _elm_win_resize_objects_eval(Evas_Object *obj)
if (sd->img_obj) evas_object_resize(obj, w, h);
else
{
_elm_win_frame_geometry_adjust(sd);
if (!sd->response) TRAP(sd, resize, w, h);
}
}
@ -4023,6 +4045,7 @@ _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *style)
if (ecore_evas_maximized_get(sd->ee))
edje_object_signal_emit(sd->frame_obj, "elm,state,maximize", "elm");
_elm_win_frame_geometry_adjust(sd);
ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
ecore_evas_resize(sd->ee, w, h);
}
@ -4070,6 +4093,7 @@ _elm_win_frame_del(Efl_Ui_Win_Data *sd)
if (sd->icon) evas_object_hide(sd->icon);
evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
_elm_win_frame_geometry_adjust(sd);
ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
ecore_evas_resize(sd->ee, w, h);
#ifdef HAVE_ELEMENTARY_WL2

View File

@ -2170,6 +2170,7 @@ _ecore_evas_x_resize(Ecore_Evas *ee, int w, int h)
Ecore_Evas_Engine_Data_X11 *edata = ee->engine.data;
Eina_Bool changed = EINA_FALSE;
int fw = 0, fh = 0;
int zero[4] = {0};
evas_output_framespace_get(ee->evas, NULL, NULL, &fw, &fh);
if (ECORE_EVAS_PORTRAIT(ee)) SWAP_INT(fw, fh);
@ -2233,6 +2234,14 @@ _ecore_evas_x_resize(Ecore_Evas *ee, int w, int h)
if (changed) edata->configure_reqs++;
if (ee->prop.window) ecore_x_window_resize(ee->prop.window, w + fw, h + fh);
}
if (memcmp(&zero, &ee->shadow, sizeof(zero)))
{
ecore_x_window_prop_property_set(ee->prop.window,
ECORE_X_ATOM_GTK_FRAME_EXTENTS,
ECORE_X_ATOM_CARDINAL, 32,
&ee->shadow, 4);
}
}
static void