1
/***************************************************************************
2
* Copyright (C) 2012~2012 by Yichao Yu *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#include "fcitx/fcitx.h"
23
#include "clipboard-internal.h"
24
#include "fcitx/module.h"
25
#include "module/x11/fcitx-x11.h"
28
_X11ClipboardPrimaryConvertCb(
29
void *owner, const char *sel_str, const char *tgt_str, int format,
30
size_t nitems, const void *buff, void *data)
32
FCITX_UNUSED(sel_str);
33
FCITX_UNUSED(tgt_str);
35
FcitxClipboard *clipboard = owner;
38
ClipboardSetPrimary(clipboard, nitems, buff);
42
_X11ClipboardPrimaryNotifyCb(void *owner, const char *sel_str,
43
int subtype, void *data)
45
FCITX_UNUSED(sel_str);
46
FCITX_UNUSED(subtype);
48
FcitxClipboard *clipboard = owner;
49
FcitxX11RequestConvertSelect(clipboard->owner, "PRIMARY", NULL,
50
clipboard, _X11ClipboardPrimaryConvertCb,
55
_X11ClipboardClipboardConvertCb(
56
void *owner, const char *sel_str, const char *tgt_str, int format,
57
size_t nitems, const void *buff, void *data)
59
FCITX_UNUSED(sel_str);
60
FCITX_UNUSED(tgt_str);
62
FcitxClipboard *clipboard = owner;
65
ClipboardPushClipboard(clipboard, nitems, buff);
69
_X11ClipboardClipboardNotifyCb(void *owner, const char *sel_str,
70
int subtype, void *data)
72
FCITX_UNUSED(sel_str);
73
FCITX_UNUSED(subtype);
75
FcitxClipboard *clipboard = owner;
76
FcitxX11RequestConvertSelect(clipboard->owner, "CLIPBOARD", NULL,
77
clipboard, _X11ClipboardClipboardConvertCb,
82
ClipboardInitX11(FcitxClipboard *clipboard)
84
FcitxInstance *instance = clipboard->owner;
85
clipboard->x11 = FcitxX11GetAddon(instance);
88
clipboard->x11_primary_notify_id = FcitxX11RegSelectNotify(
89
instance, "PRIMARY", clipboard,
90
_X11ClipboardPrimaryNotifyCb, NULL, NULL);
91
clipboard->x11_clipboard_notify_id = FcitxX11RegSelectNotify(
92
instance, "CLIPBOARD", clipboard,
93
_X11ClipboardClipboardNotifyCb, NULL, NULL);
94
FcitxX11RequestConvertSelect(clipboard->owner, "PRIMARY", NULL,
95
clipboard, _X11ClipboardPrimaryConvertCb,
97
FcitxX11RequestConvertSelect(clipboard->owner, "CLIPBOARD", NULL,
98
clipboard, _X11ClipboardClipboardConvertCb,