On Wed, Dec 08, 2010 at 10:05:32PM +0100, Vincent van Ravesteijn wrote: > This has the clue! > > case LFUN_PASTE: { > > // without argument? > string const arg = to_utf8(cmd.argument()); > if (arg.empty()) { > if (theClipboard().isInternal()) > pasteFromStack(cur, ... , 0); > else if (theClipboard().hasGraphicsContents() > && !theClipboard().hasTextContents()) > pasteClipboardGraphics(cur, ... ); > else > pasteClipboardText(cur, ...); > } > > For Windows and Linux, theClipboard().isInternal () returns true, > while for Mac it doesn't.
Good catch! > The following comment seems to be wrong: > > bool GuiClipboard::isInternal() const > { > // ownsClipboard() is also true for stuff coming from dialogs, e.g. > // the preamble dialog > // FIXME: This does only work on X11, since ownsClipboard() is > // hardwired to return false on Windows and OS X. > return qApp->clipboard()->ownsClipboard() && hasLyXContents(); > } Indeed. Looking at the Qt sources: src/gui/kernel/qclipboard.cpp: ------------------------------ bool QClipboard::ownsClipboard() const { return ownsMode(Clipboard); } src/gui/kernel/qclipboard_win.cpp: ---------------------------------- bool QClipboard::ownsMode(Mode mode) const { if (mode == Clipboard) { QClipboardData *d = clipboardData(); #if !defined(Q_OS_WINCE) return d->iData && OleIsCurrentClipboard(d->iData) == S_OK; #else return d->iData && GetClipboardOwner() == d->clipBoardViewer->internalWinId(); #endif } else { return false; } } src/gui/kernel/qclipboard_x11.cpp: ---------------------------------- bool QClipboard::ownsMode(Mode mode) const { if (mode == Clipboard) return clipboardData()->timestamp != CurrentTime; else if(mode == Selection) return selectionData()->timestamp != CurrentTime; else return false; } BUT: src/gui/kernel/qclipboard_mac.cpp: ---------------------------------- bool QClipboard::ownsMode(Mode mode) const { Q_UNUSED(mode); return false; } So, perhaps the attached patch is right. -- Enrico
Index: src/frontends/qt4/GuiClipboard.cpp =================================================================== --- src/frontends/qt4/GuiClipboard.cpp (revisione 36774) +++ src/frontends/qt4/GuiClipboard.cpp (copia locale) @@ -416,18 +416,18 @@ bool GuiClipboard::isInternal() const { // ownsClipboard() is also true for stuff coming from dialogs, e.g. // the preamble dialog - // FIXME: This does only work on X11, since ownsClipboard() is - // hardwired to return false on Windows and OS X. - return qApp->clipboard()->ownsClipboard() && hasLyXContents(); + // On OS X we only check for hasLyXContents(), since ownsClipboard() + // is hardwired to return false. + return (qApp->clipboard()->ownsClipboard() || !hasInternal()) && hasLyXContents(); } bool GuiClipboard::hasInternal() const { - // Windows and Mac OS X does not have the concept of ownership; + // Mac OS X does not have the concept of ownership; // the clipboard is a fully global resource so all applications // are notified of changes. -#if (defined(Q_WS_X11)) +#if (defined(Q_WS_X11) || defined(Q_WS_WIN)) return true; #else return false;