|
|
@ -2,6 +2,7 @@
|
|
|
|
* xrdp: A Remote Desktop Protocol server.
|
|
|
|
* xrdp: A Remote Desktop Protocol server.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) Jay Sorg 2009-2012
|
|
|
|
* Copyright (C) Jay Sorg 2009-2012
|
|
|
|
|
|
|
|
* Copyright (C) Laxmikant Rashinkar 2012
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -19,6 +20,11 @@
|
|
|
|
for help see
|
|
|
|
for help see
|
|
|
|
http://tronche.com/gui/x/icccm/sec-2.html#s-2
|
|
|
|
http://tronche.com/gui/x/icccm/sec-2.html#s-2
|
|
|
|
.../kde/kdebase/workspace/klipper/clipboardpoll.cpp
|
|
|
|
.../kde/kdebase/workspace/klipper/clipboardpoll.cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Revision:
|
|
|
|
|
|
|
|
Aug 05, 2012:
|
|
|
|
|
|
|
|
Laxmikant Rashinkar (LK dot Rashinkar at gmail.com)
|
|
|
|
|
|
|
|
added clipboard support for BMP images
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
@ -29,6 +35,28 @@
|
|
|
|
#include "os_calls.h"
|
|
|
|
#include "os_calls.h"
|
|
|
|
#include "chansrv.h"
|
|
|
|
#include "chansrv.h"
|
|
|
|
#include "clipboard.h"
|
|
|
|
#include "clipboard.h"
|
|
|
|
|
|
|
|
#include "xcommon.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char g_bmp_image_header[] =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* this is known to work */
|
|
|
|
|
|
|
|
//0x42, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* THIS IS BEING SENT BY WIN2008 */
|
|
|
|
|
|
|
|
0x42, 0x4d, 0x16, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int g_cliprdr_chan_id; /* in chansrv.c */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern Display* g_display; /* in xcommon.c */
|
|
|
|
|
|
|
|
extern int g_x_socket; /* in xcommon.c */
|
|
|
|
|
|
|
|
extern tbus g_x_wait_obj; /* in xcommon.c */
|
|
|
|
|
|
|
|
extern Screen* g_screen; /* in xcommon.c */
|
|
|
|
|
|
|
|
extern int g_screen_num; /* in xcommon.c */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int g_clip_up = 0;
|
|
|
|
|
|
|
|
int g_waiting_for_data_response = 0;
|
|
|
|
|
|
|
|
int g_waiting_for_data_response_time = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static Atom g_clipboard_atom = 0;
|
|
|
|
static Atom g_clipboard_atom = 0;
|
|
|
|
static Atom g_clip_property_atom = 0;
|
|
|
|
static Atom g_clip_property_atom = 0;
|
|
|
@ -39,12 +67,9 @@ static Atom g_primary_atom = 0;
|
|
|
|
static Atom g_secondary_atom = 0;
|
|
|
|
static Atom g_secondary_atom = 0;
|
|
|
|
static Atom g_get_time_atom = 0;
|
|
|
|
static Atom g_get_time_atom = 0;
|
|
|
|
static Atom g_utf8_atom = 0;
|
|
|
|
static Atom g_utf8_atom = 0;
|
|
|
|
static int g_x_socket = 0;
|
|
|
|
static Atom g_image_bmp_atom = 0;
|
|
|
|
static tbus g_x_wait_obj = 0;
|
|
|
|
|
|
|
|
static int g_clip_up = 0;
|
|
|
|
|
|
|
|
static Window g_wnd = 0;
|
|
|
|
static Window g_wnd = 0;
|
|
|
|
static Screen* g_screen = 0;
|
|
|
|
|
|
|
|
static int g_screen_num = 0;
|
|
|
|
|
|
|
|
static int g_xfixes_event_base = 0;
|
|
|
|
static int g_xfixes_event_base = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static int g_last_clip_size = 0;
|
|
|
|
static int g_last_clip_size = 0;
|
|
|
@ -64,35 +89,20 @@ static int g_data_in_size = 0;
|
|
|
|
static int g_data_in_time = 0;
|
|
|
|
static int g_data_in_time = 0;
|
|
|
|
static int g_data_in_up_to_date = 0;
|
|
|
|
static int g_data_in_up_to_date = 0;
|
|
|
|
static int g_got_format_announce = 0;
|
|
|
|
static int g_got_format_announce = 0;
|
|
|
|
static int g_waiting_for_data_response = 0;
|
|
|
|
|
|
|
|
static int g_waiting_for_data_response_time = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Display* g_display = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int g_cliprdr_chan_id; /* in chansrv.c */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* for image data */
|
|
|
|
int DEFAULT_CC
|
|
|
|
static int g_want_image_data = 0;
|
|
|
|
clipboard_error_handler(Display* dis, XErrorEvent* xer)
|
|
|
|
static XSelectionRequestEvent g_saved_selection_req_event;
|
|
|
|
{
|
|
|
|
|
|
|
|
char text[256];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XGetErrorText(dis, xer->error_code, text, 255);
|
|
|
|
/* for clipboard INCR transfers */
|
|
|
|
LOGM((LOG_LEVEL_ERROR,"error [%s]", text));
|
|
|
|
static Atom g_incr_atom;
|
|
|
|
return 0;
|
|
|
|
static Atom g_incr_atom_type;
|
|
|
|
}
|
|
|
|
static Atom g_incr_atom_target;
|
|
|
|
|
|
|
|
static char* g_incr_data = 0;
|
|
|
|
|
|
|
|
static int g_incr_data_size = 0;
|
|
|
|
|
|
|
|
static int g_incr_in_progress = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
static int clipboard_format_id = CB_FORMAT_UNICODETEXT;
|
|
|
|
/* The X server had an internal error. This is the last function called.
|
|
|
|
|
|
|
|
Do any cleanup that needs to be done on exit, like removing temporary files.
|
|
|
|
|
|
|
|
Don't worry about memory leaks */
|
|
|
|
|
|
|
|
int DEFAULT_CC
|
|
|
|
|
|
|
|
clipboard_fatal_handler(Display* dis)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ALWAYS, "fatal error, exiting"));
|
|
|
|
|
|
|
|
main_cleanup();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* this is one way to get the current time from the x server */
|
|
|
|
/* this is one way to get the current time from the x server */
|
|
|
@ -144,28 +154,9 @@ clipboard_init(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xcommon_init();
|
|
|
|
clipboard_deinit();
|
|
|
|
clipboard_deinit();
|
|
|
|
rv = 0;
|
|
|
|
rv = 0;
|
|
|
|
/* setting the error handlers can cause problem when shutting down
|
|
|
|
|
|
|
|
chansrv on some xlibs */
|
|
|
|
|
|
|
|
//XSetErrorHandler(clipboard_error_handler);
|
|
|
|
|
|
|
|
//XSetIOErrorHandler(clipboard_fatal_handler);
|
|
|
|
|
|
|
|
g_display = XOpenDisplay(0);
|
|
|
|
|
|
|
|
if (g_display == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_init: XOpenDisplay failed"));
|
|
|
|
|
|
|
|
rv = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rv == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_x_socket = XConnectionNumber(g_display);
|
|
|
|
|
|
|
|
if (g_x_socket == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_init: XConnectionNumber failed"));
|
|
|
|
|
|
|
|
rv = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_x_wait_obj = g_create_wait_obj_from_socket(g_x_socket, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rv == 0)
|
|
|
|
if (rv == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g_clipboard_atom = XInternAtom(g_display, "CLIPBOARD", False);
|
|
|
|
g_clipboard_atom = XInternAtom(g_display, "CLIPBOARD", False);
|
|
|
@ -185,13 +176,11 @@ clipboard_init(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rv == 0)
|
|
|
|
if (rv == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_init: g_xfixes_event_base %d",
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_init: g_xfixes_event_base %d",
|
|
|
|
g_xfixes_event_base));
|
|
|
|
g_xfixes_event_base));
|
|
|
|
st = XFixesQueryVersion(g_display, &ver_maj, &ver_min);
|
|
|
|
st = XFixesQueryVersion(g_display, &ver_maj, &ver_min);
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_init st %d, maj %d min %d", st,
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_init st %d, maj %d min %d", st,
|
|
|
|
ver_maj, ver_min));
|
|
|
|
ver_maj, ver_min));
|
|
|
|
g_screen_num = DefaultScreen(g_display);
|
|
|
|
|
|
|
|
g_screen = ScreenOfDisplay(g_display, g_screen_num);
|
|
|
|
|
|
|
|
g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM",
|
|
|
|
g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM",
|
|
|
|
False);
|
|
|
|
False);
|
|
|
|
g_get_time_atom = XInternAtom(g_display, "XRDP_GET_TIME_ATOM",
|
|
|
|
g_get_time_atom = XInternAtom(g_display, "XRDP_GET_TIME_ATOM",
|
|
|
@ -202,6 +191,15 @@ clipboard_init(void)
|
|
|
|
g_primary_atom = XInternAtom(g_display, "PRIMARY", False);
|
|
|
|
g_primary_atom = XInternAtom(g_display, "PRIMARY", False);
|
|
|
|
g_secondary_atom = XInternAtom(g_display, "SECONDARY", False);
|
|
|
|
g_secondary_atom = XInternAtom(g_display, "SECONDARY", False);
|
|
|
|
g_utf8_atom = XInternAtom(g_display, "UTF8_STRING", False);
|
|
|
|
g_utf8_atom = XInternAtom(g_display, "UTF8_STRING", False);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_image_bmp_atom = XInternAtom(g_display, "image/bmp", False);
|
|
|
|
|
|
|
|
g_incr_atom = XInternAtom(g_display, "INCR", False);
|
|
|
|
|
|
|
|
if (g_image_bmp_atom == None)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_init: g_image_bmp_atom was "
|
|
|
|
|
|
|
|
"not allocated"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
g_wnd = XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen),
|
|
|
|
g_wnd = XCreateSimpleWindow(g_display, RootWindowOfScreen(g_screen),
|
|
|
|
0, 0, 4, 4, 0, 0, 0);
|
|
|
|
0, 0, 4, 4, 0, 0, 0);
|
|
|
|
input_mask = StructureNotifyMask | PropertyChangeMask;
|
|
|
|
input_mask = StructureNotifyMask | PropertyChangeMask;
|
|
|
@ -251,27 +249,16 @@ clipboard_init(void)
|
|
|
|
int APP_CC
|
|
|
|
int APP_CC
|
|
|
|
clipboard_deinit(void)
|
|
|
|
clipboard_deinit(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (g_x_wait_obj != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_delete_wait_obj_from_socket(g_x_wait_obj);
|
|
|
|
|
|
|
|
g_x_wait_obj = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_wnd != 0)
|
|
|
|
if (g_wnd != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XDestroyWindow(g_display, g_wnd);
|
|
|
|
XDestroyWindow(g_display, g_wnd);
|
|
|
|
g_wnd = 0;
|
|
|
|
g_wnd = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_x_socket = 0;
|
|
|
|
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
g_last_clip_data = 0;
|
|
|
|
g_last_clip_data = 0;
|
|
|
|
g_last_clip_size = 0;
|
|
|
|
g_last_clip_size = 0;
|
|
|
|
free_stream(g_ins);
|
|
|
|
free_stream(g_ins);
|
|
|
|
g_ins = 0;
|
|
|
|
g_ins = 0;
|
|
|
|
if (g_display != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XCloseDisplay(g_display);
|
|
|
|
|
|
|
|
g_display = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_clip_up = 0;
|
|
|
|
g_clip_up = 0;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -297,7 +284,7 @@ clipboard_send_data_request(void)
|
|
|
|
out_uint16_le(s, 4); /* CLIPRDR_DATA_REQUEST */
|
|
|
|
out_uint16_le(s, 4); /* CLIPRDR_DATA_REQUEST */
|
|
|
|
out_uint16_le(s, 0); /* status */
|
|
|
|
out_uint16_le(s, 0); /* status */
|
|
|
|
out_uint32_le(s, 4); /* length */
|
|
|
|
out_uint32_le(s, 4); /* length */
|
|
|
|
out_uint32_le(s, 0x0d);
|
|
|
|
out_uint32_le(s, clipboard_format_id);
|
|
|
|
s_mark_end(s);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_send_data_request: data out, sending "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_send_data_request: data out, sending "
|
|
|
@ -330,9 +317,17 @@ clipboard_send_format_ack(void)
|
|
|
|
return rv;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char windows_native_format[] =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_send_format_announce(void)
|
|
|
|
clipboard_send_format_announce(tui32 format_id, char* format_name)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct stream* s;
|
|
|
|
struct stream* s;
|
|
|
|
int size;
|
|
|
|
int size;
|
|
|
@ -342,9 +337,9 @@ clipboard_send_format_announce(void)
|
|
|
|
init_stream(s, 8192);
|
|
|
|
init_stream(s, 8192);
|
|
|
|
out_uint16_le(s, 2); /* CLIPRDR_FORMAT_ANNOUNCE */
|
|
|
|
out_uint16_le(s, 2); /* CLIPRDR_FORMAT_ANNOUNCE */
|
|
|
|
out_uint16_le(s, 0); /* status */
|
|
|
|
out_uint16_le(s, 0); /* status */
|
|
|
|
out_uint32_le(s, 0x90); /* length */
|
|
|
|
out_uint32_le(s, 4 + sizeof(windows_native_format)); /* length */
|
|
|
|
out_uint32_le(s, 0x0d); /* extra 4 bytes ? */
|
|
|
|
out_uint32_le(s, format_id);
|
|
|
|
out_uint8s(s, 0x90);
|
|
|
|
out_uint8p(s, windows_native_format, sizeof(windows_native_format));
|
|
|
|
s_mark_end(s);
|
|
|
|
s_mark_end(s);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_send_format_announce: data out, sending "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_send_format_announce: data out, sending "
|
|
|
@ -384,6 +379,39 @@ clipboard_out_unicode(struct stream* s, char* text, int num_chars)
|
|
|
|
return index * 2;
|
|
|
|
return index * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
static int APP_CC
|
|
|
|
|
|
|
|
clipboard_send_data_response_for_image(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
struct stream* s;
|
|
|
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOG(10, ("clipboard_send_data_response_for_image: g_last_clip_size %d\n",
|
|
|
|
|
|
|
|
g_last_clip_size));
|
|
|
|
|
|
|
|
make_stream(s);
|
|
|
|
|
|
|
|
init_stream(s, 64 + g_last_clip_size);
|
|
|
|
|
|
|
|
out_uint16_le(s, 5); /* CLIPRDR_DATA_RESPONSE */
|
|
|
|
|
|
|
|
out_uint16_le(s, 1); /* status */
|
|
|
|
|
|
|
|
out_uint32_le(s, g_last_clip_size); /* length */
|
|
|
|
|
|
|
|
/* insert image data */
|
|
|
|
|
|
|
|
if (g_last_clip_type == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* do not insert first header */
|
|
|
|
|
|
|
|
out_uint8p(s, g_last_clip_data + 14, g_last_clip_size - 14);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
out_uint16_le(s, 0); /* nil for string */
|
|
|
|
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
|
|
|
|
out_uint32_le(s, 0);
|
|
|
|
|
|
|
|
s_mark_end(s);
|
|
|
|
|
|
|
|
size = (int)(s->end - s->data);
|
|
|
|
|
|
|
|
/* HANGING HERE WHEN IMAGE DATA IS TOO BIG!!!! */
|
|
|
|
|
|
|
|
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
|
|
|
|
|
|
|
free_stream(s);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_send_data_response(void)
|
|
|
|
clipboard_send_data_response(void)
|
|
|
@ -397,6 +425,10 @@ clipboard_send_data_response(void)
|
|
|
|
num_chars = 0;
|
|
|
|
num_chars = 0;
|
|
|
|
if (g_last_clip_data != 0)
|
|
|
|
if (g_last_clip_data != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_last_clip_type == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return clipboard_send_data_response_for_image();
|
|
|
|
|
|
|
|
}
|
|
|
|
if ((g_last_clip_type == XA_STRING) || (g_last_clip_type == g_utf8_atom))
|
|
|
|
if ((g_last_clip_type == XA_STRING) || (g_last_clip_type == g_utf8_atom))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
num_chars = g_mbstowcs(0, g_last_clip_data, 0);
|
|
|
|
num_chars = g_mbstowcs(0, g_last_clip_data, 0);
|
|
|
@ -491,6 +523,9 @@ clipboard_refuse_selection(XSelectionRequestEvent* req)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* sent by client or server when its local system clipboard is
|
|
|
|
|
|
|
|
updated with new clipboard data; contains Clipboard Format ID
|
|
|
|
|
|
|
|
and name pairs of new Clipboard Formats on the clipboard. */
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_process_format_announce(struct stream* s, int clip_msg_status,
|
|
|
|
clipboard_process_format_announce(struct stream* s, int clip_msg_status,
|
|
|
|
int clip_msg_len)
|
|
|
|
int clip_msg_len)
|
|
|
@ -510,6 +545,8 @@ clipboard_process_format_announce(struct stream* s, int clip_msg_status,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* response to CB_FORMAT_LIST; used to indicate whether
|
|
|
|
|
|
|
|
processing of the Format List PDU was successful */
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_prcoess_format_ack(struct stream* s, int clip_msg_status,
|
|
|
|
clipboard_prcoess_format_ack(struct stream* s, int clip_msg_status,
|
|
|
|
int clip_msg_len)
|
|
|
|
int clip_msg_len)
|
|
|
@ -520,6 +557,8 @@ clipboard_prcoess_format_ack(struct stream* s, int clip_msg_status,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* sent by recipient of CB_FORMAT_LIST; used to request data for one
|
|
|
|
|
|
|
|
of the formats that was listed in CB_FORMAT_LIST */
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_process_data_request(struct stream* s, int clip_msg_status,
|
|
|
|
clipboard_process_data_request(struct stream* s, int clip_msg_status,
|
|
|
|
int clip_msg_len)
|
|
|
|
int clip_msg_len)
|
|
|
@ -531,6 +570,67 @@ clipboard_process_data_request(struct stream* s, int clip_msg_status,
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate whether
|
|
|
|
|
|
|
|
processing of the CB_FORMAT_DATA_REQUEST was successful; if processing
|
|
|
|
|
|
|
|
was successful, CB_FORMAT_DATA_RESPONSE includes contents of requested
|
|
|
|
|
|
|
|
clipboard data. */
|
|
|
|
|
|
|
|
static int APP_CC
|
|
|
|
|
|
|
|
clipboard_process_data_response_for_image(struct stream * s,
|
|
|
|
|
|
|
|
int clip_msg_status,
|
|
|
|
|
|
|
|
int clip_msg_len)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XSelectionRequestEvent* lxev = &g_saved_selection_req_event;
|
|
|
|
|
|
|
|
char* cptr;
|
|
|
|
|
|
|
|
char cdata;
|
|
|
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response_for_image: "
|
|
|
|
|
|
|
|
"CLIPRDR_DATA_RESPONSE_FOR_IMAGE"));
|
|
|
|
|
|
|
|
g_waiting_for_data_response = 0;
|
|
|
|
|
|
|
|
len = (int)(s->end - s->p);
|
|
|
|
|
|
|
|
if (len < 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_last_clip_type == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* space for inserting bmp image header */
|
|
|
|
|
|
|
|
len += 14;
|
|
|
|
|
|
|
|
cptr = (char*)g_malloc(len, 0);
|
|
|
|
|
|
|
|
if (cptr == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_memcpy(cptr, g_bmp_image_header, 14);
|
|
|
|
|
|
|
|
index = 14;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
while (s_check(s))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
in_uint8(s, cdata);
|
|
|
|
|
|
|
|
cptr[index++] = cdata;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len >= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_data_in = cptr;
|
|
|
|
|
|
|
|
g_data_in_size = len;
|
|
|
|
|
|
|
|
g_data_in_time = clipboard_get_local_time();
|
|
|
|
|
|
|
|
g_data_in_up_to_date = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clipboard_provide_selection(lxev, lxev->target, 8, cptr, len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate whether
|
|
|
|
|
|
|
|
processing of the CB_FORMAT_DATA_REQUEST was successful; if processing was
|
|
|
|
|
|
|
|
successful, CB_FORMAT_DATA_RESPONSE includes contents of requested
|
|
|
|
|
|
|
|
clipboard data. */
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
|
|
|
clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
|
|
@ -543,6 +643,12 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
|
|
|
int index;
|
|
|
|
int index;
|
|
|
|
int data_in_len;
|
|
|
|
int data_in_len;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (g_want_image_data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_want_image_data = 0;
|
|
|
|
|
|
|
|
clipboard_process_data_response_for_image(s, clip_msg_status, clip_msg_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_process_data_response: "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_process_data_response: "
|
|
|
|
"CLIPRDR_DATA_RESPONSE"));
|
|
|
|
"CLIPRDR_DATA_RESPONSE"));
|
|
|
|
g_waiting_for_data_response = 0;
|
|
|
|
g_waiting_for_data_response = 0;
|
|
|
@ -584,7 +690,7 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_data_in_size = len;
|
|
|
|
g_data_in_size = len;
|
|
|
|
g_wcstombs(g_data_in, wtext, len + 1);
|
|
|
|
g_wcstombs(g_data_in, wtext, len + 1);
|
|
|
|
g_data_in_time = clipboard_get_local_time();
|
|
|
|
g_data_in_time = xcommon_get_local_time();
|
|
|
|
g_data_in_up_to_date = 1;
|
|
|
|
g_data_in_up_to_date = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (g_data_in != 0)
|
|
|
|
if (g_data_in != 0)
|
|
|
@ -645,19 +751,31 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
|
|
|
rv = 0;
|
|
|
|
rv = 0;
|
|
|
|
switch (clip_msg_id)
|
|
|
|
switch (clip_msg_id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 2: /* CLIPRDR_FORMAT_ANNOUNCE */
|
|
|
|
/* sent by client or server when its local system clipboard is */
|
|
|
|
|
|
|
|
/* updated with new clipboard data; contains Clipboard Format ID */
|
|
|
|
|
|
|
|
/* and name pairs of new Clipboard Formats on the clipboard. */
|
|
|
|
|
|
|
|
case CB_FORMAT_LIST: /* CLIPRDR_FORMAT_ANNOUNCE */
|
|
|
|
rv = clipboard_process_format_announce(ls, clip_msg_status,
|
|
|
|
rv = clipboard_process_format_announce(ls, clip_msg_status,
|
|
|
|
clip_msg_len);
|
|
|
|
clip_msg_len);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3: /* CLIPRDR_FORMAT_ACK */
|
|
|
|
/* response to CB_FORMAT_LIST; used to indicate whether */
|
|
|
|
|
|
|
|
/* processing of the Format List PDU was successful */
|
|
|
|
|
|
|
|
case CB_FORMAT_LIST_RESPONSE: /* CLIPRDR_FORMAT_ACK */
|
|
|
|
rv = clipboard_prcoess_format_ack(ls, clip_msg_status,
|
|
|
|
rv = clipboard_prcoess_format_ack(ls, clip_msg_status,
|
|
|
|
clip_msg_len);
|
|
|
|
clip_msg_len);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 4: /* CLIPRDR_DATA_REQUEST */
|
|
|
|
/* sent by recipient of CB_FORMAT_LIST; used to request data for one */
|
|
|
|
|
|
|
|
/* of the formats that was listed in CB_FORMAT_LIST */
|
|
|
|
|
|
|
|
case CB_FORMAT_DATA_REQUEST: /* CLIPRDR_DATA_REQUEST */
|
|
|
|
rv = clipboard_process_data_request(ls, clip_msg_status,
|
|
|
|
rv = clipboard_process_data_request(ls, clip_msg_status,
|
|
|
|
clip_msg_len);
|
|
|
|
clip_msg_len);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 5: /* CLIPRDR_DATA_RESPONSE */
|
|
|
|
/* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate */
|
|
|
|
|
|
|
|
/* whether processing of the CB_FORMAT_DATA_REQUEST was */
|
|
|
|
|
|
|
|
/* successful; if processing was successful, */
|
|
|
|
|
|
|
|
/* CB_FORMAT_DATA_RESPONSE includes contents of requested */
|
|
|
|
|
|
|
|
/* clipboard data. */
|
|
|
|
|
|
|
|
case CB_FORMAT_DATA_RESPONSE: /* CLIPRDR_DATA_RESPONSE */
|
|
|
|
rv = clipboard_process_data_response(ls, clip_msg_status,
|
|
|
|
rv = clipboard_process_data_response(ls, clip_msg_status,
|
|
|
|
clip_msg_len);
|
|
|
|
clip_msg_len);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -673,7 +791,8 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* this happens when a new app copies something to the clipboard
|
|
|
|
/* this happens when a new app copies something to the clipboard
|
|
|
|
'CLIPBOARD' Atom
|
|
|
|
'CLIPBOARD' Atom
|
|
|
|
typedef struct {
|
|
|
|
typedef struct
|
|
|
|
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
int type;
|
|
|
|
unsigned long serial;
|
|
|
|
unsigned long serial;
|
|
|
|
Bool send_event;
|
|
|
|
Bool send_event;
|
|
|
@ -684,7 +803,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
|
|
|
Atom selection;
|
|
|
|
Atom selection;
|
|
|
|
Time timestamp;
|
|
|
|
Time timestamp;
|
|
|
|
Time selection_timestamp;
|
|
|
|
Time selection_timestamp;
|
|
|
|
} XFixesSelectionNotifyEvent; */
|
|
|
|
} XFixesSelectionNotifyEvent; */
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_event_selection_owner_notify(XEvent* xevent)
|
|
|
|
clipboard_event_selection_owner_notify(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -726,12 +845,28 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
|
|
|
XGetWindowProperty(g_display, g_wnd, prop, 0, 0, 0,
|
|
|
|
XGetWindowProperty(g_display, g_wnd, prop, 0, 0, 0,
|
|
|
|
AnyPropertyType, <ype, &lfmt, &ln_items,
|
|
|
|
AnyPropertyType, <ype, &lfmt, &ln_items,
|
|
|
|
&llen_after, &lxdata);
|
|
|
|
&llen_after, &lxdata);
|
|
|
|
|
|
|
|
if (lxdata != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
XFree(lxdata);
|
|
|
|
XFree(lxdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ltype == 0)
|
|
|
|
if (ltype == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* XGetWindowProperty failed */
|
|
|
|
/* XGetWindowProperty failed */
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ltype == g_incr_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_property_notify: INCR start"));
|
|
|
|
|
|
|
|
g_incr_in_progress = 1;
|
|
|
|
|
|
|
|
g_incr_atom_type = prop;
|
|
|
|
|
|
|
|
g_incr_data_size = 0;
|
|
|
|
|
|
|
|
g_free(g_incr_data);
|
|
|
|
|
|
|
|
g_incr_data = 0;
|
|
|
|
|
|
|
|
XDeleteProperty(g_display, g_wnd, prop);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (llen_after < 1)
|
|
|
|
if (llen_after < 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* no data, ok */
|
|
|
|
/* no data, ok */
|
|
|
@ -745,20 +880,29 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
|
|
|
if (ltype == 0)
|
|
|
|
if (ltype == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* XGetWindowProperty failed */
|
|
|
|
/* XGetWindowProperty failed */
|
|
|
|
|
|
|
|
if (lxdata != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
XFree(lxdata);
|
|
|
|
XFree(lxdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lxdata_size = (lfmt / 8) * ln_items;
|
|
|
|
lxdata_size = (lfmt / 8) * ln_items;
|
|
|
|
if (lxdata_size < 1)
|
|
|
|
if (lxdata_size < 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* should not happen */
|
|
|
|
/* should not happen */
|
|
|
|
|
|
|
|
if (lxdata != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
XFree(lxdata);
|
|
|
|
XFree(lxdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (llen_after > 0)
|
|
|
|
if (llen_after > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* should not happen */
|
|
|
|
/* should not happen */
|
|
|
|
|
|
|
|
if (lxdata != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
XFree(lxdata);
|
|
|
|
XFree(lxdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
return 3;
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (xdata != 0)
|
|
|
|
if (xdata != 0)
|
|
|
@ -766,7 +910,10 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
|
|
|
*xdata = (char*)g_malloc(lxdata_size, 0);
|
|
|
|
*xdata = (char*)g_malloc(lxdata_size, 0);
|
|
|
|
g_memcpy(*xdata, lxdata, lxdata_size);
|
|
|
|
g_memcpy(*xdata, lxdata, lxdata_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lxdata != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
XFree(lxdata);
|
|
|
|
XFree(lxdata);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (xdata_size != 0)
|
|
|
|
if (xdata_size != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*xdata_size = lxdata_size;
|
|
|
|
*xdata_size = lxdata_size;
|
|
|
@ -812,10 +959,13 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
int index;
|
|
|
|
int index;
|
|
|
|
int convert_to_string;
|
|
|
|
int convert_to_string;
|
|
|
|
int convert_to_utf8;
|
|
|
|
int convert_to_utf8;
|
|
|
|
|
|
|
|
int convert_to_bmp_image;
|
|
|
|
int send_format_announce;
|
|
|
|
int send_format_announce;
|
|
|
|
int atom;
|
|
|
|
int atom;
|
|
|
|
int* atoms;
|
|
|
|
Atom* atoms;
|
|
|
|
Atom type;
|
|
|
|
Atom type;
|
|
|
|
|
|
|
|
tui32 format_id;
|
|
|
|
|
|
|
|
char format_name[32];
|
|
|
|
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify:"));
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify:"));
|
|
|
|
data_size = 0;
|
|
|
|
data_size = 0;
|
|
|
@ -823,11 +973,14 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
fmt = 0;
|
|
|
|
fmt = 0;
|
|
|
|
convert_to_string = 0;
|
|
|
|
convert_to_string = 0;
|
|
|
|
convert_to_utf8 = 0;
|
|
|
|
convert_to_utf8 = 0;
|
|
|
|
|
|
|
|
convert_to_bmp_image = 0;
|
|
|
|
send_format_announce = 0;
|
|
|
|
send_format_announce = 0;
|
|
|
|
|
|
|
|
format_id = 0;
|
|
|
|
rv = 0;
|
|
|
|
rv = 0;
|
|
|
|
data = 0;
|
|
|
|
data = 0;
|
|
|
|
type = 0;
|
|
|
|
type = 0;
|
|
|
|
lxevent = (XSelectionEvent*)xevent;
|
|
|
|
lxevent = (XSelectionEvent*)xevent;
|
|
|
|
|
|
|
|
g_memset(format_name, 0, 32);
|
|
|
|
if (lxevent->property == None)
|
|
|
|
if (lxevent->property == None)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: clip could "
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: clip could "
|
|
|
@ -836,6 +989,13 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (rv == 0)
|
|
|
|
if (rv == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* we need this if the call below turns out to be a
|
|
|
|
|
|
|
|
clipboard INCR operation */
|
|
|
|
|
|
|
|
if (!g_incr_in_progress)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_incr_atom_target = lxevent->target;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
|
|
|
|
rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
|
|
|
|
&type, &fmt,
|
|
|
|
&type, &fmt,
|
|
|
|
&n_items, &data, &data_size);
|
|
|
|
&n_items, &data, &data_size);
|
|
|
@ -852,9 +1012,10 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (lxevent->target == g_targets_atom)
|
|
|
|
if (lxevent->target == g_targets_atom)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* on a 64 bit machine, actual_format_return of 32 implies long */
|
|
|
|
if ((type == XA_ATOM) && (fmt == 32))
|
|
|
|
if ((type == XA_ATOM) && (fmt == 32))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
atoms = (int*)data;
|
|
|
|
atoms = (Atom*)data;
|
|
|
|
for (index = 0; index < n_items; index++)
|
|
|
|
for (index = 0; index < n_items; index++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
atom = atoms[index];
|
|
|
|
atom = atoms[index];
|
|
|
@ -868,6 +1029,10 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
convert_to_string = 1;
|
|
|
|
convert_to_string = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (atom == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
convert_to_bmp_image = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -882,24 +1047,42 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: UTF8_STRING "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: UTF8_STRING "
|
|
|
|
"data_size %d", data_size));
|
|
|
|
"data_size %d", data_size));
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
|
|
|
|
g_last_clip_data = 0;
|
|
|
|
g_last_clip_size = data_size;
|
|
|
|
g_last_clip_size = data_size;
|
|
|
|
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
|
|
|
|
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
|
|
|
|
g_last_clip_type = g_utf8_atom;
|
|
|
|
g_last_clip_type = g_utf8_atom;
|
|
|
|
g_memcpy(g_last_clip_data, data, g_last_clip_size);
|
|
|
|
g_memcpy(g_last_clip_data, data, g_last_clip_size);
|
|
|
|
g_last_clip_data[g_last_clip_size] = 0;
|
|
|
|
g_last_clip_data[g_last_clip_size] = 0;
|
|
|
|
send_format_announce = 1;
|
|
|
|
send_format_announce = 1;
|
|
|
|
|
|
|
|
format_id = CB_FORMAT_UNICODETEXT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lxevent->target == XA_STRING)
|
|
|
|
else if (lxevent->target == XA_STRING)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: XA_STRING "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: XA_STRING "
|
|
|
|
"data_size %d", data_size));
|
|
|
|
"data_size %d", data_size));
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
|
|
|
|
g_last_clip_data = 0;
|
|
|
|
g_last_clip_size = data_size;
|
|
|
|
g_last_clip_size = data_size;
|
|
|
|
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
|
|
|
|
g_last_clip_data = g_malloc(g_last_clip_size + 1, 0);
|
|
|
|
g_last_clip_type = XA_STRING;
|
|
|
|
g_last_clip_type = XA_STRING;
|
|
|
|
g_memcpy(g_last_clip_data, data, g_last_clip_size);
|
|
|
|
g_memcpy(g_last_clip_data, data, g_last_clip_size);
|
|
|
|
g_last_clip_data[g_last_clip_size] = 0;
|
|
|
|
g_last_clip_data[g_last_clip_size] = 0;
|
|
|
|
send_format_announce = 1;
|
|
|
|
send_format_announce = 1;
|
|
|
|
|
|
|
|
format_id = CB_FORMAT_UNICODETEXT;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (lxevent->target == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: image/bmp "
|
|
|
|
|
|
|
|
"data_size %d", data_size));
|
|
|
|
|
|
|
|
g_free(g_last_clip_data);
|
|
|
|
|
|
|
|
g_last_clip_data = 0;
|
|
|
|
|
|
|
|
g_last_clip_size = data_size;
|
|
|
|
|
|
|
|
g_last_clip_data = g_malloc(data_size, 0);
|
|
|
|
|
|
|
|
g_last_clip_type = g_image_bmp_atom;
|
|
|
|
|
|
|
|
g_memcpy(g_last_clip_data, data, data_size);
|
|
|
|
|
|
|
|
send_format_announce = 1;
|
|
|
|
|
|
|
|
format_id = CB_FORMAT_DIB;
|
|
|
|
|
|
|
|
g_strcpy(format_name, "image/bmp");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -923,9 +1106,14 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
XConvertSelection(g_display, g_clipboard_atom, XA_STRING,
|
|
|
|
XConvertSelection(g_display, g_clipboard_atom, XA_STRING,
|
|
|
|
g_clip_property_atom, g_wnd, lxevent->time);
|
|
|
|
g_clip_property_atom, g_wnd, lxevent->time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (convert_to_bmp_image)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XConvertSelection(g_display, g_clipboard_atom, g_image_bmp_atom,
|
|
|
|
|
|
|
|
g_clip_property_atom, g_wnd, lxevent->time);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (send_format_announce)
|
|
|
|
if (send_format_announce)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (clipboard_send_format_announce() != 0)
|
|
|
|
if (clipboard_send_format_announce(format_id, format_name) != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rv = 4;
|
|
|
|
rv = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -949,12 +1137,17 @@ clipboard_event_selection_notify(XEvent* xevent)
|
|
|
|
Atom property;
|
|
|
|
Atom property;
|
|
|
|
Time time;
|
|
|
|
Time time;
|
|
|
|
} XSelectionRequestEvent; */
|
|
|
|
} XSelectionRequestEvent; */
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* When XGetWindowProperty and XChangeProperty talk about "format 32" it
|
|
|
|
|
|
|
|
* doesn't mean a 32bit value, but actually a long. So 32 means 4 bytes on
|
|
|
|
|
|
|
|
* a 32bit machine and 8 bytes on a 64 machine
|
|
|
|
|
|
|
|
*/
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_event_selection_request(XEvent* xevent)
|
|
|
|
clipboard_event_selection_request(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//XEvent xev;
|
|
|
|
|
|
|
|
XSelectionRequestEvent* lxev;
|
|
|
|
XSelectionRequestEvent* lxev;
|
|
|
|
tui32 ui32[8];
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
Atom atom_buf[10];
|
|
|
|
Atom type;
|
|
|
|
Atom type;
|
|
|
|
int fmt;
|
|
|
|
int fmt;
|
|
|
|
int n_items;
|
|
|
|
int n_items;
|
|
|
@ -977,27 +1170,27 @@ clipboard_event_selection_request(XEvent* xevent)
|
|
|
|
/* requestor is asking what the selection can be converted to */
|
|
|
|
/* requestor is asking what the selection can be converted to */
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
"g_targets_atom"));
|
|
|
|
"g_targets_atom"));
|
|
|
|
ui32[0] = g_targets_atom;
|
|
|
|
atom_buf[0] = g_targets_atom;
|
|
|
|
ui32[1] = g_timestamp_atom;
|
|
|
|
atom_buf[1] = g_timestamp_atom;
|
|
|
|
ui32[2] = g_multiple_atom;
|
|
|
|
atom_buf[2] = g_multiple_atom;
|
|
|
|
ui32[3] = XA_STRING;
|
|
|
|
atom_buf[3] = XA_STRING;
|
|
|
|
ui32[4] = g_utf8_atom;
|
|
|
|
atom_buf[4] = g_utf8_atom;
|
|
|
|
return clipboard_provide_selection(lxev, XA_ATOM, 32, (char*)ui32, 5);
|
|
|
|
atom_buf[5] = g_image_bmp_atom;
|
|
|
|
|
|
|
|
return clipboard_provide_selection(lxev, XA_ATOM, 32, (char*)atom_buf, 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lxev->target == g_timestamp_atom)
|
|
|
|
else if (lxev->target == g_timestamp_atom)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* requestor is asking the time I got the selection */
|
|
|
|
/* requestor is asking the time I got the selection */
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
"g_timestamp_atom"));
|
|
|
|
"g_timestamp_atom"));
|
|
|
|
ui32[0] = g_selection_time;
|
|
|
|
atom_buf[0] = g_selection_time;
|
|
|
|
return clipboard_provide_selection(lxev, XA_INTEGER, 32, (char*)ui32, 1);
|
|
|
|
return clipboard_provide_selection(lxev, XA_INTEGER, 32, (char*)atom_buf, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lxev->target == g_multiple_atom)
|
|
|
|
else if (lxev->target == g_multiple_atom)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* target, property pairs */
|
|
|
|
/* target, property pairs */
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
|
|
|
"g_multiple_atom"));
|
|
|
|
"g_multiple_atom"));
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
if (clipboard_get_window_property(xev.xselection.requestor,
|
|
|
|
if (clipboard_get_window_property(xev.xselection.requestor,
|
|
|
|
xev.xselection.property,
|
|
|
|
xev.xselection.property,
|
|
|
|
&type, &fmt, &n_items, &xdata,
|
|
|
|
&type, &fmt, &n_items, &xdata,
|
|
|
@ -1008,12 +1201,12 @@ clipboard_event_selection_request(XEvent* xevent)
|
|
|
|
/* todo */
|
|
|
|
/* todo */
|
|
|
|
g_free(xdata);
|
|
|
|
g_free(xdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom))
|
|
|
|
else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: %s",
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: %s",
|
|
|
|
XGetAtomName(g_display, lxev->target)));
|
|
|
|
XGetAtomName(g_display, lxev->target)));
|
|
|
|
|
|
|
|
clipboard_format_id = CB_FORMAT_UNICODETEXT;
|
|
|
|
if (g_data_in_up_to_date)
|
|
|
|
if (g_data_in_up_to_date)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return clipboard_provide_selection(lxev, lxev->target, 8,
|
|
|
|
return clipboard_provide_selection(lxev, lxev->target, 8,
|
|
|
@ -1032,12 +1225,24 @@ clipboard_event_selection_request(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
clipboard_send_data_request();
|
|
|
|
clipboard_send_data_request();
|
|
|
|
g_waiting_for_data_response = 1;
|
|
|
|
g_waiting_for_data_response = 1;
|
|
|
|
g_waiting_for_data_response_time = clipboard_get_local_time();
|
|
|
|
g_waiting_for_data_response_time = xcommon_get_local_time();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_selection_request_event_count++;
|
|
|
|
g_selection_request_event_count++;
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (lxev->target == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_memcpy(&g_saved_selection_req_event, lxev,
|
|
|
|
|
|
|
|
sizeof(g_saved_selection_req_event));
|
|
|
|
|
|
|
|
g_last_clip_type = g_image_bmp_atom;
|
|
|
|
|
|
|
|
g_want_image_data = 1;
|
|
|
|
|
|
|
|
clipboard_format_id = CB_FORMAT_DIB;
|
|
|
|
|
|
|
|
clipboard_send_data_request();
|
|
|
|
|
|
|
|
g_waiting_for_data_response = 1;
|
|
|
|
|
|
|
|
g_waiting_for_data_response_time = clipboard_get_local_time();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOGM((LOG_LEVEL_ERROR,"clipboard_event_selection_request: unknown "
|
|
|
|
LOGM((LOG_LEVEL_ERROR,"clipboard_event_selection_request: unknown "
|
|
|
@ -1081,92 +1286,132 @@ clipboard_event_selection_clear(XEvent* xevent)
|
|
|
|
static int APP_CC
|
|
|
|
static int APP_CC
|
|
|
|
clipboard_event_property_notify(XEvent* xevent)
|
|
|
|
clipboard_event_property_notify(XEvent* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Atom actual_type_return;
|
|
|
|
|
|
|
|
int actual_format_return;
|
|
|
|
|
|
|
|
unsigned long nitems_returned;
|
|
|
|
|
|
|
|
unsigned long bytes_left;
|
|
|
|
|
|
|
|
unsigned char* data;
|
|
|
|
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
int format_in_bytes;
|
|
|
|
|
|
|
|
int new_data_len;
|
|
|
|
|
|
|
|
char* cptr;
|
|
|
|
|
|
|
|
char format_name[32];
|
|
|
|
|
|
|
|
|
|
|
|
LOG(10, ("clipboard_check_wait_objs: PropertyNotify .window %d "
|
|
|
|
LOG(10, ("clipboard_check_wait_objs: PropertyNotify .window %d "
|
|
|
|
".state %d .atom %d", xevent->xproperty.window,
|
|
|
|
".state %d .atom %d", xevent->xproperty.window,
|
|
|
|
xevent->xproperty.state, xevent->xproperty.atom));
|
|
|
|
xevent->xproperty.state, xevent->xproperty.atom));
|
|
|
|
return 0;
|
|
|
|
if (g_incr_in_progress &&
|
|
|
|
}
|
|
|
|
(xevent->xproperty.atom == g_incr_atom_type) &&
|
|
|
|
|
|
|
|
(xevent->xproperty.state == PropertyNewValue))
|
|
|
|
/*****************************************************************************/
|
|
|
|
{
|
|
|
|
/* returns error
|
|
|
|
rv = XGetWindowProperty(g_display, g_wnd, g_incr_atom_type, 0, 0, 0,
|
|
|
|
this is called to get any wait objects for the main loop
|
|
|
|
AnyPropertyType, &actual_type_return, &actual_format_return,
|
|
|
|
timeout can be nil */
|
|
|
|
&nitems_returned, &bytes_left, (unsigned char **) &data);
|
|
|
|
int APP_CC
|
|
|
|
if (data != 0)
|
|
|
|
clipboard_get_wait_objs(tbus* objs, int* count, int* timeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFree(data);
|
|
|
|
int lcount;
|
|
|
|
data = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bytes_left <= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_property_notify: INCR done"));
|
|
|
|
|
|
|
|
g_memset(format_name, 0, 32);
|
|
|
|
|
|
|
|
/* clipboard INCR cycle has completed */
|
|
|
|
|
|
|
|
g_incr_in_progress = 0;
|
|
|
|
|
|
|
|
g_last_clip_size = g_incr_data_size;
|
|
|
|
|
|
|
|
g_last_clip_data = g_incr_data;
|
|
|
|
|
|
|
|
g_incr_data = 0;
|
|
|
|
|
|
|
|
g_last_clip_type = g_incr_atom_target;
|
|
|
|
|
|
|
|
if (g_incr_atom_target == g_image_bmp_atom)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_snprintf(format_name, 31, "image/bmp");
|
|
|
|
|
|
|
|
clipboard_send_format_announce(CB_FORMAT_DIB, format_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rv = XGetWindowProperty(g_display, g_wnd, g_incr_atom_type, 0, bytes_left, 0,
|
|
|
|
|
|
|
|
AnyPropertyType, &actual_type_return, &actual_format_return,
|
|
|
|
|
|
|
|
&nitems_returned, &bytes_left, (unsigned char **) &data);
|
|
|
|
|
|
|
|
|
|
|
|
if ((!g_clip_up) || (objs == 0) || (count == 0))
|
|
|
|
format_in_bytes = actual_format_return / 8;
|
|
|
|
|
|
|
|
if ((actual_format_return == 32) && (sizeof(long) == 8))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* on a 64 bit machine, actual_format_return of 32 implies long */
|
|
|
|
|
|
|
|
format_in_bytes = 8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
new_data_len = nitems_returned * format_in_bytes;
|
|
|
|
|
|
|
|
cptr = (char*)g_malloc(g_incr_data_size + new_data_len, 0);
|
|
|
|
|
|
|
|
g_memcpy(cptr, g_incr_data, g_incr_data_size);
|
|
|
|
|
|
|
|
g_free(g_incr_data);
|
|
|
|
|
|
|
|
if (cptr == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_incr_data = 0;
|
|
|
|
|
|
|
|
/* cannot add any more data */
|
|
|
|
|
|
|
|
if (data != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
XFree(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lcount = *count;
|
|
|
|
g_incr_data = cptr;
|
|
|
|
objs[lcount] = g_x_wait_obj;
|
|
|
|
g_memcpy(g_incr_data + g_incr_data_size, data, new_data_len);
|
|
|
|
lcount++;
|
|
|
|
g_incr_data_size += new_data_len;
|
|
|
|
*count = lcount;
|
|
|
|
if (data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XFree(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/* returns 0, event handled, 1 unhandled */
|
|
|
|
int APP_CC
|
|
|
|
int APP_CC
|
|
|
|
clipboard_check_wait_objs(void)
|
|
|
|
clipboard_xevent(void* xevent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XEvent xevent;
|
|
|
|
XEvent* lxevent;
|
|
|
|
int time_diff;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!g_clip_up)
|
|
|
|
if (!g_clip_up)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_is_wait_obj_set(g_x_wait_obj))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (XPending(g_display) < 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* something is wrong, should not get here */
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_check_wait_objs: sck closed"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_waiting_for_data_response)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
time_diff = clipboard_get_local_time() -
|
|
|
|
|
|
|
|
g_waiting_for_data_response_time;
|
|
|
|
|
|
|
|
if (time_diff > 1000)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_check_wait_objs: warning, "
|
|
|
|
|
|
|
|
"waiting for data response too long"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (XPending(g_display) > 0)
|
|
|
|
lxevent = (XEvent*)xevent;
|
|
|
|
{
|
|
|
|
switch (lxevent->type)
|
|
|
|
XNextEvent(g_display, &xevent);
|
|
|
|
|
|
|
|
switch (xevent.type)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case SelectionNotify:
|
|
|
|
case SelectionNotify:
|
|
|
|
clipboard_event_selection_notify(&xevent);
|
|
|
|
clipboard_event_selection_notify(lxevent);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SelectionRequest:
|
|
|
|
case SelectionRequest:
|
|
|
|
clipboard_event_selection_request(&xevent);
|
|
|
|
clipboard_event_selection_request(lxevent);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case SelectionClear:
|
|
|
|
case SelectionClear:
|
|
|
|
clipboard_event_selection_clear(&xevent);
|
|
|
|
clipboard_event_selection_clear(lxevent);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case MappingNotify:
|
|
|
|
case MappingNotify:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case PropertyNotify:
|
|
|
|
case PropertyNotify:
|
|
|
|
clipboard_event_property_notify(&xevent);
|
|
|
|
clipboard_event_property_notify(lxevent);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UnmapNotify:
|
|
|
|
|
|
|
|
LOG(0, ("chansrv::clipboard_xevent: got UnmapNotify"));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ClientMessage:
|
|
|
|
|
|
|
|
LOG(0, ("chansrv::clipboard_xevent: got ClientMessage"));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if (xevent.type == g_xfixes_event_base +
|
|
|
|
if (lxevent->type == g_xfixes_event_base +
|
|
|
|
XFixesSetSelectionOwnerNotify)
|
|
|
|
XFixesSetSelectionOwnerNotify)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
clipboard_event_selection_owner_notify(&xevent);
|
|
|
|
clipboard_event_selection_owner_notify(lxevent);
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGM((LOG_LEVEL_ERROR, "clipboard_check_wait_objs unknown type %d",
|
|
|
|
|
|
|
|
xevent.type));
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* we didn't handle this message */
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|