shadow toggling wip

This commit is contained in:
Mike Blumenkrantz 2015-12-04 15:52:25 -05:00
parent a6ded999a9
commit 925468fbe9
5 changed files with 140 additions and 1 deletions

View File

@ -140,6 +140,7 @@ struct _E_Comp_Wl_Data
{
struct wl_resource *shell;
struct wl_resource *xdg_shell;
struct wl_resource *draw_modes;
} shell_interface;
struct
@ -272,6 +273,7 @@ struct _E_Comp_Wl_Client_Data
void (*map)(struct wl_resource *resource);
void (*unmap)(struct wl_resource *resource);
Eina_Rectangle window;
Eina_Bool draw_mode_noshadow;
} shell;
E_Comp_Wl_Buffer_Ref buffer_ref;

View File

@ -25,7 +25,9 @@ src_modules_wl_desktop_shell_module_la_SOURCES = \
src/modules/wl_desktop_shell/e_input_method_protocol.c \
src/modules/wl_desktop_shell/e_input_method_protocol.h \
src/modules/wl_desktop_shell/e_desktop_shell_protocol.c \
src/modules/wl_desktop_shell/e_desktop_shell_protocol.h
src/modules/wl_desktop_shell/e_desktop_shell_protocol.h \
src/modules/wl_desktop_shell/draw-mode.c \
src/modules/wl_desktop_shell/draw-mode.h
PHONIES += wl_desktop_shell install-wl_desktop_shell
wl_desktop_shell: $(wl_desktop_shellpkg_LTLIBRARIES) $(wl_desktop_shell_DATA)

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,60 @@
#ifndef ZWP_DRAW_MODES_SERVER_PROTOCOL_H
#define ZWP_DRAW_MODES_SERVER_PROTOCOL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#include "wayland-server.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 */
struct draw_modes_interface {
/**
* set_available_draw_modes - advertise optional draw modes for
* the window
* @surface: (none)
* @states: (none)
*
* 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.
*/
void (*set_available_draw_modes)(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *surface,
struct wl_array *states);
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -2,6 +2,7 @@
#include "e.h"
#include "e_mod_main.h"
#include "e_desktop_shell_protocol.h"
#include "draw-mode.h"
#define XDG_SERVER_VERSION 5
@ -623,6 +624,8 @@ _e_xdg_shell_surface_configure_send(struct wl_resource *resource, uint32_t edges
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_RESIZING);
if (ec->focused)
_e_xdg_surface_state_add(resource, &states, XDG_SURFACE_STATE_ACTIVATED);
if (ec->comp_data->shell.draw_mode_noshadow)
_e_xdg_surface_state_add(resource, &states, DRAW_MODES_STATE_DRAW_NOSHADOW);
if (ec->netwm.type != E_WINDOW_TYPE_POPUP_MENU)
{
@ -1262,6 +1265,23 @@ _e_xdg_shell_cb_pong(struct wl_client *client EINA_UNUSED, struct wl_resource *r
}
}
static void
_e_draw_modes_cb_set_available_draw_modes(struct wl_client *client EINA_UNUSED, struct wl_resource *resource EINA_UNUSED, struct wl_resource *surface, struct wl_array *modes)
{
E_Client *ec;
uint32_t *m;
ec = wl_resource_get_user_data(surface);
wl_array_for_each(m, modes)
switch (*m)
{
case DRAW_MODES_STATE_DRAW_NOSHADOW:
ec->comp_data->shell.draw_mode_noshadow = 1;
break;
}
}
static const struct wl_shell_interface _e_shell_interface =
{
_e_shell_cb_shell_surface_get
@ -1276,12 +1296,23 @@ static const struct xdg_shell_interface _e_xdg_shell_interface =
_e_xdg_shell_cb_pong
};
static const struct draw_modes_interface _e_draw_modes_interface =
{
_e_draw_modes_cb_set_available_draw_modes,
};
static void
_e_xdg_shell_cb_unbind(struct wl_resource *resource EINA_UNUSED)
{
e_comp_wl->shell_interface.xdg_shell = NULL;
}
static void
_e_draw_modes_cb_unbind(struct wl_resource *resource EINA_UNUSED)
{
e_comp_wl->shell_interface.draw_modes = NULL;
}
static int
_e_xdg_shell_cb_dispatch(const void *implementation EINA_UNUSED, void *target, uint32_t opcode, const struct wl_message *message EINA_UNUSED, union wl_argument *args)
{
@ -1351,6 +1382,23 @@ _e_xdg_shell_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t
e_comp->wl_comp_data, NULL);
}
static void
_e_draw_modes_cb_bind(struct wl_client *client, void *data EINA_UNUSED, uint32_t version, uint32_t id)
{
struct wl_resource *res;
if (!(res = wl_resource_create(client, &draw_modes_interface, version, id)))
{
wl_client_post_no_memory(client);
return;
}
e_comp_wl->shell_interface.draw_modes = res;
wl_resource_set_implementation(res, &_e_draw_modes_interface,
e_comp->wl_comp_data,
_e_draw_modes_cb_unbind);
}
E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Desktop_Shell" };
E_API void *
@ -1380,6 +1428,12 @@ e_modapi_init(E_Module *m)
ERR("Could not create xdg_shell global: %m");
return NULL;
}
if (!wl_global_create(e_comp_wl->wl.disp, &draw_modes_interface, 1,
e_comp->wl_comp_data, _e_draw_modes_cb_bind))
{
ERR("Could not create draw_modes global: %m");
return NULL;
}
#ifdef HAVE_WL_TEXT_INPUT
if (!e_input_panel_init())