summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2010-10-01 20:01:47 +0200
committerHans de Goede <hdegoede@redhat.com>2010-10-01 20:01:47 +0200
commita2d645ffe3fa23e8c57950987c93c0fe8822238b (patch)
tree76621a76bdc10c4dd86c91300c98870859ada29a
parentc6e9c52a2a588fa11f516e96f3ba5fea3cd67274 (diff)
downloadspice-a2d645ffe3fa23e8c57950987c93c0fe8822238b.tar.gz
spice-a2d645ffe3fa23e8c57950987c93c0fe8822238b.tar.xz
spice-a2d645ffe3fa23e8c57950987c93c0fe8822238b.zip
Change VD_AGENT_CLIPBOARD_GRAB to an array of types
A clipboard owner can indicate that it can supply the data the clipboard owns in multiple formats, so make the data passed with a VD_AGENT_CLIPBOARD_GRAB message an array of types rather then a single type.
-rw-r--r--client/platform.h4
-rw-r--r--client/red_client.cpp10
-rw-r--r--client/red_client.h17
-rw-r--r--client/windows/platform.cpp11
-rw-r--r--client/x11/platform.cpp12
5 files changed, 34 insertions, 20 deletions
diff --git a/client/platform.h b/client/platform.h
index 47278893..48476cf2 100644
--- a/client/platform.h
+++ b/client/platform.h
@@ -121,7 +121,7 @@ public:
class ClipboardListener;
static void set_clipboard_listener(ClipboardListener* listener);
- static bool set_clipboard_owner(uint32_t type);
+ static bool set_clipboard_owner(uint32_t *types, uint32_t type_count);
static bool set_clipboard_data(uint32_t type, const uint8_t* data, int32_t size);
static bool request_clipboard_notification(uint32_t type);
static void release_clipboard();
@@ -138,7 +138,7 @@ public:
class Platform::ClipboardListener {
public:
virtual ~ClipboardListener() {}
- virtual void on_clipboard_grab(uint32_t type) = 0;
+ virtual void on_clipboard_grab(uint32_t *types, uint32_t type_count) = 0;
virtual void on_clipboard_request(uint32_t type) = 0;
virtual void on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) = 0;
};
diff --git a/client/red_client.cpp b/client/red_client.cpp
index 562b8269..e3519006 100644
--- a/client/red_client.cpp
+++ b/client/red_client.cpp
@@ -83,9 +83,8 @@ uint32_t default_agent_caps[] = {
void ClipboardGrabEvent::response(AbstractProcessLoop& events_loop)
{
- VDAgentClipboardGrab grab = {_type};
static_cast<RedClient*>(events_loop.get_owner())->send_agent_clipboard_message(
- VD_AGENT_CLIPBOARD_GRAB, sizeof(grab), &grab);
+ VD_AGENT_CLIPBOARD_GRAB, _type_count * sizeof(uint32_t), _types);
}
void ClipboardRequestEvent::response(AbstractProcessLoop& events_loop)
@@ -834,13 +833,13 @@ void RedClient::send_agent_clipboard_message(uint32_t message_type, uint32_t siz
post_message(message);
}
-void RedClient::on_clipboard_grab(uint32_t type)
+void RedClient::on_clipboard_grab(uint32_t *types, uint32_t type_count)
{
if (!_agent_caps || !VD_AGENT_HAS_CAPABILITY(_agent_caps, _agent_caps_size,
VD_AGENT_CAP_CLIPBOARD_BY_DEMAND)) {
return;
}
- AutoRef<ClipboardGrabEvent> event(new ClipboardGrabEvent(type));
+ AutoRef<ClipboardGrabEvent> event(new ClipboardGrabEvent(types, type_count));
get_process_loop().push_event(*event);
}
@@ -1091,7 +1090,8 @@ void RedClient::dispatch_agent_message(VDAgentMessage* msg, void* data)
break;
}
case VD_AGENT_CLIPBOARD_GRAB:
- Platform::set_clipboard_owner(((VDAgentClipboardGrab*)data)->type);
+ Platform::set_clipboard_owner((uint32_t *)data,
+ msg->size / sizeof(uint32_t));
break;
case VD_AGENT_CLIPBOARD_REQUEST:
if (!Platform::request_clipboard_notification(((VDAgentClipboardRequest*)data)->type)) {
diff --git a/client/red_client.h b/client/red_client.h
index 3ccb8e32..2cfce494 100644
--- a/client/red_client.h
+++ b/client/red_client.h
@@ -146,11 +146,22 @@ public:
class ClipboardGrabEvent : public Event {
public:
- ClipboardGrabEvent(uint32_t type) : _type (type) {}
+ ClipboardGrabEvent(uint32_t *types, uint32_t type_count)
+ {
+ _types = new uint32_t [type_count];
+ memcpy(_types, types, type_count * sizeof(uint32_t));
+ _type_count = type_count;
+ }
+ ~ClipboardGrabEvent()
+ {
+ delete[] _types;
+ }
+
virtual void response(AbstractProcessLoop& events_loop);
private:
- uint32_t _type;
+ uint32_t *_types;
+ uint32_t _type_count;
};
class ClipboardRequestEvent : public Event {
@@ -207,7 +218,7 @@ public:
PixmapCache& get_pixmap_cache() {return _pixmap_cache;}
uint64_t get_pixmap_cache_size() { return _pixmap_cache_size;}
void on_display_mode_change();
- void on_clipboard_grab(uint32_t type);
+ void on_clipboard_grab(uint32_t *types, uint32_t type_count);
void on_clipboard_request(uint32_t type);
void on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size);
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index 95876dc5..2a629440 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -51,7 +51,7 @@ static ProcessLoop* main_loop = NULL;
class DefaultClipboardListener: public Platform::ClipboardListener {
public:
- virtual void on_clipboard_grab(uint32_t type) {}
+ virtual void on_clipboard_grab(uint32_t *types, uint32_t type_count) {}
virtual void on_clipboard_request(uint32_t type) {}
virtual void on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) {}
};
@@ -151,7 +151,7 @@ static LRESULT CALLBACK PlatformWinProc(HWND hWnd, UINT message, WPARAM wParam,
if (!clipboard_changer) {
uint32_t type = get_available_clipboard_type();
if (type) {
- clipboard_listener->on_clipboard_grab(type);
+ clipboard_listener->on_clipboard_grab(&type, 1);
} else {
LOG_INFO("Unsupported clipboard format");
}
@@ -856,12 +856,13 @@ void WinPlatform::exit_modal_loop()
modal_loop_active = false;
}
-bool Platform::set_clipboard_owner(uint32_t type)
+bool Platform::set_clipboard_owner(uint32_t *types, uint32_t type_count)
{
- uint32_t format = get_clipboard_format(type);
+ /* FIXME use all types rather then just the first one */
+ uint32_t format = get_clipboard_format(types[0]);
if (!format) {
- LOG_INFO("Unsupported clipboard type %u", type);
+ LOG_INFO("Unsupported clipboard type %u", types[0]);
return false;
}
if (!OpenClipboard(platform_win)) {
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 8f4ed2de..66271872 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -151,7 +151,7 @@ static Platform::DisplayModeListener* display_mode_listener = &default_display_m
class DefaultClipboardListener: public Platform::ClipboardListener {
public:
- void on_clipboard_grab(uint32_t type) {}
+ void on_clipboard_grab(uint32_t *types, uint32_t type_count) {}
void on_clipboard_request(uint32_t type) {}
void on_clipboard_notify(uint32_t type, uint8_t* data, int32_t size) {}
};
@@ -2392,7 +2392,8 @@ static void root_win_proc(XEvent& event)
return;
}
// FIXME: use actual type
- clipboard_listener->on_clipboard_grab(VD_AGENT_CLIPBOARD_UTF8_TEXT);
+ uint32_t type = VD_AGENT_CLIPBOARD_UTF8_TEXT;
+ clipboard_listener->on_clipboard_grab(&type, 1);
return;
}
switch (event.type) {
@@ -3144,13 +3145,14 @@ LocalCursor* Platform::create_default_cursor()
return new XDefaultCursor();
}
-bool Platform::set_clipboard_owner(uint32_t type)
+bool Platform::set_clipboard_owner(uint32_t *types, uint32_t type_count)
{
Lock lock(clipboard_lock);
- uint32_t format = get_clipboard_format(type);
+ /* FIXME use all types rather then just the first one */
+ uint32_t format = get_clipboard_format(types[0]);
if (!format) {
- LOG_INFO("Unsupported clipboard type %u", type);
+ LOG_INFO("Unsupported clipboard type %u", types[0]);
return false;
}
clipboard_changer = true;