From 1e5da933a4ef2c5de8ca711215918e9f3ff9df3e Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 6 May 2025 23:46:26 +0200 Subject: Copy links to clipboard selection too Selecting text in the page copies only to the primary selection. Copying links via the context menu now places the URL both in the primary and clipboard selections so it can also be pasted with Ctrl+V. See: https://github.com/dillo-browser/dillo/issues/228 --- dw/fltkplatform.cc | 5 +++-- dw/fltkplatform.hh | 22 +++++++++++++++++++++- dw/layout.hh | 24 ++++++++++++++++++++++-- dw/platform.hh | 22 +++++++++++++++++++++- dw/selection.cc | 3 ++- 5 files changed, 69 insertions(+), 7 deletions(-) (limited to 'dw') diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 21c0866a..5551a80c 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken + * Copyright 2025 Rodrigo Arias Mallo * * 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 @@ -700,9 +701,9 @@ core::style::Tooltip *FltkPlatform::createTooltip (const char *text) return FltkTooltip::create (text); } -void FltkPlatform::copySelection(const char *text) +void FltkPlatform::copySelection(const char *text, int destination) { - Fl::copy(text, strlen(text), 0); + Fl::copy(text, strlen(text), destination); } core::Imgbuf *FltkPlatform::createImgbuf (core::Imgbuf::Type type, diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 60dca7f2..f1b68b0a 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2007 Sebastian Geerken + * Copyright 2025 Rodrigo Arias Mallo + * + * 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 3 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 . + */ + #ifndef __DW_FLTKPLATFORM_HH__ #define __DW_FLTKPLATFORM_HH__ @@ -174,7 +194,7 @@ public: core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height, double gamma); - void copySelection(const char *text); + void copySelection(const char *text, int destination); core::ui::ResourceFactory *getResourceFactory (); diff --git a/dw/layout.hh b/dw/layout.hh index 08360e19..36f433b5 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2007 Sebastian Geerken + * Copyright 2025 Rodrigo Arias Mallo + * + * 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 3 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 . + */ + #ifndef __DW_LAYOUT_HH__ #define __DW_LAYOUT_HH__ @@ -413,9 +433,9 @@ public: return platform->createImgbuf (type, width, height, gamma); } - inline void copySelection(const char *text) + inline void copySelection(const char *text, int destination) { - platform->copySelection(text); + platform->copySelection(text, destination); } inline ui::ResourceFactory *getResourceFactory () diff --git a/dw/platform.hh b/dw/platform.hh index 5270098b..9d90c9df 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2013 Sebastian Geerken + * Copyright 2025 Rodrigo Arias Mallo + * + * 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 3 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 . + */ + #ifndef __DW_PLATFORM_HH__ #define __DW_PLATFORM_HH__ @@ -158,7 +178,7 @@ public: /** * \brief Copy selected text (0-terminated). */ - virtual void copySelection(const char *text) = 0; + virtual void copySelection(const char *text, int destination) = 0; /** * ... diff --git a/dw/selection.cc b/dw/selection.cc index a69eb82a..899fad69 100644 --- a/dw/selection.cc +++ b/dw/selection.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken + * Copyright 2025 Rodrigo Arias Mallo * * 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 @@ -494,7 +495,7 @@ void SelectionState::copy() delete i; } - layout->copySelection(strbuf.getChars()); + layout->copySelection(strbuf.getChars(), 0); } } -- cgit v1.2.3