Commit f0b38977 authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Carlos Garnacho

clibpoard: Drop clipboard manager

This responsibility was taken over by mutter, where it can be made to work
both on Wayland and X11. This clipboard manager implementation becomes
superfluous then.
parent c5853978
Pipeline #99855 passed with stages
in 3 minutes and 50 seconds
This diff is collapsed.
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
*
* 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __GSD_CLIPBOARD_MANAGER_H
#define __GSD_CLIPBOARD_MANAGER_H
#include <glib-object.h>
G_BEGIN_DECLS
#define GSD_TYPE_CLIPBOARD_MANAGER (gsd_clipboard_manager_get_type ())
G_DECLARE_FINAL_TYPE (GsdClipboardManager, gsd_clipboard_manager, GSD, CLIPBOARD_MANAGER, GObject)
GsdClipboardManager * gsd_clipboard_manager_new (void);
gboolean gsd_clipboard_manager_start (GsdClipboardManager *manager,
GError **error);
void gsd_clipboard_manager_stop (GsdClipboardManager *manager);
G_END_DECLS
#endif /* __GSD_CLIPBOARD_MANAGER_H */
/*
* Copyright © 2004 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Matthias Clasen, Red Hat, Inc.
*/
#include <stdlib.h>
#include <list.h>
void
list_foreach (List *list,
Callback func,
void *user_data)
{
while (list)
{
func (list->data, user_data);
list = list->next;
}
}
List *
list_prepend (List *list,
void *data)
{
List *link;
link = (List *) malloc (sizeof (List));
link->next = list;
link->data = data;
return link;
}
void
list_free (List *list)
{
while (list)
{
List *next = list->next;
free (list);
list = next;
}
}
List *
list_find (List *list,
ListFindFunc func,
void *user_data)
{
List *tmp;
for (tmp = list; tmp; tmp = tmp->next)
{
if ((*func) (tmp->data, user_data))
break;
}
return tmp;
}
List *
list_remove (List *list,
void *data)
{
List *tmp, *prev;
prev = NULL;
for (tmp = list; tmp; tmp = tmp->next)
{
if (tmp->data == data)
{
if (prev)
prev->next = tmp->next;
else
list = tmp->next;
free (tmp);
break;
}
prev = tmp;
}
return list;
}
int
list_length (List *list)
{
List *tmp;
int length;
length = 0;
for (tmp = list; tmp; tmp = tmp->next)
length++;
return length;
}
List *
list_copy (List *list)
{
List *new_list = NULL;
if (list)
{
List *last;
new_list = (List *) malloc (sizeof (List));
new_list->data = list->data;
new_list->next = NULL;
last = new_list;
list = list->next;
while (list)
{
last->next = (List *) malloc (sizeof (List));
last = last->next;
last->data = list->data;
list = list->next;
}
last->next = NULL;
}
return new_list;
}
/*
* Copyright © 2004 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Matthias Clasen, Red Hat, Inc.
*/
#ifndef LIST_H
#define LIST_H
typedef struct _List List;
typedef void (*Callback) (void *data,
void *user_data);
struct _List
{
void *data;
List *next;
};
typedef int (*ListFindFunc) (void *data,
void *user_data);
void list_foreach (List *list,
Callback func,
void *user_data);
List *list_prepend (List *list,
void *data);
void list_free (List *list);
List *list_find (List *list,
ListFindFunc func,
void *user_data);
List *list_remove (List *list,
void *data);
int list_length (List *list);
List *list_copy (List *list);
#endif /* LIST_H */
#define NEW gsd_clipboard_manager_new
#define START gsd_clipboard_manager_start
#define STOP gsd_clipboard_manager_stop
#define MANAGER GsdClipboardManager
#define GDK_BACKEND "x11"
#include "gsd-clipboard-manager.h"
#include "daemon-skeleton-gtk.h"
sources = files(
'gsd-clipboard-manager.c',
'list.c',
'main.c',
'xutils.c'
)
deps = plugins_deps + [
gtk_x11_dep,
x11_dep
]
executable(
'gsd-' + plugin_name,
sources,
include_directories: [top_inc, common_inc],
dependencies: deps,
c_args: cflags,
install: true,
install_rpath: gsd_pkglibdir,
install_dir: gsd_libexecdir
)
[Desktop Entry]
Type=Application
Name=GNOME Settings Daemon's clipboard plugin
Exec=@libexecdir@/gsd-clipboard
OnlyShowIn=GNOME;
NoDisplay=true
X-GNOME-Autostart-Phase=Initialization
X-GNOME-Autostart-Notify=true
X-GNOME-AutoRestart=true
/*
* Copyright © 2004 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Matthias Clasen, Red Hat, Inc.
*/
#include <stdlib.h>
#include "xutils.h"
Atom XA_ATOM_PAIR;
Atom XA_CLIPBOARD_MANAGER;
Atom XA_CLIPBOARD;
Atom XA_DELETE;
Atom XA_INCR;
Atom XA_INSERT_PROPERTY;
Atom XA_INSERT_SELECTION;
Atom XA_MANAGER;
Atom XA_MULTIPLE;
Atom XA_NULL;
Atom XA_SAVE_TARGETS;
Atom XA_TARGETS;
Atom XA_TIMESTAMP;
unsigned long SELECTION_MAX_SIZE = 0;
void
init_atoms (Display *display)
{
unsigned long max_request_size;
if (SELECTION_MAX_SIZE > 0)
return;
XA_ATOM_PAIR = XInternAtom (display, "ATOM_PAIR", False);
XA_CLIPBOARD_MANAGER = XInternAtom (display, "CLIPBOARD_MANAGER", False);
XA_CLIPBOARD = XInternAtom (display, "CLIPBOARD", False);
XA_DELETE = XInternAtom (display, "DELETE", False);
XA_INCR = XInternAtom (display, "INCR", False);
XA_INSERT_PROPERTY = XInternAtom (display, "INSERT_PROPERTY", False);
XA_INSERT_SELECTION = XInternAtom (display, "INSERT_SELECTION", False);
XA_MANAGER = XInternAtom (display, "MANAGER", False);
XA_MULTIPLE = XInternAtom (display, "MULTIPLE", False);
XA_NULL = XInternAtom (display, "NULL", False);
XA_SAVE_TARGETS = XInternAtom (display, "SAVE_TARGETS", False);
XA_TARGETS = XInternAtom (display, "TARGETS", False);
XA_TIMESTAMP = XInternAtom (display, "TIMESTAMP", False);
max_request_size = XExtendedMaxRequestSize (display);
if (max_request_size == 0)
max_request_size = XMaxRequestSize (display);
SELECTION_MAX_SIZE = max_request_size - 100;
if (SELECTION_MAX_SIZE > 262144)
SELECTION_MAX_SIZE = 262144;
}
typedef struct
{
Window window;
Atom timestamp_prop_atom;
} TimeStampInfo;
static Bool
timestamp_predicate (Display *display,
XEvent *xevent,
XPointer arg)
{
TimeStampInfo *info = (TimeStampInfo *)arg;
if (xevent->type == PropertyNotify &&
xevent->xproperty.window == info->window &&
xevent->xproperty.atom == info->timestamp_prop_atom)
return True;
return False;
}
Time
get_server_time (Display *display,
Window window)
{
unsigned char c = 'a';
XEvent xevent;
TimeStampInfo info;
info.timestamp_prop_atom = XInternAtom (display, "_TIMESTAMP_PROP", False);
info.window = window;
XChangeProperty (display, window,
info.timestamp_prop_atom, info.timestamp_prop_atom,
8, PropModeReplace, &c, 1);
XIfEvent (display, &xevent,
timestamp_predicate, (XPointer)&info);
return xevent.xproperty.time;
}
/*
* Copyright © 2004 Red Hat, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Red Hat not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. Red Hat makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Matthias Clasen, Red Hat, Inc.
*/
#ifndef X_UTILS_H
#define X_UTILS_H
#include <X11/Xlib.h>
extern Atom XA_ATOM_PAIR;
extern Atom XA_CLIPBOARD_MANAGER;
extern Atom XA_CLIPBOARD;
extern Atom XA_DELETE;
extern Atom XA_INCR;
extern Atom XA_INSERT_PROPERTY;
extern Atom XA_INSERT_SELECTION;
extern Atom XA_MANAGER;
extern Atom XA_MULTIPLE;
extern Atom XA_NULL;
extern Atom XA_SAVE_TARGETS;
extern Atom XA_TARGETS;
extern Atom XA_TIMESTAMP;
extern unsigned long SELECTION_MAX_SIZE;
void init_atoms (Display *display);
Time get_server_time (Display *display,
Window window);
#endif /* X_UTILS_H */
enabled_plugins = [
['a11y-settings', 'A11ySettings'],
['clipboard', 'Clipboard'],
['color', 'Color'],
['datetime', 'Datetime'],
['dummy', ''],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment