]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/lyx_gui.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / lyx_gui.C
index f6438ed86d47a43fb1186111125fa4526bdc30b5..c64afc720fded4539e31c216dcbcb76a349c8883 100644 (file)
@@ -1,14 +1,20 @@
 /**
- * \file lyx_gui.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * \file qt2/lyx_gui.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author unknown
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/filetools.h"
@@ -16,9 +22,6 @@
 #include "debug.h"
 #include "gettext.h"
 
-#include <fcntl.h>
-#include <boost/bind.hpp>
-
 #include "lyx_gui.h"
 #include "lyx_main.h"
 #include "lyxrc.h"
@@ -35,6 +38,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/function/function0.hpp>
 #include <boost/signals/signal1.hpp>
+#include <boost/bind.hpp>
 
 #include "QtView.h"
 #include "QLImage.h"
 #include "io_callback.h"
 
 #include <qapplication.h>
+#include <qwidget.h>
+#include <qpaintdevicemetrics.h>
+
+#include <fcntl.h>
 
 #ifndef CXX_GLOBAL_CSTD
 using std::exit;
@@ -54,16 +62,46 @@ using std::endl;
 extern BufferList bufferlist;
 
 namespace {
-       /// good ol' "easy to use" Qt again
-       float getDPI() { return 95; }
-};
+
+float getDPI()
+{
+       QWidget w;
+       QPaintDeviceMetrics pdm(&w);
+       return 0.5 * (pdm.logicalDpiX() + pdm.logicalDpiY());
+}
+
+map<int, io_callback *> io_callbacks;
+
+} // namespace anon
+
+
 // FIXME: wrong place !
 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[])
 {
-       static QApplication a(argc, argv);
+       static LQApplication a(argc, argv);
 
        using namespace grfx;
 
@@ -80,7 +118,7 @@ void lyx_gui::parse_lyxrc()
 }
 
 
-void lyx_gui::start(string const & batch, vector<string> files)
+void lyx_gui::start(string const & batch, vector<string> const & files)
 {
        // initial geometry
        int xpos = -1;
@@ -154,12 +192,7 @@ bool lyx_gui::font_available(LyXFont const & font)
        return fontloader.available(font);
 }
 
-namespace {
-       map<int, io_callback *> io_callbacks;
-}
 
 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
 {
        io_callbacks[fd] = new io_callback(fd, comm);