poc for shadow toggling

https://www.enlightenment.org/ss/e-5663260720de00.68316445.png
This commit is contained in:
Mike Blumenkrantz 2015-12-04 14:40:02 -05:00
parent f50a434bd1
commit 888870b1ba
10 changed files with 168 additions and 1 deletions

View File

@ -20,6 +20,8 @@ lib/ecore_wl2/ecore_wl2_input.c \
lib/ecore_wl2/ecore_wl2_output.c \
lib/ecore_wl2/ecore_wl2_display.c \
lib/ecore_wl2/ecore_wl2.c \
lib/ecore_wl2/draw-mode.c \
lib/ecore_wl2/draw-mode.h \
lib/ecore_wl2/ecore_wl2_private.h
lib_ecore_wl2_libecore_wl2_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_WL2_CFLAGS@

View File

@ -124,6 +124,7 @@ typedef struct _Ecore_Wl2_Event_Window_Configure
{
unsigned int win, event_win, edges;
int x, y, w, h;
Eina_Bool no_shadow;
} Ecore_Wl2_Event_Window_Configure;
typedef enum _Ecore_Wl2_Window_Type
@ -1006,6 +1007,8 @@ EAPI void ecore_wl2_keyboard_repeat_info_set(Ecore_Wl2_Keyboard *kbd, double rat
/* } */
/* # endif */
EAPI Eina_Bool ecore_wl2_window_shadow_get(const Ecore_Wl2_Window *win);
# undef EAPI
# define EAPI

View File

@ -0,0 +1,21 @@
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
extern const struct wl_interface xdg_surface_interface;
static const struct wl_interface *types[] = {
&xdg_surface_interface,
NULL,
};
static const struct wl_message draw_modes_requests[] = {
{ "set_available_draw_modes", "oa", types + 0 },
};
WL_EXPORT const struct wl_interface draw_modes_interface = {
"draw_modes", 1,
1, draw_modes_requests,
0, NULL,
};

View File

@ -0,0 +1,63 @@
#ifndef ZWP_DRAW_MODES_CLIENT_PROTOCOL_H
#define ZWP_DRAW_MODES_CLIENT_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"
struct wl_client;
struct wl_resource;
struct draw_modes;
extern const struct wl_interface draw_modes_interface;
#ifndef DRAW_MODES_STATE_ENUM
#define DRAW_MODES_STATE_ENUM
/**
* draw_modes_state - the surface has CSD without dropshadow
* @DRAW_MODES_STATE_DRAW_NOSHADOW: CSD with no dropshadow
*
* The surface contains a CSD region which does not include a dropshadow.
*/
enum draw_modes_state {
DRAW_MODES_STATE_DRAW_NOSHADOW = 0x2000,
};
#endif /* DRAW_MODES_STATE_ENUM */
#define DRAW_MODES_SET_AVAILABLE_DRAW_MODES 0
static inline void
draw_modes_set_user_data(struct draw_modes *draw_modes, void *user_data)
{
wl_proxy_set_user_data((struct wl_proxy *) draw_modes, user_data);
}
static inline void *
draw_modes_get_user_data(struct draw_modes *draw_modes)
{
return wl_proxy_get_user_data((struct wl_proxy *) draw_modes);
}
static inline void
draw_modes_destroy(struct draw_modes *draw_modes)
{
wl_proxy_destroy((struct wl_proxy *) draw_modes);
}
static inline void
draw_modes_set_available_draw_modes(struct draw_modes *draw_modes, struct xdg_surface *surface, struct wl_array *states)
{
wl_proxy_marshal((struct wl_proxy *) draw_modes,
DRAW_MODES_SET_AVAILABLE_DRAW_MODES, surface, states);
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,37 @@
<protocol name="zwp_draw_modes">
<interface name="draw_modes" version="1">
<request name="set_available_draw_modes">
<description summary="advertise optional draw modes for the window">
Inform the compositor of optional draw modes which are available
for the window.
Calling this after an xdg_surface's first commit is a client error.
Required modes are implemented by all clients and are not present in
this array. If set_available_draw_modes is not called, only required
modes are available.
</description>
<arg name="surface" type="object" interface="xdg_surface"/>
<arg name="states" type="array"/>
</request>
<enum name="state">
<description summary="types of state on the surface">
The different state values used on the surface. This is designed for
state values like maximized, fullscreen. It is paired with the
configure event to ensure that both the client and the compositor
setting the state can be synchronized.
States set in this way are double-buffered. They will get applied on
the next commit.
Compositors will pass a draw mode in every states array when the mode is
not "CSD with optional dropshadow".
</description>
<entry name="draw_noshadow" value="0x2000" summary="CSD with no dropshadow">
<description summary="the surface has CSD without dropshadow">
The surface contains a CSD region which does not include a dropshadow.
</description>
</entry>
</enum>
</interface>
</protocol>

View File

@ -3,6 +3,7 @@
#endif
#include "ecore_wl2_private.h"
#include "draw-mode.h"
static Eina_Bool _fatal_error = EINA_FALSE;
static Eina_Hash *_server_displays = NULL;
@ -49,6 +50,7 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
ewd = data;
fprintf(stderr, "wl_global disp %p interface %s\n", ewd, interface);
/* test to see if we have already added this global to our hash */
if (!eina_hash_find(ewd->globals, &id))
{
@ -74,6 +76,7 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
if (!strcmp(interface, "wl_compositor"))
{
fprintf(stderr, "wl_compositor.bind disp %p\n", ewd);
ewd->wl.compositor =
wl_registry_bind(registry, id, &wl_compositor_interface, 3);
}
@ -113,6 +116,10 @@ _cb_global_add(void *data, struct wl_registry *registry, unsigned int id, const
_ecore_wl2_output_add(ewd, id);
else if (!strcmp(interface, "wl_seat"))
_ecore_wl2_input_add(ewd, id, version);
else if (!strcmp(interface, "draw_modes"))
{
ewd->wl.draw_modes = wl_registry_bind(registry, id, &draw_modes_interface, 1);
}
event:
/* allocate space for event structure */

View File

@ -62,6 +62,7 @@ struct _Ecore_Wl2_Display
struct wl_shm *shm;
struct wl_shell *wl_shell;
struct xdg_shell *xdg_shell;
struct draw_modes *draw_modes;
} wl;
uint32_t serial;
@ -137,6 +138,7 @@ struct _Ecore_Wl2_Window
Eina_Bool resizing : 1;
Eina_Bool alpha : 1;
Eina_Bool transparent : 1;
Eina_Bool no_shadow : 1;
};
struct _Ecore_Wl2_Output
@ -404,4 +406,5 @@ void _ecore_wl2_dnd_del(Ecore_Wl2_Dnd_Source *source);
void _ecore_wl2_subsurf_free(Ecore_Wl2_Subsurface *subsurf);
void _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window);
void _ecore_wl2_window_draw_modes_init(Ecore_Wl2_Window *window);
#endif

View File

@ -3,6 +3,7 @@
#endif
#include "ecore_wl2_private.h"
#include "draw-mode.h"
static void
_ecore_wl2_window_configure_send(Ecore_Wl2_Window *window, int w, int h, unsigned int edges)
@ -19,6 +20,7 @@ _ecore_wl2_window_configure_send(Ecore_Wl2_Window *window, int w, int h, unsigne
ev->w = w;
ev->h = h;
ev->edges = edges;
ev->no_shadow = window->no_shadow;
ecore_event_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, ev, NULL, NULL);
}
@ -90,11 +92,15 @@ _xdg_surface_cb_configure(void *data, struct xdg_surface *xdg_surface EINA_UNUSE
win->fullscreen = EINA_FALSE;
win->focused = EINA_FALSE;
win->resizing = EINA_FALSE;
win->no_shadow = 0;
wl_array_for_each(s, states)
{
switch (*s)
{
case DRAW_MODES_STATE_DRAW_NOSHADOW:
win->no_shadow = 1;
break;
case XDG_SURFACE_STATE_MAXIMIZED:
win->maximized = EINA_TRUE;
break;
@ -214,6 +220,19 @@ _ecore_wl2_window_type_set(Ecore_Wl2_Window *win)
}
}
void
_ecore_wl2_window_draw_modes_init(Ecore_Wl2_Window *window)
{
struct wl_array modes;
uint32_t *m;
wl_array_init(&modes);
m = wl_array_add(&modes, sizeof(uint32_t));
*m = DRAW_MODES_STATE_DRAW_NOSHADOW;
draw_modes_set_available_draw_modes(window->display->wl.draw_modes, window->xdg_surface, &modes);
wl_array_release(&modes);
}
void
_ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window)
{
@ -229,6 +248,8 @@ _ecore_wl2_window_shell_surface_init(Ecore_Wl2_Window *window)
if (window->class)
xdg_surface_set_app_id(window->xdg_surface, window->class);
if (window->display->wl.draw_modes)
_ecore_wl2_window_draw_modes_init(window);
xdg_surface_set_user_data(window->xdg_surface, window);
xdg_surface_add_listener(window->xdg_surface,
@ -305,6 +326,7 @@ ecore_wl2_window_surface_get(Ecore_Wl2_Window *window)
if (!window->surface)
{
fprintf(stderr, "ecore_wl2_window_surface_get() disp %p\n", window->display);
EINA_SAFETY_ON_NULL_RETURN_VAL(window->display->wl.compositor, NULL);
window->surface =
@ -874,3 +896,10 @@ ecore_wl2_window_input_get(Ecore_Wl2_Window *window)
return NULL;
}
EAPI Eina_Bool
ecore_wl2_window_shadow_get(const Ecore_Wl2_Window *win)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE);
return !win->no_shadow;
}

View File

@ -195,7 +195,8 @@ _ecore_evas_wl_common_cb_window_configure(void *data EINA_UNUSED, int type EINA_
_ecore_evas_wl_common_border_update(ee);
if ((prev_max != ee->prop.maximized) ||
(prev_full != ee->prop.fullscreen))
(prev_full != ee->prop.fullscreen) ||
(wdata->no_shadow != ev->no_shadow))
_ecore_evas_wl_common_state_update(ee);
/* NB: We receive window configure sizes based on xdg surface

View File

@ -39,6 +39,7 @@ struct _Ecore_Evas_Engine_Wl_Data
struct wl_egl_window *egl_win;
#endif
struct wl_callback *anim_callback;
Eina_Bool no_shadow : 1;
};
Ecore_Evas_Interface_Wayland *_ecore_evas_wl_interface_new(void);