mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-20 06:49:56 +00:00
Fix X selection code.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5600 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a23766d245
commit
6d7115bb60
@ -1,3 +1,8 @@
|
|||||||
|
2002-11-08 Dekel Tsur <dekelts@tau.ac.il>
|
||||||
|
|
||||||
|
* lyx_gui.C:
|
||||||
|
* QWorkArea.C: Fix X selection code.
|
||||||
|
|
||||||
2002-11-07 John Levon <levon@movementarian.org>
|
2002-11-07 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
* ui/QIncludeDialog.ui:
|
* ui/QIncludeDialog.ui:
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qclipboard.h>
|
#include <qclipboard.h>
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
@ -79,15 +83,52 @@ void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
|
|||||||
scrollbar_->setPageStep(height());
|
scrollbar_->setPageStep(height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QWorkArea const * wa_ptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void QWorkArea::haveSelection(bool) const
|
#ifdef Q_WS_X11
|
||||||
|
bool lyxX11EventFilter(XEvent * xev)
|
||||||
{
|
{
|
||||||
// not possible in Qt !
|
switch (xev->type) {
|
||||||
|
case SelectionRequest:
|
||||||
|
lyxerr[Debug::GUI] << "X requested selection." << endl;
|
||||||
|
if (wa_ptr)
|
||||||
|
wa_ptr->selectionRequested();
|
||||||
|
break;
|
||||||
|
case SelectionClear:
|
||||||
|
lyxerr[Debug::GUI] << "Lost selection." << endl;
|
||||||
|
if (wa_ptr)
|
||||||
|
wa_ptr->selectionLost();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void QWorkArea::haveSelection(bool own) const
|
||||||
|
{
|
||||||
|
wa_ptr = this;
|
||||||
|
|
||||||
|
#if QT_VERSION >= 300
|
||||||
|
if (!QApplication::clipboard()->supportsSelection())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (own) {
|
||||||
|
QApplication::clipboard()->setSelectionMode(true);
|
||||||
|
QApplication::clipboard()->setText(QString());
|
||||||
|
}
|
||||||
|
// We don't need to do anything if own = false, as this case is
|
||||||
|
// handled by QT.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const QWorkArea::getClipboard() const
|
string const QWorkArea::getClipboard() const
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= 300
|
||||||
|
QApplication::clipboard()->setSelectionMode(true);
|
||||||
|
#endif
|
||||||
QString str = QApplication::clipboard()->text();
|
QString str = QApplication::clipboard()->text();
|
||||||
if (str.isNull())
|
if (str.isNull())
|
||||||
return string();
|
return string();
|
||||||
@ -97,5 +138,8 @@ string const QWorkArea::getClipboard() const
|
|||||||
|
|
||||||
void QWorkArea::putClipboard(string const & str) const
|
void QWorkArea::putClipboard(string const & str) const
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= 300
|
||||||
|
QApplication::clipboard()->setSelectionMode(true);
|
||||||
|
#endif
|
||||||
QApplication::clipboard()->setText(str.c_str());
|
QApplication::clipboard()->setText(str.c_str());
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,30 @@ map<int, io_callback *> io_callbacks;
|
|||||||
// FIXME: wrong place !
|
// FIXME: wrong place !
|
||||||
LyXServer * lyxserver;
|
LyXServer * lyxserver;
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
extern bool lyxX11EventFilter(XEvent * xev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class LQApplication : public QApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LQApplication(int &argc, char **argv);
|
||||||
|
~LQApplication();
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); }
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
LQApplication::LQApplication(int &argc, char **argv)
|
||||||
|
: QApplication( argc, argv )
|
||||||
|
{}
|
||||||
|
|
||||||
|
LQApplication::~LQApplication()
|
||||||
|
{}
|
||||||
|
|
||||||
void lyx_gui::parse_init(int & argc, char * argv[])
|
void lyx_gui::parse_init(int & argc, char * argv[])
|
||||||
{
|
{
|
||||||
static QApplication a(argc, argv);
|
static LQApplication a(argc, argv);
|
||||||
|
|
||||||
using namespace grfx;
|
using namespace grfx;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user