gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10491: Kde4 gui: correctly compute


From: Sandro Santilli
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10491: Kde4 gui: correctly compute redraw area; show/hide mouse cursor; keyboard handling and Esc to exit fullscreen.
Date: Tue, 30 Dec 2008 13:42:02 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10491
author: John Wimer <address@hidden>
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Tue 2008-12-30 13:42:02 +0100
message:
  Kde4 gui: correctly compute redraw area; show/hide mouse cursor; keyboard 
handling and Esc to exit fullscreen.
modified:
  gui/Kde4Gui.cpp
  gui/Kde4Gui.h
=== modified file 'gui/Kde4Gui.cpp'
--- a/gui/Kde4Gui.cpp   2008-12-04 09:27:57 +0000
+++ b/gui/Kde4Gui.cpp   2008-12-30 12:42:02 +0000
@@ -120,13 +120,13 @@
     
     if(_xid) {
         _drawingWidget->embedInto(_xid);
-       _drawingWidget->show();
-       // Adjust width and height to the window we're being embedded into...
-       XWindowAttributes winAttributes;
-       XGetWindowAttributes(QX11Info::display(), _xid, &winAttributes);
-       _width=winAttributes.width;
-       _height=winAttributes.height;
-       _drawingWidget->resize(_width, _height);
+        _drawingWidget->show();
+        // Adjust width and height to the window we're being embedded into...
+        XWindowAttributes winAttributes;
+        XGetWindowAttributes(QX11Info::display(), _xid, &winAttributes);
+        _width=winAttributes.width;
+        _height=winAttributes.height;
+        _drawingWidget->resize(_width, _height);
     } else {
         // The QMainWindow takes ownership of the DrawingWidget.
         _window->setCentralWidget(_drawingWidget);
@@ -232,6 +232,8 @@
 void
 Kde4Gui::setCursor(gnash_cursor_type newcursor)
 {
+    if (! _mouseShown) return;
+
     switch (newcursor) {
         case CURSOR_HAND:
             _drawingWidget->setCursor(Qt::PointingHandCursor);
@@ -244,9 +246,28 @@
     }
 }
 
+bool
+Kde4Gui::showMouse(bool show)
+{
+    bool prevState = _mouseShown;
+    _mouseShown = show;
+
+    if (show) {
+        _drawingWidget->unsetCursor();
+    }
+    else {
+        _drawingWidget->setCursor(Qt::BlankCursor);
+    }
+
+    return prevState;
+}
+
 void
 Kde4Gui::setFullscreen()
 {
+    _fullscreen = true;
+    fullscreenAction->setChecked(_fullscreen);
+
     _window->showFullScreen();
     QMenuBar* mainMenu = _window->menuBar();
     if (mainMenu) mainMenu->hide();
@@ -255,6 +276,9 @@
 void
 Kde4Gui::unsetFullscreen()
 {
+    _fullscreen = false;
+    fullscreenAction->setChecked(_fullscreen);
+
     _window->showNormal();
     QMenuBar* mainMenu = _window->menuBar();
     if (mainMenu) mainMenu->show();
@@ -313,12 +337,27 @@
 }
 
 
+int
+Kde4Gui::qtToGnashModifier(const Qt::KeyboardModifiers modifiers)
+{
+    int gnashModifier = gnash::key::GNASH_MOD_NONE;
+
+    if (modifiers & Qt::ShiftModifier)
+        gnashModifier = gnashModifier | gnash::key::GNASH_MOD_SHIFT;
+    if (modifiers & Qt::ControlModifier)
+        gnashModifier = gnashModifier | gnash::key::GNASH_MOD_CONTROL;
+    if (modifiers & Qt::AltModifier)
+        gnashModifier = gnashModifier | gnash::key::GNASH_MOD_ALT;
+
+    return gnashModifier;
+}
+
 void
 Kde4Gui::handleKeyEvent(QKeyEvent *event, bool down)
 {
     gnash::key::code c = qtToGnashKey(event);
-//    int mod = qtToGnashModifier(event->state());
-    notify_key_event(c, 0, down);
+    int mod = qtToGnashModifier(event->modifiers());
+    notify_key_event(c, mod, down);
 }
 
 

=== modified file 'gui/Kde4Gui.h'
--- a/gui/Kde4Gui.h     2008-12-04 09:27:57 +0000
+++ b/gui/Kde4Gui.h     2008-12-30 12:42:02 +0000
@@ -102,6 +102,7 @@
     virtual void handleKeyEvent(QKeyEvent *event, bool down);
     virtual void setCursor(gnash_cursor_type newcursor);
     virtual void setFullscreen();
+    virtual bool showMouse(bool show);
     virtual void unsetFullscreen();
     void setInvalidatedRegions(const InvalidatedRanges& ranges);
     void resize(int width, int height);
@@ -125,7 +126,6 @@
     /// Set up the map of Qt to Gnash keys.
     void setupKeyMap();
 
-    DrawBounds::value_type _validbounds;
     DrawBounds _drawbounds;
  
     /// The main application, which should destroy everything
@@ -148,7 +148,9 @@
     /// map onto Gnash ones.
     KeyMap _keyMap;
 
+    /// Methods for mapping key press events from qt codes to gnash ones
     gnash::key::code qtToGnashKey(QKeyEvent *event);
+    int qtToGnashModifier(const Qt::KeyboardModifiers modifiers);
 
     /// QActions and QMenus should be attached to the
     /// QMainWindow so that they are destroyed with it.


reply via email to

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