From 541c264c2c9e9999d20eb85fbcbc6e76e78ebc58 Mon Sep 17 00:00:00 2001 From: Janos Kovacs Date: Sat, 16 Aug 2014 18:43:57 +0300 Subject: [PATCH] system-controller: thumbnail support Change-Id: I7db9d3c8dd605d9477d6dccf102983bf93434cf0 --- packaging.in/murphy.lua | 24 ++-- src/plugins/system-controller/wayland/animation.c | 1 + src/plugins/system-controller/wayland/animation.h | 1 + .../system-controller/wayland/glm-window-manager.c | 128 ++++++++++++++++++++- .../wayland/scripting-animation.c | 9 ++ 5 files changed, 149 insertions(+), 14 deletions(-) diff --git a/packaging.in/murphy.lua b/packaging.in/murphy.lua index dbfc4ce..d58065f 100644 --- a/packaging.in/murphy.lua +++ b/packaging.in/murphy.lua @@ -1172,7 +1172,7 @@ wmgr = window_manager { command = 0x10020 end arg.attr = map.type - arg.name = map.target + --arg.name = map.target arg.width = map.width arg.height = map.height arg.stride = map.stride @@ -1655,16 +1655,20 @@ if sc then wmgr:window_request(msg.arg, a, 0) elseif msg.command == 0x10020 then -- ico MAP_THUMB local framerate = msg.arg.framerate - if not framerate or framerate < 0 then - framerate = 0 + local animname = msg.arg.anim_name + if animname then + a.map = { animname, 1 } + if not framerate or framerate < 0 then + framerate = 5 + end + msg.arg.mapped = 1 + if verbose > 2 then + print('### ==> MAP_THUMB REQUEST') + print(msg.arg) + print('framerate: '..framerate) + end + wmgr:window_request(msg.arg, a, framerate) end - msg.arg.mapped = 1 - if verbose > 2 then - print('### ==> MAP_THUMB REQUEST') - print(msg.arg) - print('framerate: '..framerate) - end - wmgr:window_request(msg.arg, a, framerate) elseif msg.command == 0x10021 then -- ico UNMAP_THUMB msg.arg.mapped = 0 if verbose > 2 then diff --git a/src/plugins/system-controller/wayland/animation.c b/src/plugins/system-controller/wayland/animation.c index 1b27e23..fa2b3e5 100644 --- a/src/plugins/system-controller/wayland/animation.c +++ b/src/plugins/system-controller/wayland/animation.c @@ -135,6 +135,7 @@ static const char *type_str(mrp_wayland_animation_type_t type) case MRP_WAYLAND_ANIMATION_SHOW: str = "show"; break; case MRP_WAYLAND_ANIMATION_MOVE: str = "move"; break; case MRP_WAYLAND_ANIMATION_RESIZE: str = "resize"; break; + case MRP_WAYLAND_ANIMATION_MAP: str = "map"; break; default: str = ""; break; } diff --git a/src/plugins/system-controller/wayland/animation.h b/src/plugins/system-controller/wayland/animation.h index f1fbe32..cdf986b 100644 --- a/src/plugins/system-controller/wayland/animation.h +++ b/src/plugins/system-controller/wayland/animation.h @@ -40,6 +40,7 @@ enum mrp_wayland_animation_type_e { MRP_WAYLAND_ANIMATION_SHOW, MRP_WAYLAND_ANIMATION_MOVE, MRP_WAYLAND_ANIMATION_RESIZE, + MRP_WAYLAND_ANIMATION_MAP, MRP_WAYLAND_ANIMATION_MAX }; diff --git a/src/plugins/system-controller/wayland/glm-window-manager.c b/src/plugins/system-controller/wayland/glm-window-manager.c index dc4d64a..0d09803 100644 --- a/src/plugins/system-controller/wayland/glm-window-manager.c +++ b/src/plugins/system-controller/wayland/glm-window-manager.c @@ -2061,6 +2061,11 @@ static void ico_extension_map_surface_callback(void *data, ico_extension_t *ico = (ico_extension_t *)data; mrp_wayland_t *wl; mrp_glm_window_manager_t *wm; + ctrl_surface_t *sf; + mrp_wayland_window_t *win; + mrp_wayland_window_update_t u; + mrp_wayland_window_map_t map; + char id_str[256]; MRP_ASSERT(ico && ico->interface && ico->interface->wl, "invalid argument"); @@ -2075,6 +2080,50 @@ static void ico_extension_map_surface_callback(void *data, mrp_debug("event=%d surfaceid=%u type=%u width=%d height=%d stride=%d " "format=%u", event, surfaceid, type, width,height, stride, format); + + surface_id_print(surfaceid, id_str, sizeof(id_str)); + + if (!(sf = surface_find(wm, surfaceid))) { + mrp_debug("can't find surface for id=%s", id_str); + return; + } + + if (!(win = sf->win)) { + mrp_debug("can't forward map event for surface id=%s " + "(no window)", id_str); + return; + } + + memset(&map, 0, sizeof(map)); + map.type = type; + map.width = width; + map.height = height; + map.stride = stride; + map.format = format; + + memset(&u, 0, sizeof(u)); + u.mask = MRP_WAYLAND_WINDOW_MAPPED_MASK | MRP_WAYLAND_WINDOW_MAP_MASK; + u.map = ↦ + + switch (event) { + + case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_CONTENTS: + case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_RESIZE: + case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_MAP: + u.mapped = true; + break; + + case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_UNMAP: + case ICO_WINDOW_MGR_MAP_SURFACE_EVENT_ERROR: + u.mapped = false; + break; + + default: + mrp_debug("ignoring unknown event type %d event", event); + return; + } + + mrp_wayland_window_update(win, MRP_WAYLAND_WINDOW_MAP, &u); } static void ico_extension_update_surface_callback(void *data, @@ -2204,9 +2253,9 @@ static constructor_t *constructor_create(mrp_glm_window_manager_t *wm, mrp_list_append(&wm->constructors, &c->link); - mrp_debug("constructor created (state=%s, pid=%d, title='%s' id_surface=%u)", - constructor_state_str(state), pid, title?title:"", id_surface); -ace); + mrp_debug("constructor created (state=%s, pid=%d, title='%s' " + "id_surface=%u)", constructor_state_str(state), pid, + title ? title: "", id_surface); return c; } @@ -2629,6 +2678,72 @@ static bool set_window_layer(mrp_wayland_window_t *win, return changed; } +static bool set_window_mapped(mrp_wayland_window_t *win, + mrp_wayland_window_update_mask_t passthrough, + mrp_wayland_window_update_t *u, + mrp_wayland_animation_t *anims, + uint32_t framerate) +{ + mrp_glm_window_manager_t *wm = (mrp_glm_window_manager_t *)win->wm; + ico_extension_t *ico = wm->ico; + int32_t id_surface; + struct ico_window_mgr *ico_window_mgr; + const char *filepath; + char id_str[256]; + + ico_window_mgr = ico ? (struct ico_window_mgr *)ico->proxy : NULL; + id_surface = win->surfaceid; + + surface_id_print(id_surface, id_str, sizeof(id_str)); + + if (((u->mapped && win->mapped) || (!u->mapped && !win->mapped)) && + !(passthrough & MRP_WAYLAND_WINDOW_MAPPED_MASK)) + { + mrp_debug("nothing to do"); + return false; + } + + if (u->mapped) { + if (!anims || !(filepath = anims[MRP_WAYLAND_ANIMATION_MAP].name)) { + mrp_log_error("system-controller: broken map request " + "(no file path)"); + return false; + } + + if (!ico_window_mgr) { + mrp_debug("can't map surface %s to file '%s' (ico-extension not " + "available)", id_str, filepath); + return false; + } + + if (framerate == 0) + framerate = -1; + + mrp_debug("calling ico_window_mgr_map_surface" + "(ico_window_mgr=%p, surfaceid=%u, framerate=%d, " + "filepath='%s')", + ico_window_mgr, id_surface, framerate, filepath); + + ico_window_mgr_map_surface(ico_window_mgr, id_surface, framerate, + filepath); + } + else { + if (!ico_window_mgr) { + mrp_debug("can't unmap surface %u (ico-extension not available)", + win->surfaceid); + return false; + } + + mrp_debug("calling ico_window_mgr_unmap_surface" + "(ico_window_mgr=%p, surfaceid=%u)", + ico_window_mgr, id_surface, framerate, filepath); + + ico_window_mgr_unmap_surface(ico_window_mgr, id_surface); + } + + return true; +} + static bool set_window_geometry(mrp_wayland_window_t *win, mrp_wayland_window_update_mask_t passthrough, mrp_wayland_window_update_t *u, @@ -2829,9 +2944,9 @@ static void window_request(mrp_wayland_window_t *win, MRP_WAYLAND_WINDOW_AREA_MASK; static mrp_wayland_window_update_mask_t active_mask = MRP_WAYLAND_WINDOW_ACTIVE_MASK; +#endif static mrp_wayland_window_update_mask_t mapped_mask = MRP_WAYLAND_WINDOW_MAPPED_MASK; -#endif static mrp_wayland_window_update_mask_t geometry_mask = /* MRP_WAYLAND_WINDOW_NODEID_MASK | */ MRP_WAYLAND_WINDOW_POSITION_MASK | @@ -2873,6 +2988,11 @@ static void window_request(mrp_wayland_window_t *win, changed |= set_window_layer(win, passthrough, u); mask &= ~layer_mask; } + else if ((mask & mapped_mask)) { + changed |= set_window_mapped(win, passthrough, u, + anims, framerate); + mask &= ~(mapped_mask); + } #if 0 else if ((mask & area_mask)) { changed |= set_window_area(win, passthrough, u, anims); diff --git a/src/plugins/system-controller/wayland/scripting-animation.c b/src/plugins/system-controller/wayland/scripting-animation.c index 83ce688..db7b512 100644 --- a/src/plugins/system-controller/wayland/scripting-animation.c +++ b/src/plugins/system-controller/wayland/scripting-animation.c @@ -133,6 +133,7 @@ static int animation_create(lua_State *L) animation_def_t *show = NULL; animation_def_t *move = NULL; animation_def_t *resize = NULL; + animation_def_t *map = NULL; MRP_LUA_ENTER; @@ -145,6 +146,7 @@ static int animation_create(lua_State *L) case SHOW: show = animation_def_check(L, -1); break; case MOVE: move = animation_def_check(L, -1); break; case RESIZE: resize = animation_def_check(L, -1); break; + case MAP: map = animation_def_check(L, -1); break; default: luaL_error(L, "bad field '%s'", fldnam); break; } } @@ -171,6 +173,11 @@ static int animation_create(lua_State *L) resize->name, resize->time); animation_def_free(resize); } + if (map) { + mrp_wayland_animation_set(anims, MRP_WAYLAND_ANIMATION_MAP, + map->name, map->time); + animation_def_free(map); + } an = (scripting_animation_t *)mrp_lua_create_object(L, ANIMATION_CLASS, NULL, 0); @@ -204,6 +211,7 @@ static int animation_getfield(lua_State *L) case SHOW: type = MRP_WAYLAND_ANIMATION_SHOW; goto push; case MOVE: type = MRP_WAYLAND_ANIMATION_MOVE; goto push; case RESIZE: type = MRP_WAYLAND_ANIMATION_RESIZE; goto push; + case MAP: type = MRP_WAYLAND_ANIMATION_MAP; goto push; push: animation_push_type(L, anims, type); break; default: lua_pushnil(L); break; } @@ -234,6 +242,7 @@ static int animation_setfield(lua_State *L) case SHOW: type = MRP_WAYLAND_ANIMATION_SHOW; goto setfield; case MOVE: type = MRP_WAYLAND_ANIMATION_MOVE; goto setfield; case RESIZE: type = MRP_WAYLAND_ANIMATION_RESIZE; goto setfield; + case MAP: type = MRP_WAYLAND_ANIMATION_MAP; goto setfield; default: break; setfield: mrp_wayland_animation_set(anims, type, def->name, def->time); -- 2.7.4