wxMaxima
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
test_PrimarySelectionPaste.cpp File Reference

GH #794: a middle-click pastes the primary selection, not the Ctrl+C clipboard. More...

#include <wx/app.h>
#include <wx/bitmap.h>
#include <wx/clipbrd.h>
#include <wx/dataobj.h>
#include <wx/dcmemory.h>
#include <wx/frame.h>
#include <wx/image.h>
#include <wx/log.h>
#include "Configuration.h"
#include "worksheet/Worksheet.h"
#include "cells/EditorCell.h"
#include "cells/GroupCell.h"
#include <catch2/catch.hpp>
Include dependency graph for test_PrimarySelectionPaste.cpp:

Data Structures

class  TestApp
 

Functions

 SCENARIO ("An ordinary paste into a cell still inserts the Ctrl+C clipboard")
 
 SCENARIO ("A paste into a cell scrolled out of view brings it back into view")
 
 SCENARIO ("Copied cells keep their text formatting when pasted (GH #2474)")
 
 wxDECLARE_APP (TestApp)
 
int main (int argc, char **argv)
 

Detailed Description

GH #794: a middle-click pastes the primary selection, not the Ctrl+C clipboard.

X11 has two clipboards: the ordinary one (Ctrl+C / Ctrl+V) and the primary selection, which holds whatever was last selected and is pasted by a middle-click. Worksheet::OnMouseMiddleUp() switched wxTheClipboard to the primary selection, but Worksheet::PasteFromClipboard() then handed the paste to EditorCell::PasteFromClipboard() without saying which clipboard it was for - and that function's default switched back to the ordinary clipboard. So a middle-click into a cell pasted the Ctrl+C contents, while a middle-click between cells (which never reaches the cell) worked. Anyone testing with both clipboards holding the same text could not see it.

GH #2474: copied cells keep their text formatting, which only the XML flavour carries, when they are pasted.

This test uses the real clipboard, so it needs a display (CI runs it under xvfb). Windows and macOS have no primary selection, so there only the ordinary paste is checked. wxWidgets can't be asked whether there is one: on MSW UsePrimarySelection(true) is accepted, IsUsingPrimarySelection() answers true, and the clipboard then silently stays empty. An earlier version of this test asked it anyway and turned the minGW job red; it now goes by Worksheet::HasPrimarySelection().