From 5f40493c84bb3ba0633c95199aa1359771621fe7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 8 Apr 2020 13:36:33 +0200 Subject: [PATCH] core: Add private function to get the current selection owner This is a bit untidy to expose, however may be necessary internally. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186 (cherry picked from commit fbd6366eddf39704fb79be608dd22cb3fad328e6) --- src/core/meta-selection-private.h | 32 +++++++++++++++++++++++++++++++ src/core/meta-selection.c | 11 +++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/core/meta-selection-private.h diff --git a/src/core/meta-selection-private.h b/src/core/meta-selection-private.h new file mode 100644 index 000000000..de9caf9bf --- /dev/null +++ b/src/core/meta-selection-private.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 Red Hat + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by: + * Carlos Garnacho + */ + +#ifndef META_SELECTION_PRIVATE_H +#define META_SELECTION_PRIVATE_H + +#include "meta/meta-selection.h" + +MetaSelectionSource * + meta_selection_get_current_owner (MetaSelection *selection, + MetaSelectionType selection_type); + +#endif /* META_SELECTION_PRIVATE_H */ diff --git a/src/core/meta-selection.c b/src/core/meta-selection.c index 1029782fc..4e42e59a9 100644 --- a/src/core/meta-selection.c +++ b/src/core/meta-selection.c @@ -21,6 +21,7 @@ #include "config.h" +#include "core/meta-selection-private.h" #include "meta/meta-selection.h" typedef struct TransferRequest TransferRequest; @@ -402,3 +403,13 @@ meta_selection_transfer_finish (MetaSelection *selection, return g_task_propagate_boolean (G_TASK (result), error); } + +MetaSelectionSource * +meta_selection_get_current_owner (MetaSelection *selection, + MetaSelectionType selection_type) +{ + g_return_val_if_fail (META_IS_SELECTION (selection), NULL); + g_return_val_if_fail (selection_type < META_N_SELECTION_TYPES, NULL); + + return selection->owners[selection_type]; +}