From baf094ce92ef7e55ae14d3c2225686369fe62bf2 Mon Sep 17 00:00:00 2001 From: bgk Date: Tue, 29 Apr 2008 19:08:47 +0000 Subject: [PATCH] GTK GUI : Added fullscreen support (toggle with F11) --- src/gtk/vba.glade | 14 ++++++++++++++ src/gtk/window.cpp | 25 ++++++++++++++++++++++++- src/gtk/window.h | 5 +++++ src/gtk/windowcallbacks.cpp | 22 ++++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/gtk/vba.glade b/src/gtk/vba.glade index 49eef515..cc3fc147 100644 --- a/src/gtk/vba.glade +++ b/src/gtk/vba.glade @@ -598,6 +598,20 @@ True + + + True + gtk-fullscreen + True + True + + + + + + True + + True diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 593d76cb..c3811abf 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -90,7 +90,8 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : m_iJoypadMin (1), m_iJoypadMax (4), m_iVideoOutputMin (OutputCairo), - m_iVideoOutputMax (OutputXvideo) + m_iVideoOutputMax (OutputXvideo), + m_bFullscreen (false) { m_poXml = _poXml; m_poFileOpenDialog = NULL; @@ -131,6 +132,9 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : Gtk::MenuItem * poMI; Gtk::CheckMenuItem * poCMI; + // Menu bar + m_poMenuBar = dynamic_cast(_poXml->get_widget("MenuBar")); + // Video output menu // struct @@ -828,6 +832,11 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : poCMI, astAutofire[i].m_eKeyFlag)); } + // Fullscreen menu + // + poMI = dynamic_cast(_poXml->get_widget("VideoFullscreen")); + poMI->signal_activate().connect(sigc::mem_fun(*this, &Window::vOnVideoFullscreen)); + // GDB menu // poMI = dynamic_cast(_poXml->get_widget("GdbWait")); @@ -1953,4 +1962,18 @@ void Window::vUpdateGameSlots() } } +void Window::vToggleFullscreen() +{ + if(!m_bFullscreen) + { + fullscreen(); + m_poMenuBar->hide(); + } + else + { + unfullscreen(); + m_poMenuBar->show(); + } +} + } // VBA namespace diff --git a/src/gtk/window.h b/src/gtk/window.h index 6fba720d..667d560e 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -159,6 +159,7 @@ protected: virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue); virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent); virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI); + virtual void vOnVideoFullscreen(); virtual void vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput); virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale); virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer); @@ -198,6 +199,7 @@ protected: virtual bool on_focus_out_event(GdkEventFocus * _pstEvent); virtual bool on_key_press_event(GdkEventKey * _pstEvent); virtual bool on_key_release_event(GdkEventKey * _pstEvent); + virtual bool on_window_state_event(GdkEventWindowState* _pstEvent); private: // Config limits @@ -248,6 +250,7 @@ private: Gtk::CheckMenuItem * m_poFilePauseItem; Gtk::CheckMenuItem * m_poUseBiosItem; Gtk::CheckMenuItem * m_poSoundOffItem; + Gtk::MenuBar * m_poMenuBar; struct SGameSlot { @@ -269,6 +272,7 @@ private: std::vector m_oJoypads; Keymap * m_poKeymap; + int m_bFullscreen; int m_iScreenWidth; int m_iScreenHeight; @@ -311,6 +315,7 @@ private: void vSetThrottle(int _iPercent); void vSelectBestThrottleItem(); void vUpdateGameSlots(); + void vToggleFullscreen(); }; } // namespace VBA diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 6644fbc1..4b7aae67 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -590,6 +590,11 @@ void Window::vOnThrottleOther(Gtk::CheckMenuItem * _poCMI) vSelectBestThrottleItem(); } +void Window::vOnVideoFullscreen() +{ + vToggleFullscreen(); +} + void Window::vOnVideoOutputToggled(Gtk::CheckMenuItem * _poCMI, int _iOutput) { if (! _poCMI->get_active()) @@ -1323,6 +1328,13 @@ bool Window::on_key_press_event(GdkEventKey * _pstEvent) { EKey eKey; + // The menu accelerators are disabled when it is hidden + if (_pstEvent->keyval == GDK_F11 && !m_poMenuBar->is_visible()) + { + vToggleFullscreen(); + return true; + } + if ((_pstEvent->state & Gtk::AccelGroup::get_default_mod_mask()) || (eKey = m_poKeymap->eGetKey(_pstEvent->hardware_keycode)) == KeyNone) { @@ -1431,4 +1443,14 @@ bool Window::on_key_release_event(GdkEventKey * _pstEvent) return true; } +bool Window::on_window_state_event(GdkEventWindowState* _pstEvent) +{ + if (_pstEvent->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) + { + m_bFullscreen = _pstEvent->new_window_state & GDK_WINDOW_STATE_FULLSCREEN; + } + + return true; +} + } // namespace VBA