[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h gui/gu...
From: |
Markus Gothe |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h gui/gu... |
Date: |
Thu, 12 Apr 2007 06:51:04 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Markus Gothe <nihilus> 07/04/12 06:51:04
Modified files:
. : ChangeLog
gui : gtk.cpp gtksup.h gui.cpp gui.h kde.cpp
kde_glue.h kdesup.h
Log message:
Applied patches from Anntti Ajanki
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2854&r2=1.2855
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde_glue.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kdesup.h?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2854
retrieving revision 1.2855
diff -u -b -r1.2854 -r1.2855
--- ChangeLog 12 Apr 2007 05:37:33 -0000 1.2854
+++ ChangeLog 12 Apr 2007 06:51:04 -0000 1.2855
@@ -1,3 +1,21 @@
+2007-04-11 Antti Ajanki <address@hidden>
+
+ * gui/gtk.cpp gui/gtksup.h gui/gui.cpp gui/gui.h
+ * gui/kde.cpp gui/kde_glue.h gui/kdesup.h
+ * moves the handling of GUI shortcuts (Crtl+R for restarting the
+ movie, Ctrl+Q for quiting, etc.) form GtkGui to base class Gui.
+ This way all GUIs can inherit the same code instead of having
+ to duplicate it.
+ adds keyboard handling for the KdeGui using this new interface.
+ Currently KdeGui has no support for keyboard input.
+
+ The destructor of KdeGlue deletes _drawing_area object even though
+ it is not owned by KdeGlue. The _drawing_area is actually the
+ _qwidget object from KdeGui and is (correctly) deleted at the
+ destructor of
+ KdeGui. This double-free error causes a segfault when closing
+ Gnash.
+
2007-04-11 Sandro Santilli <address@hidden>
* server/parser/shape_character_def.cpp (compute_bound):
Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- gui/gtk.cpp 2 Apr 2007 16:46:32 -0000 1.81
+++ gui/gtk.cpp 12 Apr 2007 06:51:04 -0000 1.82
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: gtk.cpp,v 1.81 2007/04/02 16:46:32 tgc Exp $ */
+/* $Id: gtk.cpp,v 1.82 2007/04/12 06:51:04 nihilus Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1154,6 +1154,24 @@
return c;
}
+int
+GtkGui::gdk_to_gnash_modifier(int state)
+{
+ int modifier = gnash::key::MOD_NONE;
+
+ if (state & GDK_SHIFT_MASK) {
+ modifier = modifier | gnash::key::MOD_SHIFT;
+ }
+ if (state & GDK_CONTROL_MASK) {
+ modifier = modifier | gnash::key::MOD_CONTROL;
+ }
+ if (state & GDK_MOD1_MASK) {
+ modifier = modifier | gnash::key::MOD_ALT;
+ }
+
+ return modifier;
+}
+
gboolean
GtkGui::key_press_event(GtkWidget *const /*widget*/,
GdkEventKey *const event,
@@ -1165,52 +1183,10 @@
/* Forward key event to gnash */
gnash::key::code c = gdk_to_gnash_key(event->keyval);
+ int mod = gdk_to_gnash_modifier(event->state);
if (c != gnash::key::INVALID) {
- gui->notify_key_event(c, true);
- }
-
- /* Handle GUI shortcuts */
- if (event->length <= 0) {
- return true;
- }
- unsigned int key = gdk_unicode_to_keyval(event->keyval);
- if (event->state == GDK_SHIFT_MASK) {
- dbglogfile << "Got Shift-key: " << key << endl;
- }
- if (event->state == GDK_CONTROL_MASK) {
- dbglogfile << "Got Control-key: " << key << endl;
- switch(key) {
- case 'r':
- gui->menu_restart();
- break;
- case 'p':
- gui->menu_pause();
- break;
- case 'q':
- case 'w':
- gui->menu_quit();
- break;
- default:
- break;
- }
- } else {
-#if 0
- dbglogfile << "Got key: '" << (char) key
- << "' its name is: " << gdk_keyval_name(key)
- << " it's value is: " << (int)key
- << " hwkeycode: " << event->hardware_keycode << endl;
-#endif
- switch (key) {
- case '[':
- menuitem_step_forward_callback(NULL, NULL);
- break;
- case ']':
- menuitem_step_backward_callback(NULL, NULL);
- break;
- default:
- break;
- }
+ gui->notify_key_event(c, mod, true);
}
return true;
@@ -1228,9 +1204,10 @@
/* Forward key event to gnash */
gnash::key::code c = gdk_to_gnash_key(event->keyval);
+ int mod = gdk_to_gnash_modifier(event->state);
if (c != gnash::key::INVALID) {
- gui->notify_key_event(c, false);
+ gui->notify_key_event(c, mod, false);
}
return true;
Index: gui/gtksup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtksup.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- gui/gtksup.h 6 Mar 2007 18:06:13 -0000 1.37
+++ gui/gtksup.h 12 Apr 2007 06:51:04 -0000 1.38
@@ -158,6 +158,7 @@
#endif
static gnash::key::code gdk_to_gnash_key(guint key);
+ static int gdk_to_gnash_modifier(int state);
static void open_file(GtkWidget* dialog, gpointer data);
};
Index: gui/gui.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- gui/gui.cpp 4 Apr 2007 20:30:45 -0000 1.69
+++ gui/gui.cpp 12 Apr 2007 06:51:04 -0000 1.70
@@ -277,17 +277,46 @@
}
void
-Gui::notify_key_event(gnash::key::code k, bool pressed)
+Gui::notify_key_event(gnash::key::code k, int modifier, bool pressed)
{
movie_root* m = get_current_root();
- //log_msg("mouse @ %d,%d", x, y);
if ( m->notify_key_event(k, pressed) )
{
// any action triggered by the
// event required screen refresh
display(m);
}
+
+ /* Handle GUI shortcuts */
+ if (!pressed) return;
+ if (modifier & gnash::key::MOD_CONTROL) {
+ switch(k) {
+ case gnash::key::R:
+ menu_restart();
+ break;
+ case gnash::key::P:
+ menu_pause();
+ break;
+ case gnash::key::Q:
+ case gnash::key::W:
+ menu_quit();
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (k) {
+ case gnash::key::LEFT_BRACKET:
+ menu_step_forward();
+ break;
+ case gnash::key::RIGHT_BRACKET:
+ menu_step_backward();
+ break;
+ default:
+ break;
+ }
+ }
}
bool
Index: gui/gui.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gui.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- gui/gui.h 2 Apr 2007 15:45:22 -0000 1.47
+++ gui/gui.h 12 Apr 2007 06:51:04 -0000 1.48
@@ -182,11 +182,11 @@
/// Key event notification to be called when a key is pressed or depressed
//
/// @param k The key code.
- ///
+ /// @param modifier Modifier key identifiers from gnash::key::modifier
ORed together
/// @param pressed Determines whether the key is being
/// pressed (true) or being released (false)
///
- void notify_key_event(gnash::key::code k, bool pressed);
+ void notify_key_event(gnash::key::code k, int modifier, bool pressed);
/// Resize the client area view and the window accordingly.
//
Index: gui/kde.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/kde.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/kde.cpp 20 Mar 2007 16:22:38 -0000 1.10
+++ gui/kde.cpp 12 Apr 2007 06:51:04 -0000 1.11
@@ -149,6 +149,102 @@
return true;
}
+gnash::key::code
+KdeGui::qtToGnashKey(QKeyEvent *event)
+{
+ gnash::key::code c = gnash::key::INVALID;
+ int key = event->key();
+
+ if (key >= Qt::Key_0 && key <= Qt::Key_9) {
+ if (event->state() & Qt::Keypad)
+ c = (gnash::key::code) ((key - Qt::Key_0) + gnash::key::KP_0);
+ else
+ c = (gnash::key::code) ((key - Qt::Key_0) + gnash::key::_0);
+ } else if (key >= Qt::Key_A && key <= Qt::Key_Z) {
+ c = (gnash::key::code) ((key - Qt::Key_A) + gnash::key::A);
+ } else if (key >= Qt::Key_F1 && key <= Qt::Key_F15) {
+ c = (gnash::key::code) ((key - Qt::Key_F1) + gnash::key::F1);
+ } else {
+ // many keys don't correlate, so just use a look-up table.
+ struct {
+ int qt;
+ gnash::key::code gs;
+ } table[] = {
+ { Qt::Key_Backspace, gnash::key::BACKSPACE },
+ { Qt::Key_Tab, gnash::key::TAB },
+ { Qt::Key_Clear, gnash::key::CLEAR },
+ { Qt::Key_Return, gnash::key::ENTER },
+ { Qt::Key_Enter, gnash::key::ENTER },
+
+ { Qt::Key_Shift, gnash::key::SHIFT },
+ { Qt::Key_Control, gnash::key::CONTROL },
+ { Qt::Key_Alt, gnash::key::ALT },
+ { Qt::Key_CapsLock, gnash::key::CAPSLOCK },
+
+ { Qt::Key_Escape, gnash::key::ESCAPE },
+ { Qt::Key_Space, gnash::key::SPACE },
+
+ { Qt::Key_Next, gnash::key::PGDN },
+ { Qt::Key_Prior, gnash::key::PGUP },
+ { Qt::Key_Home, gnash::key::HOME },
+ { Qt::Key_End, gnash::key::END },
+ { Qt::Key_Left, gnash::key::LEFT },
+ { Qt::Key_Up, gnash::key::UP },
+ { Qt::Key_Right, gnash::key::RIGHT },
+ { Qt::Key_Down, gnash::key::DOWN },
+ { Qt::Key_Insert, gnash::key::INSERT },
+ { Qt::Key_Delete, gnash::key::DELETEKEY },
+
+ { Qt::Key_Help, gnash::key::HELP },
+ { Qt::Key_NumLock, gnash::key::NUM_LOCK },
+ { Qt::Key_Semicolon, gnash::key::SEMICOLON },
+ { Qt::Key_Equal, gnash::key::EQUALS },
+ { Qt::Key_Minus, gnash::key::MINUS },
+ { Qt::Key_Slash, gnash::key::SLASH },
+ { Qt::Key_BracketLeft, gnash::key::LEFT_BRACKET },
+ { Qt::Key_Backslash, gnash::key::BACKSLASH },
+ { Qt::Key_BracketRight, gnash::key::RIGHT_BRACKET },
+ { Qt::Key_QuoteDbl, gnash::key::QUOTE },
+ { 0, gnash::key::INVALID }
+ };
+
+ for (int i = 0; table[i].qt != 0; i++) {
+ if (key == table[i].qt) {
+ c = table[i].gs;
+ break;
+ }
+ }
+ }
+
+ return c;
+}
+
+int
+KdeGui::qtToGnashModifier(Qt::ButtonState state)
+{
+ int modifier = gnash::key::MOD_NONE;
+
+ if (state & Qt::ShiftButton) {
+ modifier = modifier | gnash::key::MOD_SHIFT;
+ }
+ if (state & Qt::ControlButton) {
+ modifier = modifier | gnash::key::MOD_CONTROL;
+ }
+ if (state & Qt::AltButton) {
+ modifier = modifier | gnash::key::MOD_ALT;
+ }
+
+ return modifier;
+}
+
+void
+KdeGui::handleKeyEvent(QKeyEvent *event, bool down)
+{
+ gnash::key::code c = qtToGnashKey(event);
+ int mod = qtToGnashModifier(event->state());
+ notify_key_event(c, mod, down);
+}
+
/// \brief restart the movie from the beginning
void
@@ -259,6 +355,7 @@
_godfather = godfather;
setMouseTracking(true);
+ setFocusPolicy(QWidget::StrongFocus);
}
void
@@ -292,6 +389,17 @@
_godfather->notify_mouse_clicked(false, 1);
}
+void
+qwidget::keyPressEvent(QKeyEvent *event)
+{
+ _godfather->handleKeyEvent(event, true);
+}
+
+void
+qwidget::keyReleaseEvent(QKeyEvent *event)
+{
+ _godfather->handleKeyEvent(event, false);
+}
void
qwidget::resizeEvent(QResizeEvent *event)
Index: gui/kde_glue.h
===================================================================
RCS file: /sources/gnash/gnash/gui/kde_glue.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gui/kde_glue.h 29 Oct 2006 18:34:10 -0000 1.6
+++ gui/kde_glue.h 12 Apr 2007 06:51:04 -0000 1.7
@@ -18,7 +18,7 @@
//
-/* $Id: kde_glue.h,v 1.6 2006/10/29 18:34:10 rsavoye Exp $ */
+/* $Id: kde_glue.h,v 1.7 2007/04/12 06:51:04 nihilus Exp $ */
#include "gnash.h"
@@ -30,7 +30,7 @@
class KdeGlue
{
public:
- virtual ~KdeGlue() { delete _drawing_area; }
+ virtual ~KdeGlue() { };
virtual bool init(int argc, char **argv[]) = 0;
virtual void prepDrawingArea(QWidget *drawing_area) = 0;
Index: gui/kdesup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/kdesup.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gui/kdesup.h 20 Mar 2007 16:22:38 -0000 1.12
+++ gui/kdesup.h 12 Apr 2007 06:51:04 -0000 1.13
@@ -70,6 +70,8 @@
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent( QMouseEvent * );
void mouseMoveEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *);
void resizeEvent(QResizeEvent *event);
public slots:
@@ -102,12 +104,16 @@
virtual void renderBuffer();
virtual void setInterval(unsigned int interval);
virtual void setTimeout(unsigned int timeout);
+ virtual void handleKeyEvent(QKeyEvent *event, bool down);
private:
QApplication* _qapp;
qwidget* _qwidget;
KdeOpenGLGlue _glue;
QTimer *_timer;
+
+ gnash::key::code qtToGnashKey(QKeyEvent *event);
+ int qtToGnashModifier(Qt::ButtonState state);
};
// end of namespace gnash
- [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h gui/gu...,
Markus Gothe <=