texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Qt-TeXmacs: Pile of patches


From: Joris van der Hoeven
Subject: Re: [Texmacs-dev] Qt-TeXmacs: Pile of patches
Date: Sun, 14 Jun 2009 05:58:17 +0200
User-agent: Mutt/1.5.9i

Hi Norbert,

I will let Max handle these patches.

Best wishes, Joris


On Thu, Jun 11, 2009 at 07:21:54AM +0100, Norbert Nemec wrote:
> Hi Massimiliano, hi everybody,
> 
> attached is a pile of patches to the Qt GUI. The Qt event-loop is now 
> used properly, properly hooking in the repaint and update mechanisms via 
> timers. As far as I can see, it covers everything that the X11 GUI and 
> the former hacked up Qt-solution did. It has been working smoothly for 
> me over the past few weeks, solves a few quirks and uses far less CPU 
> time when idle. (<0.1% compared to the former 3% on my machine).
> 
> The other changes fix a number of issues that I encountered, most 
> notably the keymap. Please make sure that these changes also apply to 
> MacOSX, where everything seems to be somewhat different to my Linux machine.
> 
> Greetings,
> Norbert

> remove trailing spaces and expand tabs
> 
> From:  <>
> 
> 
> ---
> 
>  src/plugins/asymptote/bin/perl-tm_asy |    0 
>  src/src/Plugins/Qt/qt_gui.cpp         |    9 ++++-----
>  src/src/Plugins/Qt/qt_widget.cpp      |   16 ++++++++--------
>  3 files changed, 12 insertions(+), 13 deletions(-)
>  mode change 100644 => 100755 src/plugins/asymptote/bin/perl-tm_asy
> 
> 
> diff --git a/src/plugins/asymptote/bin/perl-tm_asy 
> b/src/plugins/asymptote/bin/perl-tm_asy
> old mode 100644
> new mode 100755
> diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/qt_gui.cpp
> index 8ce92ea..3f34f32 100755
> --- a/src/src/Plugins/Qt/qt_gui.cpp
> +++ b/src/src/Plugins/Qt/qt_gui.cpp
> @@ -57,7 +57,7 @@ void
>  qt_gui_rep::get_extents (SI& width, SI& height) {
>    QDesktopWidget* d= QApplication::desktop();
>    int w = d->width();  // returns desktop width
> -  int h = d->height(); // returns desktop height        
> +  int h = d->height(); // returns desktop height
>    width = ((SI) w) * PIXEL;
>    height= ((SI) h) * PIXEL;
>  }
> @@ -109,11 +109,11 @@ qt_gui_rep::set_selection (string key, tree t, string 
> s) {
>      //XSetSelectionOwner (dpy, XA_PRIMARY, win, CurrentTime);
>      //if (XGetSelectionOwner(dpy, XA_PRIMARY)==None) return false;
>      selection= as_charp (s);
> -        
> +
>      QClipboard *clipboard = QApplication::clipboard();
>      QString originalText = clipboard->text();
> -                
> -    clipboard->setText(selection);      
> +
> +    clipboard->setText(selection);
>    }
>    return true;
>  }
> @@ -390,4 +390,3 @@ font x_font (string family, int size, int dpi)
>    if (DEBUG_EVENTS) cout << "x_font(): SHOULD NOT BE CALLED\n";
>    return NULL;
>  }
> -
> diff --git a/src/src/Plugins/Qt/qt_widget.cpp 
> b/src/src/Plugins/Qt/qt_widget.cpp
> index 0e80d4b..0637efd 100755
> --- a/src/src/Plugins/Qt/qt_widget.cpp
> +++ b/src/src/Plugins/Qt/qt_widget.cpp
> @@ -154,7 +154,7 @@ qt_view_widget_rep::send (slot s, blackbox val) {
>      cout << "qt_view_widget_rep::send " << slot_name (s) << LF;
>    switch (s) {
>    case SLOT_NAME:
> -    {   
> +    {
>        check_type<string> (val, "SLOT_NAME");
>        string name = open_box<string> (val);
>        view->window() -> setWindowTitle (to_qstring (name));
> @@ -190,7 +190,7 @@ qt_view_widget_rep::send (slot s, blackbox val) {
>      if (open_box<bool> (val)) the_keyboard_focus = this;
>        if (DEBUG_EVENTS) cout << "Ignored!\n";
>      break;
> -                        
> +
>    default:
>      FAILED ("unhandled slot type");
>    }
> @@ -279,7 +279,7 @@ qt_view_widget_rep::read (slot s, blackbox index) {
>            return (widget_rep*) (v.value<void*> ());
>          else FAILED ("QWidget property not set");
>        }
> -      break; // not reached     
> +      break; // not reached
>      default:
>        FAILED ("cannot handle slot type");
>        return widget();
> @@ -553,7 +553,7 @@ qt_tm_widget_rep::query (slot s, int type_id) {
>        if (DEBUG_EVENTS) cout << "Visible Region " << rect << LF;
>        return close_box<coord4> (c);
>      }
> -                        
> +
>    case SLOT_USER_ICONS_VISIBILITY:
>      TYPE_CHECK (type_id == type_helper<bool>::id);
>      return close_box<bool> (visibility[3]);
> @@ -643,7 +643,7 @@ qt_tm_widget_rep::write (slot s, blackbox index, widget 
> w) {
>        check_type_void (index, "SLOT_CANVAS");
>        QWidget* qw= ((qt_view_widget_rep*) w.rep)->view;
>        QWidget* old_canvas= tm_scrollarea()->takeWidget();
> -      tm_scrollarea()->setWidget (qw);                  
> +      tm_scrollarea()->setWidget (qw);
>        (void) old_canvas;
>        // old_canvas will be deleted when the corresponding 
> qt_view_widget_rep is destroyed
>        qw->setFocusPolicy (Qt::StrongFocus);
> @@ -673,7 +673,7 @@ qt_tm_widget_rep::write (slot s, blackbox index, widget 
> w) {
>  
>    case SLOT_CONTEXT_ICONS:
>      check_type_void (index, "SLOT_CONTEXT_ICONS");
> -    {   
> +    {
>        QMenu* m= to_qmenu (w);
>        replaceButtons (contextToolBar, m);
>        delete m;
> @@ -682,7 +682,7 @@ qt_tm_widget_rep::write (slot s, blackbox index, widget 
> w) {
>  
>    case SLOT_USER_ICONS:
>      check_type_void (index, "SLOT_USER_ICONS");
> -    {   
> +    {
>        QMenu* m= to_qmenu (w);
>        replaceButtons (userToolBar, m);
>        delete m;
> @@ -769,7 +769,7 @@ qt_window_widget_rep::send (slot s, blackbox val) {
>      break;
>  
>    case SLOT_NAME:
> -    {   
> +    {
>        check_type<string> (val, "SLOT_NAME");
>        string name = open_box<string> (val);
>        if (wid) wid->setWindowTitle (to_qstring (name));

> Qt: Make sure closeEvent of windows is handled only through the TeXmacs 
> engine.
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/QTMWindow.cpp |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMWindow.cpp 
> b/src/src/Plugins/Qt/QTMWindow.cpp
> index 42d79ca..1904022 100644
> --- a/src/src/Plugins/Qt/QTMWindow.cpp
> +++ b/src/src/Plugins/Qt/QTMWindow.cpp
> @@ -20,8 +20,11 @@ void QTMWindow::closeEvent ( QCloseEvent *event )
>    if (DEBUG_EVENTS)   cout << "CLOSE WINDOW" << LF;
>    qt_tm_widget_rep *wid = tm_widget ();
>    if (wid) {
> +    // pass the close request on to TeXmacs and ignore
> +    // the direct handling
>      wid -> quit ();
> +    event -> ignore();
>    }
> -  QMainWindow::closeEvent (event);
> +//  QMainWindow::closeEvent (event);
>  }
>  

> Set SH_MenuBar_AltKeyNavigation to false. Typically this would be the job of 
> the style that is selected.
> 
> From:  <>
> 
> However: That mechanism seems to be broken with some Qt versions. 
> Furthermore, the Alt key is heavily
> used within TeXmacs, so the menubar navigation gets in the way quite often.
> ---
> 
>  src/src/Plugins/Qt/QTMStyle.cpp  |   10 ++++++++++
>  src/src/Plugins/Qt/QTMStyle.hpp  |    1 +
>  src/src/Plugins/Qt/qt_widget.cpp |    2 ++
>  3 files changed, 13 insertions(+), 0 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMStyle.cpp b/src/src/Plugins/Qt/QTMStyle.cpp
> index cd92b03..0e5a6de 100644
> --- a/src/src/Plugins/Qt/QTMStyle.cpp
> +++ b/src/src/Plugins/Qt/QTMStyle.cpp
> @@ -174,6 +174,16 @@ QTMStyle::drawControl (ControlElement element, const 
> QStyleOption* option, QPain
>  }
>  #endif
>  
> +int
> +QTMStyle::styleHint (StyleHint hint, const QStyleOption* option, const 
> QWidget* widget, QStyleHintReturn* returnData) const {
> +  switch (hint) {
> +  case SH_MenuBar_AltKeyNavigation:
> +    return 0;
> +  default:
> +    return style->styleHint (hint, option, widget, returnData);
> +  }
> +}
> +
>  QTMStyle*
>  qtmstyle () {
>    static QTMStyle* qtmstyle= NULL;
> diff --git a/src/src/Plugins/Qt/QTMStyle.hpp b/src/src/Plugins/Qt/QTMStyle.hpp
> index 76aa010..612311c 100644
> --- a/src/src/Plugins/Qt/QTMStyle.hpp
> +++ b/src/src/Plugins/Qt/QTMStyle.hpp
> @@ -60,6 +60,7 @@ public:
>    void drawPrimitive (PrimitiveElement element, const QStyleOption *option, 
> QPainter *painter, const QWidget *widget) const;
>    int pixelMetric (PixelMetric metric, const QStyleOption *opt, const 
> QWidget *widget) const;
>    // void drawControl (ControlElement element, const QStyleOption* option, 
> QPainter* painter, const QWidget* widget = 0)  const;
> +  int styleHint (StyleHint hint, const QStyleOption* option = 0, const 
> QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
>  };
>  
>  QTMStyle* qtmstyle ();
> diff --git a/src/src/Plugins/Qt/qt_widget.cpp 
> b/src/src/Plugins/Qt/qt_widget.cpp
> index 0637efd..8f9df2b 100755
> --- a/src/src/Plugins/Qt/qt_widget.cpp
> +++ b/src/src/Plugins/Qt/qt_widget.cpp
> @@ -321,6 +321,8 @@ qt_tm_widget_rep::qt_tm_widget_rep(int mask, command 
> _quit):
>  
>  
>    QMainWindow* mw= tm_mainwindow ();
> +  mw->setStyle (qtmstyle ());
> +  mw->menuBar()->setStyle (qtmstyle ());
>  
>    QScrollArea* sa= new QScrollArea (mw);
>    sa->setBackgroundRole (QPalette::Dark);

> Prevent qt to pass on plain modifier key-events (like "C-", "Mod1-" etc) to 
> be passed on to TeXmacs.
> 
> From:  <>
> 
> This used to cause "stuck" Alt keypresses to modify the next keypress, even 
> though the Alt key had
> been released afterwards.
> ---
> 
>  src/src/Plugins/Qt/QTMWidget.cpp |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMWidget.cpp 
> b/src/src/Plugins/Qt/QTMWidget.cpp
> index 7dc2cfc..b0e72ff 100644
> --- a/src/src/Plugins/Qt/QTMWidget.cpp
> +++ b/src/src/Plugins/Qt/QTMWidget.cpp
> @@ -309,6 +309,8 @@ QTMWidget::keyPressEvent (QKeyEvent* event) {
>        }
>      }
>  
> +    if (r == "") return;
> +
>  #ifdef Q_WS_MAC
>      if (mods & Qt::MetaModifier) r= "C-" * r;
>      if (mods & Qt::ControlModifier) r= "Mod1-" * r;
> @@ -321,7 +323,6 @@ QTMWidget::keyPressEvent (QKeyEvent* event) {
>      if (mods & Qt::MetaModifier) r= "Mod4-" * r;
>  #endif
>  
> -    if (r == "") return;
>      if (DEBUG_EVENTS)
>        cout << "key press: " << r << LF;
>      //int start= texmacs_time ();

> Fix handling of deadkeys in qt keymap
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/QTMWidget.cpp |   44 
> ++++++++++++++++++++++++++------------
>  1 files changed, 30 insertions(+), 14 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMWidget.cpp 
> b/src/src/Plugins/Qt/QTMWidget.cpp
> index b0e72ff..792595a 100644
> --- a/src/src/Plugins/Qt/QTMWidget.cpp
> +++ b/src/src/Plugins/Qt/QTMWidget.cpp
> @@ -41,6 +41,7 @@ extern int time_credit;
>  extern int timeout_time;
>  
>  hashmap<int,string> qtkeymap (0);
> +hashmap<int,string> qtdeadmap (0);
>  
>  inline void
>  scale (QPoint& point) {
> @@ -51,6 +52,10 @@ inline void
>  map (int code, string name) {
>    qtkeymap(code) = name;
>  }
> +inline void
> +deadmap (int code, string name) {
> +  qtdeadmap(code) = name;
> +}
>  
>  void
>  initkeymap () {
> @@ -116,11 +121,11 @@ initkeymap () {
>    map (Qt::Key_Execute   , "execute" );
>    map (Qt::Key_Help      , "help" );
>  
> -  map (Qt::Key_Dead_Acute     , "acute");
> -  map (Qt::Key_Dead_Grave     , "grave");
> -  map (Qt::Key_Dead_Diaeresis , "umlaut");
> -  map (Qt::Key_Dead_Circumflex, "hat");
> -  map (Qt::Key_Dead_Tilde     , "tilde");
> +  deadmap (Qt::Key_Dead_Acute     , "acute");
> +  deadmap (Qt::Key_Dead_Grave     , "grave");
> +  deadmap (Qt::Key_Dead_Diaeresis , "umlaut");
> +  deadmap (Qt::Key_Dead_Circumflex, "hat");
> +  deadmap (Qt::Key_Dead_Tilde     , "tilde");
>  
>    // map (0x0003              , "K-enter");
>    // map (Qt::Key_Begin       , "begin" );
> @@ -281,6 +286,8 @@ QTMWidget::keyPressEvent (QKeyEvent* event) {
>      if (qtkeymap->contains (key)) {
>        r = qtkeymap[key];
>        if (mods & Qt::ShiftModifier) r= "S-" * r;
> +    } else if (qtdeadmap->contains (key)) {
> +      r = qtdeadmap[key];
>      }
>      else {
>        QByteArray buf= nss.toUtf8();
> @@ -296,17 +303,26 @@ QTMWidget::keyPressEvent (QKeyEvent* event) {
>              key= (int) (key + ((int) 'a') - ((int) 'A'));
>          r= string ((char) key);
>        }
> +
>        else {
> -        if (unic == 168) r= "umlaut";
> -        if (unic == 96) {
> -          if ((mods & Qt::AltModifier) != 0) r= "grave";
> -          else r= "`";
> -        }
> -        if (unic == 180) r= "acute";
> -        if (unic == 710) r= "hat";
> -        if (unic == 732) r= "tilde";
>          flag= false;
> +     switch(unic) {
> +     case 168:  r= "umlaut"; break;
> +     case 96:   if ((mods & Qt::AltModifier) != 0) r= "grave";
> +                   else r= "`";
> +                break;
> +     case 180:  r= "acute"; break;
> +     // the following combining characters should be caught by qtdeadmap
> +     // case 0x300: r= "grave";
> +     // case 0x301: r= "acute";
> +     // case 0x302: r= "hat";
> +     // case 0x308: r= "umlaut";
> +     // case 0x33e: r= "tilde";
> +     default:
> +         flag= true;
> +        }
>        }
> +
>      }
>  
>      if (r == "") return;
> @@ -318,7 +334,7 @@ QTMWidget::keyPressEvent (QKeyEvent* event) {
>      if (flag && ((mods & Qt::AltModifier) != 0)) r= "Mod4-" * r;
>  #else
>      if (mods & Qt::ControlModifier) r= "C-" * r;
> -    if (mods & Qt::AltModifier) r= "Mod1-" * r;
> +    if (flag && ((mods & Qt::AltModifier) != 0)) r= "Mod1-" * r;
>      //if (mods & Qt::KeypadModifier) r= "Mod3-" * r;
>      if (mods & Qt::MetaModifier) r= "Mod4-" * r;
>  #endif

> Attempt to use Qt event loop
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_gui.cpp |   24 +++++++++++++++---------
>  src/src/Plugins/Qt/qt_gui.hpp |    2 ++
>  2 files changed, 17 insertions(+), 9 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/qt_gui.cpp
> index 3f34f32..c0ad8f9 100755
> --- a/src/src/Plugins/Qt/qt_gui.cpp
> +++ b/src/src/Plugins/Qt/qt_gui.cpp
> @@ -49,6 +49,8 @@ qt_gui_rep::qt_gui_rep(int &argc, char **argv):
>    interrupted   = false;
>    interrupt_time= texmacs_time ();
>    set_output_language (get_locale_language ());
> +  gui_helper = new QTMGuiHelper(this);
> +  qApp -> installEventFilter (gui_helper);
>  //  (void) default_font ();
>  }
>  
> @@ -70,6 +72,7 @@ qt_gui_rep::get_max_size (SI& width, SI& height) {
>  
>  
>  qt_gui_rep::~qt_gui_rep()  {
> +  delete gui_helper;
>  }
>  
>  
> /******************************************************************************
> @@ -187,6 +190,14 @@ qt_gui_rep::update () {
>  void
>  qt_gui_rep::event_loop () {
>    QApplication *app = (QApplication*) QApplication::instance();
> +
> +  QTimer *timer = new QTimer( gui_helper );
> +  QObject::connect( timer, SIGNAL(timeout()), gui_helper, SLOT(doUpdate()) );
> +  timer->start(0); // 0 ms - call immediately when all other events have 
> been processed
> +
> +  app->exec();
> +  delete timer;
> +/*
>    QTimer t (NULL);
>    t.start (25);
>  
> @@ -203,24 +214,19 @@ qt_gui_rep::event_loop () {
>    }
>    //FIXME: QCoreApplication sends aboutToQuit signal before exiting...
>    app->sendPostedEvents (0, QEvent::DeferredDelete);
> +*/
>  }
>  
>  
> /******************************************************************************
>  * Main routines
>  
> ******************************************************************************/
>  
> -QTMGuiHelper *gui_helper;
> -
>  
>  void
>  gui_open (int& argc, char** argv) {
>    // start the gui
>   // new QApplication (argc,argv); now in texmacs.cpp
>    the_gui = tm_new<qt_gui_rep> (argc, argv);
> -  
> -  gui_helper = new QTMGuiHelper (the_gui);
> -  qApp -> installEventFilter (gui_helper);
> -  
>  }
>  
>  void
> @@ -272,7 +278,7 @@ QTMGuiHelper::eventFilter (QObject *obj, QEvent *event) {
>       const char *s = openEvent->file().toAscii().constData();
>       qDebug ("File Open Event %s", s);
>       call ("texmacs-load-buffer", object(url_system (s)), object("generic"), 
> object(1), object(false));
> -     
> +
>       return true;
>     } else {
>       // standard event processing
> @@ -295,9 +301,9 @@ set_default_font (string name) {
>  
>  font
>  get_default_font (bool tt) {
> -        (void) tt;      
> +        (void) tt;
>    // get the default font or monospaced font (if tt is true)
> -        
> +
>    // return a null font since this function is not called in the Qt port.
>    if (DEBUG_EVENTS) cout << "get_default_font(): SHOULD NOT BE CALLED\n";
>    return NULL;
> diff --git a/src/src/Plugins/Qt/qt_gui.hpp b/src/src/Plugins/Qt/qt_gui.hpp
> index 284339f..e7fd1d0 100755
> --- a/src/src/Plugins/Qt/qt_gui.hpp
> +++ b/src/src/Plugins/Qt/qt_gui.hpp
> @@ -27,6 +27,7 @@
>  * The qt_gui class
>  
> ******************************************************************************/
>  
> +class QTMGuiHelper;
>  typedef class qt_gui_rep* qt_gui;
>  extern qt_gui the_gui;
>  
> @@ -35,6 +36,7 @@ public:
>    bool interrupted;
>    time_t interrupt_time;
>  
> +  QTMGuiHelper *gui_helper;
>  
>    char*                  selection;
>    hashmap<string,tree>   selection_t;

> Various changes
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_gui.cpp |   14 ++++++++------
>  src/src/Plugins/Qt/qt_gui.hpp |    1 +
>  2 files changed, 9 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/qt_gui.cpp
> index c0ad8f9..3e77db6 100755
> --- a/src/src/Plugins/Qt/qt_gui.cpp
> +++ b/src/src/Plugins/Qt/qt_gui.cpp
> @@ -31,7 +31,7 @@ extern window (*get_current_window) (void);
>  
>  qt_gui_rep* the_gui= NULL;
>  int nr_windows = 0; // FIXME: fake variable, referenced in tm_server
> -bool qt_update_flag= false;
> +bool qt_update_flag = false;
>  
>  int time_credit;
>  int timeout_time;
> @@ -51,6 +51,9 @@ qt_gui_rep::qt_gui_rep(int &argc, char **argv):
>    set_output_language (get_locale_language ());
>    gui_helper = new QTMGuiHelper(this);
>    qApp -> installEventFilter (gui_helper);
> +  updatetimer = new QTimer( gui_helper );
> +  updatetimer->setSingleShot(true);
> +  QObject::connect( updatetimer, SIGNAL(timeout()), gui_helper, 
> SLOT(doUpdate()) );
>  //  (void) default_font ();
>  }
>  
> @@ -73,6 +76,7 @@ qt_gui_rep::get_max_size (SI& width, SI& height) {
>  
>  qt_gui_rep::~qt_gui_rep()  {
>    delete gui_helper;
> +  delete updatetimer;
>  }
>  
>  
> /******************************************************************************
> @@ -191,12 +195,9 @@ void
>  qt_gui_rep::event_loop () {
>    QApplication *app = (QApplication*) QApplication::instance();
>  
> -  QTimer *timer = new QTimer( gui_helper );
> -  QObject::connect( timer, SIGNAL(timeout()), gui_helper, SLOT(doUpdate()) );
> -  timer->start(0); // 0 ms - call immediately when all other events have 
> been processed
> +  updatetimer->start(); // 0 ms - call immediately when all other events 
> have been processed
>  
>    app->exec();
> -  delete timer;
>  /*
>    QTimer t (NULL);
>    t.start (25);
> @@ -358,7 +359,8 @@ beep () {
>  
>  void
>  needs_update () {
> -  qt_update_flag= true;
> +  qt_update_flag = true;
> +  the_gui->updatetimer->start();
>  }
>  
>  bool
> diff --git a/src/src/Plugins/Qt/qt_gui.hpp b/src/src/Plugins/Qt/qt_gui.hpp
> index e7fd1d0..fa4de0b 100755
> --- a/src/src/Plugins/Qt/qt_gui.hpp
> +++ b/src/src/Plugins/Qt/qt_gui.hpp
> @@ -37,6 +37,7 @@ public:
>    time_t interrupt_time;
>  
>    QTMGuiHelper *gui_helper;
> +  QTimer *updatetimer;
>  
>    char*                  selection;
>    hashmap<string,tree>   selection_t;

> Call needs_update after issuing commands
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/QTMMenuHelper.hpp |    3 ++-
>  src/src/Plugins/Qt/QTMWindow.cpp     |    2 ++
>  2 files changed, 4 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMMenuHelper.hpp 
> b/src/src/Plugins/Qt/QTMMenuHelper.hpp
> index 3369c1d..f3f1f95 100644
> --- a/src/src/Plugins/Qt/QTMMenuHelper.hpp
> +++ b/src/src/Plugins/Qt/QTMMenuHelper.hpp
> @@ -12,6 +12,7 @@
>  #ifndef QTMMENUHELPER_HPP
>  #define QTMMENUHELPER_HPP
>  
> +#include "gui.hpp"
>  #include "message.hpp"
>  #include "promise.hpp"
>  #include <QObject>
> @@ -28,7 +29,7 @@ public:
>  
>  public slots:
>    inline void apply() {
> -    if (!is_nil(cmd)) cmd->apply(); }
> +    if (!is_nil(cmd)) cmd->apply(); needs_update(); }
>  };
>  
>  class QTMLazyMenu: public QMenu {
> diff --git a/src/src/Plugins/Qt/QTMWindow.cpp 
> b/src/src/Plugins/Qt/QTMWindow.cpp
> index 1904022..adfa3c9 100644
> --- a/src/src/Plugins/Qt/QTMWindow.cpp
> +++ b/src/src/Plugins/Qt/QTMWindow.cpp
> @@ -12,6 +12,7 @@
>  #include <QtGui>
>  
>  #include "QTMWindow.hpp"
> +#include "gui.hpp"
>  
>  #include <QEvent>
>  
> @@ -23,6 +24,7 @@ void QTMWindow::closeEvent ( QCloseEvent *event )
>      // pass the close request on to TeXmacs and ignore
>      // the direct handling
>      wid -> quit ();
> +    needs_update();
>      event -> ignore();
>    }
>  //  QMainWindow::closeEvent (event);

> Repeatedly call updatetimer every 500ms
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_gui.cpp |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/qt_gui.cpp
> index 3e77db6..f2a99d5 100755
> --- a/src/src/Plugins/Qt/qt_gui.cpp
> +++ b/src/src/Plugins/Qt/qt_gui.cpp
> @@ -195,7 +195,7 @@ void
>  qt_gui_rep::event_loop () {
>    QApplication *app = (QApplication*) QApplication::instance();
>  
> -  updatetimer->start(); // 0 ms - call immediately when all other events 
> have been processed
> +  updatetimer->start(0); // 0 ms - call immediately when all other events 
> have been processed
>  
>    app->exec();
>  /*
> @@ -270,6 +270,10 @@ gui_refresh () {
>  void
>  QTMGuiHelper::doUpdate() {
>    gui->update();
> +  int interval = gui->updatetimer->interval() + 5;
> +  if(interval > 1000) interval = 1000;
> +  if(qt_update_flag) interval = 0;
> +  gui->updatetimer->start(interval);
>  }
>  
>  bool
> @@ -360,7 +364,7 @@ beep () {
>  void
>  needs_update () {
>    qt_update_flag = true;
> -  the_gui->updatetimer->start();
> +  the_gui->updatetimer->start(0);
>  }
>  
>  bool

> Fix the call to postponedUpdate for the new event loop
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/QTMWidget.cpp |   23 +++++++++++------------
>  1 files changed, 11 insertions(+), 12 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/QTMWidget.cpp 
> b/src/src/Plugins/Qt/QTMWidget.cpp
> index 792595a..1fee52f 100644
> --- a/src/src/Plugins/Qt/QTMWidget.cpp
> +++ b/src/src/Plugins/Qt/QTMWidget.cpp
> @@ -150,6 +150,14 @@ initkeymap () {
>  
>  void
>  QTMWidget::postponedUpdate () {
> +#ifdef Q_WS_MAC
> +  //FIXME: the call to update(rect) is ignored sometimes (usually in long 
> documents).
> +  //       It is a confirmed Qt/Mac bug (#251792). See
> +  //       
> http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=251792
> +  //       This is a workaround for the update(rect) bug. Mac specific.
> +  update();
> +  delayed_rects= list<QRect>();
> +#else
>    while (!is_nil (delayed_rects)) {
>      QRect rect = delayed_rects->item;
>      if (DEBUG_EVENTS) {
> @@ -158,23 +166,15 @@ QTMWidget::postponedUpdate () {
>        << "," <<  rect.width()
>        << "," <<  rect.height() << ")\n" ;
>      }
> -    //FIXME: the call below to update is ignored sometimes (usually in long 
> documents).
> -    //       It is a confirmed Qt/Mac bug (#251792). See
> -    //       
> http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=251792
> -#ifdef Q_WS_MAC
> -    //FIXME: This is a workaround for the update(rect) bug. Mac specific.
> -    update();
> -#else
>      update (rect);
> -#endif
>      delayed_rects= delayed_rects->next;
>    }
> +#endif
>  }
>  
>  void
>  QTMWidget::paintEvent (QPaintEvent* event) {
>    QRect rect = event->rect ();
> -  bool partial_redraw = false;
>  
>    if (DEBUG_EVENTS) {
>      QPainter p(this);
> @@ -229,7 +229,6 @@ QTMWidget::paintEvent (QPaintEvent* event) {
>        if (DEBUG_EVENTS)
>          cout << "Interrupted\n";
>        qt_update_flag= true;
> -      partial_redraw = true;
>      }
>  
>      r->end();
> @@ -238,12 +237,12 @@ QTMWidget::paintEvent (QPaintEvent* event) {
>      //int end= texmacs_time ();
>      //if (end > start) cout << "Repaint " << end - start << "\n";
>    }
> -  if (partial_redraw) 
> +  if (qt_update_flag)
>    {
>      if (DEBUG_EVENTS)
>        cout << "Postponed redrawing\n";
>      delayed_rects= list<QRect> (rect, delayed_rects);
> -    QTimer::singleShot (1, this, SLOT (postponedUpdate ()));
> +    QTimer::singleShot (0, this, SLOT (postponedUpdate ()));
>    }
>  }
>  

> Correct handling of QClipboard
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_gui.cpp |   61 
> +++++++++++++++++++++++++----------------
>  1 files changed, 37 insertions(+), 24 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_gui.cpp b/src/src/Plugins/Qt/qt_gui.cpp
> index f2a99d5..ddfb497 100755
> --- a/src/src/Plugins/Qt/qt_gui.cpp
> +++ b/src/src/Plugins/Qt/qt_gui.cpp
> @@ -85,17 +85,30 @@ qt_gui_rep::~qt_gui_rep()  {
>  
>  bool
>  qt_gui_rep::get_selection (string key, tree& t, string& s) {
> -  t= "none";
> +  QClipboard *cb= QApplication::clipboard();
> +  bool owns= true;
> +  QClipboard::Mode mode;
> +  if (key == "primary") {
> +    owns= cb->ownsClipboard();
> +    mode= QClipboard::Clipboard;
> +  } else if (key == "mouse" && cb->supportsSelection()) {
> +    owns= cb->ownsSelection();
> +    mode= QClipboard::Selection;
> +  }
> +
>    s= "";
> -  if (selection_t->contains (key)) {
> -    t= copy (selection_t [key]);
> -    s= copy (selection_s [key]);
> -    return true;
> +  t= "none";
> +
> +  if(owns) {
> +    if (selection_t->contains (key)) {
> +      t= copy (selection_t [key]);
> +      s= copy (selection_s [key]);
> +      return true;
> +    }
> +    return false;
>    }
> -  if (key != "primary") return false;
>  
> -  QClipboard *clipboard = QApplication::clipboard();
> -  QString originalText = clipboard->text();
> +  QString originalText = cb->text(mode);
>    QByteArray buf = originalText.toAscii();
>    if (!(buf.isEmpty())) {
>      s << string(buf.constData(), buf.size());
> @@ -109,19 +122,18 @@ bool
>  qt_gui_rep::set_selection (string key, tree t, string s) {
>    selection_t (key)= copy (t);
>    selection_s (key)= copy (s);
> -  if (key == "primary") {
> -    //if (is_nil (windows_l)) return false;
> -    //Window win= windows_l->item;
> -    if (selection != NULL) tm_delete_array (selection);
> -    //XSetSelectionOwner (dpy, XA_PRIMARY, win, CurrentTime);
> -    //if (XGetSelectionOwner(dpy, XA_PRIMARY)==None) return false;
> -    selection= as_charp (s);
>  
> -    QClipboard *clipboard = QApplication::clipboard();
> -    QString originalText = clipboard->text();
> +  QClipboard *cb = QApplication::clipboard();
>  
> -    clipboard->setText(selection);
> -  }
> +  QClipboard::Mode mode;
> +  if (key == "primary")
> +    mode=QClipboard::Clipboard;
> +  else if (key == "mouse" && cb->supportsSelection())
> +    mode=QClipboard::Selection;
> +  else
> +    return true;
> +
> +  cb->setText(QString::fromAscii(as_charp(s)),mode);
>    return true;
>  }
>  
> @@ -129,11 +141,12 @@ void
>  qt_gui_rep::clear_selection (string key) {
>    selection_t->reset (key);
>    selection_s->reset (key);
> -  if ((key == "primary") && (selection != NULL)) {
> -    tm_delete_array (selection);
> -    // FIXME: should we do something with the pasteboard?
> -    selection= NULL;
> -  }
> +
> +  QClipboard *cb = QApplication::clipboard();
> +  if (key == "primary")
> +    cb->clear(QClipboard::Clipboard);
> +  else if (key == "mouse" && cb->supportsSelection())
> +    cb->clear(QClipboard::Selection);
>  }
>  
>  
> /******************************************************************************

> Fix color computation in qt drawing of glyphs
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_renderer.cpp |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_renderer.cpp 
> b/src/src/Plugins/Qt/qt_renderer.cpp
> index c5e3b49..9e09bec 100755
> --- a/src/src/Plugins/Qt/qt_renderer.cpp
> +++ b/src/src/Plugins/Qt/qt_renderer.cpp
> @@ -357,7 +357,7 @@ qt_renderer_rep::draw (int c, font_glyphs fng, SI x, SI 
> y) {
>        for (j=0; j<h; j++)
>          for (i=0; i<w; i++) {
>            int col = gl->get_x (i, j);
> -          brush.setColor (QColor (r, g, b, (255*col)/(nr_cols+1)));
> +          brush.setColor (QColor (r, g, b, (255*col)/nr_cols));
>            pp.fillRect (i, j, 1, 1, brush);
>          }
>        pp.end();
> @@ -376,7 +376,7 @@ qt_renderer_rep::draw (int c, font_glyphs fng, SI x, SI 
> y) {
>        for (j=0; j<h; j++)
>          for (i=0; i<w; i++) {
>            int col = gl->get_x (i, j);
> -          im->setPixel (i, j, qRgba (r, g, b, (255*col)/(nr_cols+1)));
> +          im->setPixel (i, j, qRgba (r, g, b, (255*col)/nr_cols));
>          }
>      }
>  #endif

> Enable smooth rendering for images
> 
> From:  <>
> 
> 
> ---
> 
>  src/src/Plugins/Qt/qt_renderer.cpp |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> 
> diff --git a/src/src/Plugins/Qt/qt_renderer.cpp 
> b/src/src/Plugins/Qt/qt_renderer.cpp
> index 9e09bec..26e7ca4 100755
> --- a/src/src/Plugins/Qt/qt_renderer.cpp
> +++ b/src/src/Plugins/Qt/qt_renderer.cpp
> @@ -253,9 +253,6 @@ qt_renderer_rep::image (url u, SI w, SI h, SI x, SI y,
>    w= w/pixel; h= h/pixel;
>    decode (x, y);
>  
> -  //painter.setRenderHints (0);
> -  //painter.drawRect (QRect (x, y-h, w, h));
> -
>    QImage *pm = NULL;
>    tree lookup= tuple (u->t);
>    lookup << as_string (w ) << as_string (h )
> @@ -275,7 +272,7 @@ qt_renderer_rep::image (url u, SI w, SI h, SI x, SI y,
>  #ifdef MACOSX_EXTENSIONS
>        mac_image_to_png (u, temp);
>  #else
> -      system ("convert", u, temp);
> +      system ("convert  -background white -flatten", u, temp);
>  #endif
>        pm= new QImage (to_qstring (as_string (temp)));
>        remove (temp);
> @@ -299,8 +296,7 @@ qt_renderer_rep::image (url u, SI w, SI h, SI x, SI y,
>    int ww= x2 - x1;
>    int hh= y2 - y1;
>  
> -  painter.setRenderHints (0);
> -  //painter.setRenderHints (QPainter::SmoothPixmapTransform);
> +  painter.setRenderHints (QPainter::SmoothPixmapTransform);
>    painter.drawImage (QRect (x, y-h, w, h), *pm, QRect (x1, hh-y2, ww, hh));
>  };
>  

> _______________________________________________
> Texmacs-dev mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/texmacs-dev





reply via email to

[Prev in Thread] Current Thread [Next in Thread]