Start a selection transfer object
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
0f948d0dd9
commit
b979fb724a
|
@ -89,6 +89,7 @@ set(AWE_SRCS
|
||||||
${BUILD_DIR}/objects/key.c
|
${BUILD_DIR}/objects/key.c
|
||||||
${BUILD_DIR}/objects/screen.c
|
${BUILD_DIR}/objects/screen.c
|
||||||
${BUILD_DIR}/objects/selection_acquire.c
|
${BUILD_DIR}/objects/selection_acquire.c
|
||||||
|
${BUILD_DIR}/objects/selection_transfer.c
|
||||||
${BUILD_DIR}/objects/selection_watcher.c
|
${BUILD_DIR}/objects/selection_watcher.c
|
||||||
${BUILD_DIR}/objects/tag.c
|
${BUILD_DIR}/objects/tag.c
|
||||||
${BUILD_DIR}/objects/selection_getter.c
|
${BUILD_DIR}/objects/selection_getter.c
|
||||||
|
|
4
luaa.c
4
luaa.c
|
@ -51,6 +51,7 @@
|
||||||
#include "objects/selection_getter.h"
|
#include "objects/selection_getter.h"
|
||||||
#include "objects/screen.h"
|
#include "objects/screen.h"
|
||||||
#include "objects/selection_acquire.h"
|
#include "objects/selection_acquire.h"
|
||||||
|
#include "objects/selection_transfer.h"
|
||||||
#include "objects/selection_watcher.h"
|
#include "objects/selection_watcher.h"
|
||||||
#include "objects/tag.h"
|
#include "objects/tag.h"
|
||||||
#include "property.h"
|
#include "property.h"
|
||||||
|
@ -1044,6 +1045,9 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath)
|
||||||
/* Export selection acquire */
|
/* Export selection acquire */
|
||||||
selection_acquire_class_setup(L);
|
selection_acquire_class_setup(L);
|
||||||
|
|
||||||
|
/* Export selection transfer */
|
||||||
|
selection_transfer_class_setup(L);
|
||||||
|
|
||||||
/* Export selection watcher */
|
/* Export selection watcher */
|
||||||
selection_watcher_class_setup(L);
|
selection_watcher_class_setup(L);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "objects/selection_acquire.h"
|
#include "objects/selection_acquire.h"
|
||||||
|
#include "objects/selection_transfer.h"
|
||||||
#include "common/luaobject.h"
|
#include "common/luaobject.h"
|
||||||
#include "globalconf.h"
|
#include "globalconf.h"
|
||||||
|
|
||||||
|
@ -107,41 +108,6 @@ selection_handle_selectionclear(xcb_selection_clear_event_t *ev)
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
selection_transfer_notify(xcb_window_t requestor, xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t time)
|
|
||||||
{
|
|
||||||
xcb_selection_notify_event_t ev;
|
|
||||||
|
|
||||||
p_clear(&ev, 1);
|
|
||||||
ev.response_type = XCB_SELECTION_NOTIFY;
|
|
||||||
ev.requestor = requestor;
|
|
||||||
ev.selection = selection;
|
|
||||||
ev.target = target;
|
|
||||||
ev.property = property;
|
|
||||||
ev.time = time;
|
|
||||||
|
|
||||||
xcb_send_event(globalconf.connection, false, requestor, XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
selection_transfer_reject(xcb_window_t requestor, xcb_atom_t selection,
|
|
||||||
xcb_atom_t target, xcb_timestamp_t time)
|
|
||||||
{
|
|
||||||
selection_transfer_notify(requestor, selection, target, XCB_NONE, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "common/atoms.h" /* TODO remove */
|
|
||||||
static void
|
|
||||||
selection_transfer_begin(lua_State *L, int ud, xcb_window_t requestor,
|
|
||||||
xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property,
|
|
||||||
xcb_timestamp_t time)
|
|
||||||
{
|
|
||||||
/* TODO implement this */
|
|
||||||
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
|
||||||
requestor, property, UTF8_STRING, 8, 5, "Test\n");
|
|
||||||
selection_transfer_notify(requestor, selection, target, property, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
selection_handle_selectionrequest(xcb_selection_request_event_t *ev)
|
selection_handle_selectionrequest(xcb_selection_request_event_t *ev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* selection_transfer.c - objects for selection transfer header
|
||||||
|
*
|
||||||
|
* Copyright © 2019 Uli Schlachter <psychon@znc.in>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "objects/selection_transfer.h"
|
||||||
|
#include "common/luaobject.h"
|
||||||
|
#include "globalconf.h"
|
||||||
|
|
||||||
|
#define REGISTRY_TRANSFER_TABLE_INDEX "awesome_selection_transfers"
|
||||||
|
|
||||||
|
typedef struct selection_transfer_t
|
||||||
|
{
|
||||||
|
LUA_OBJECT_HEADER
|
||||||
|
} selection_transfer_t;
|
||||||
|
|
||||||
|
static lua_class_t selection_transfer_class;
|
||||||
|
LUA_OBJECT_FUNCS(selection_transfer_class, selection_transfer_t, selection_transfer)
|
||||||
|
|
||||||
|
static void
|
||||||
|
selection_transfer_notify(xcb_window_t requestor, xcb_atom_t selection,
|
||||||
|
xcb_atom_t target, xcb_atom_t property, xcb_timestamp_t time)
|
||||||
|
{
|
||||||
|
xcb_selection_notify_event_t ev;
|
||||||
|
|
||||||
|
p_clear(&ev, 1);
|
||||||
|
ev.response_type = XCB_SELECTION_NOTIFY;
|
||||||
|
ev.requestor = requestor;
|
||||||
|
ev.selection = selection;
|
||||||
|
ev.target = target;
|
||||||
|
ev.property = property;
|
||||||
|
ev.time = time;
|
||||||
|
|
||||||
|
xcb_send_event(globalconf.connection, false, requestor,
|
||||||
|
XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
selection_transfer_reject(xcb_window_t requestor, xcb_atom_t selection,
|
||||||
|
xcb_atom_t target, xcb_timestamp_t time)
|
||||||
|
{
|
||||||
|
selection_transfer_notify(requestor, selection, target, XCB_NONE, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "common/atoms.h" /* TODO remove */
|
||||||
|
void
|
||||||
|
selection_transfer_begin(lua_State *L, int ud, xcb_window_t requestor,
|
||||||
|
xcb_atom_t selection, xcb_atom_t target, xcb_atom_t property,
|
||||||
|
xcb_timestamp_t time)
|
||||||
|
{
|
||||||
|
/* TODO implement this */
|
||||||
|
xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE,
|
||||||
|
requestor, property, UTF8_STRING, 8, 5, "Test\n");
|
||||||
|
selection_transfer_notify(requestor, selection, target, property, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
selection_transfer_checker(selection_transfer_t *selection)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
selection_transfer_class_setup(lua_State *L)
|
||||||
|
{
|
||||||
|
static const struct luaL_Reg selection_transfer_methods[] =
|
||||||
|
{
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct luaL_Reg selection_transfer_meta[] =
|
||||||
|
{
|
||||||
|
LUA_OBJECT_META(selection_transfer)
|
||||||
|
LUA_CLASS_META
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Store a table in the registry that tracks active selection_transfer_t. */
|
||||||
|
lua_pushliteral(L, REGISTRY_TRANSFER_TABLE_INDEX);
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_rawset(L, LUA_REGISTRYINDEX);
|
||||||
|
|
||||||
|
luaA_class_setup(L, &selection_transfer_class, "selection_transfer", NULL,
|
||||||
|
(lua_class_allocator_t) selection_transfer_new, NULL,
|
||||||
|
(lua_class_checker_t) selection_transfer_checker,
|
||||||
|
luaA_class_index_miss_property, luaA_class_newindex_miss_property,
|
||||||
|
selection_transfer_methods, selection_transfer_meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* selection_transfer.c - objects for selection transfer header
|
||||||
|
*
|
||||||
|
* Copyright © 2019 Uli Schlachter <psychon@znc.in>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AWESOME_OBJECTS_SELECTION_TRANSFER_H
|
||||||
|
#define AWESOME_OBJECTS_SELECTION_TRANSFER_H
|
||||||
|
|
||||||
|
#include <lua.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
void selection_transfer_class_setup(lua_State*);
|
||||||
|
void selection_transfer_reject(xcb_window_t, xcb_atom_t, xcb_atom_t, xcb_timestamp_t);
|
||||||
|
void selection_transfer_begin(lua_State*, int, xcb_window_t, xcb_atom_t,
|
||||||
|
xcb_atom_t, xcb_atom_t, xcb_timestamp_t);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
Loading…
Reference in New Issue