[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: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h gui/gu... |
Date: |
Fri, 13 Apr 2007 09:15:55 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Bastiaan Jacques <bjacques> 07/04/13 09:15:55
Modified files:
. : ChangeLog
gui : gtk.cpp gtksup.h gui.cpp gui.h kde.cpp
kde_glue.h kdesup.h
libbase : container.h
server : gnash.h
Log message:
* server/gnash.h, gui: version two of Antti Ajanki's GUI
patches, this time the whole thing.
* libbase/container.h: Remove the last pthread.h include
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2868&r2=1.2869
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.cpp?cvsroot=gnash&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gui.h?cvsroot=gnash&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde_glue.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kdesup.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/container.h?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.91&r2=1.92
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2868
retrieving revision 1.2869
diff -u -b -r1.2868 -r1.2869
--- ChangeLog 13 Apr 2007 07:35:55 -0000 1.2868
+++ ChangeLog 13 Apr 2007 09:15:54 -0000 1.2869
@@ -11,6 +11,9 @@
it is used in another DSO.
* all over the place: Remove all inclusions of pthread.h,
because we're no longer directly using pthreads.
+ * server/gnash.h, gui: version two of Antti Ajanki's GUI
+ patches, this time the whole thing.
+ * libbase/container.h: Remove the last pthread.h include.
2007-04-12 Sandro Santilli <address@hidden>
Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- gui/gtk.cpp 12 Apr 2007 09:04:01 -0000 1.86
+++ gui/gtk.cpp 13 Apr 2007 09:15:54 -0000 1.87
@@ -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.86 2007/04/12 09:04:01 bjacques Exp $ */
+/* $Id: gtk.cpp,v 1.87 2007/04/13 09:15:54 bjacques 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.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- gui/gtksup.h 12 Apr 2007 09:04:01 -0000 1.39
+++ gui/gtksup.h 13 Apr 2007 09:15:54 -0000 1.40
@@ -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.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- gui/gui.cpp 12 Apr 2007 09:04:01 -0000 1.71
+++ gui/gui.cpp 13 Apr 2007 09:15:54 -0000 1.72
@@ -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.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- gui/gui.h 12 Apr 2007 09:04:01 -0000 1.49
+++ gui/gui.h 13 Apr 2007 09:15:54 -0000 1.50
@@ -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.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gui/kde.cpp 12 Apr 2007 09:04:01 -0000 1.12
+++ gui/kde.cpp 13 Apr 2007 09:15:54 -0000 1.13
@@ -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.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gui/kde_glue.h 12 Apr 2007 09:04:01 -0000 1.8
+++ gui/kde_glue.h 13 Apr 2007 09:15:54 -0000 1.9
@@ -18,7 +18,7 @@
//
-/* $Id: kde_glue.h,v 1.8 2007/04/12 09:04:01 bjacques Exp $ */
+/* $Id: kde_glue.h,v 1.9 2007/04/13 09:15:54 bjacques 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.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- gui/kdesup.h 12 Apr 2007 09:04:01 -0000 1.14
+++ gui/kdesup.h 13 Apr 2007 09:15:54 -0000 1.15
@@ -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
Index: libbase/container.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/container.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- libbase/container.h 11 Apr 2007 17:54:21 -0000 1.52
+++ libbase/container.h 13 Apr 2007 09:15:54 -0000 1.53
@@ -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: container.h,v 1.52 2007/04/11 17:54:21 bjacques Exp $ */
+/* $Id: container.h,v 1.53 2007/04/13 09:15:54 bjacques Exp $ */
#ifndef __CONTAINER_H__
#define __CONTAINER_H__
@@ -52,8 +52,8 @@
#ifndef _LIB_PTHREAD_TYPES_H
# define _LIB_PTHREAD_TYPES_H 1
#endif
+
#include <sys/types.h>
-#include <pthread.h>
// This screws up MingW
#if 0
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -b -r1.91 -r1.92
--- server/gnash.h 11 Apr 2007 14:20:20 -0000 1.91
+++ server/gnash.h 13 Apr 2007 09:15:54 -0000 1.92
@@ -17,7 +17,7 @@
//
//
-/* $Id: gnash.h,v 1.91 2007/04/11 14:20:20 strk Exp $ */
+/* $Id: gnash.h,v 1.92 2007/04/13 09:15:54 bjacques Exp $ */
/// \mainpage
///
@@ -545,6 +545,13 @@
KEYCOUNT
};
+enum modifier
+{
+ MOD_NONE = 0,
+ MOD_SHIFT = 1,
+ MOD_CONTROL = 2,
+ MOD_ALT = 4
+};
} // end namespace key
/// Some optional helpers.