GTK: Remove mostly unused status bar.

Don't bypass compositor in UI-fullscreen mode.
This commit is contained in:
Brandon Wright 2019-03-24 12:25:29 -05:00
parent 54ba8798b5
commit 0deed414b9
7 changed files with 5 additions and 172 deletions

View File

@ -100,7 +100,6 @@ int Snes9xConfig::load_defaults ()
mute_sound_turbo = false;
fullscreen = false;
ui_visible = true;
statusbar_visible = false;
default_esc_behavior = 1;
prevent_screensaver = false;
sound_driver = 0;
@ -311,7 +310,6 @@ int Snes9xConfig::save_config_file ()
cf.SetInt (z"ShaderParametersHeight", shader_parameters_height);
cf.SetInt (z"CurrentDisplayTab", current_display_tab);
outbool (cf, z"UIVisible", ui_visible);
outbool (cf, z"StatusBarVisible", statusbar_visible);
if (default_esc_behavior != ESC_TOGGLE_MENUBAR)
outbool (cf, z"Fullscreen", 0);
else
@ -542,7 +540,6 @@ int Snes9xConfig::load_config_file ()
inint (z"ShaderParametersHeight", shader_parameters_height);
inint (z"CurrentDisplayTab", current_display_tab);
inbool (z"UIVisible", ui_visible);
inbool (z"StatusBarVisible", statusbar_visible);
inbool (z"Fullscreen", fullscreen);
#undef z

View File

@ -63,7 +63,6 @@ class Snes9xConfig
bool change_display_resolution;
bool fullscreen;
bool ui_visible;
bool statusbar_visible;
int default_esc_behavior;
bool prevent_screensaver;
int xrr_index;

View File

@ -269,8 +269,6 @@ S9xNetplaySyncSpeed ()
int
S9xNetplayPush ()
{
static int statusbar_state = false;
if (gui_config->netplay_activated &&
(!Settings.NetPlay || !NetPlay.Connected))
S9xNetplayDisconnect ();
@ -285,23 +283,11 @@ S9xNetplayPush ()
S9xSoundStop ();
NetPlay.Paused = true;
if (statusbar_state == false)
{
top_level->update_statusbar ();
statusbar_state = true;
}
return 1;
}
NetPlay.Paused = false;
if (statusbar_state)
{
top_level->update_statusbar ();
statusbar_state = false;
}
S9xSoundStart ();
/* Save the joypad input */

View File

@ -254,7 +254,6 @@ void S9xNoROMLoaded ()
gui_config->rom_loaded = false;
S9xDisplayRefresh (-1, -1);
top_level->configure_widgets ();
top_level->update_statusbar ();
}
static gboolean S9xPauseFunc (gpointer data)
@ -287,7 +286,6 @@ static gboolean S9xPauseFunc (gpointer data)
S9xIdleFunc,
NULL,
NULL);
top_level->update_statusbar ();
return false;
}
@ -310,7 +308,6 @@ gboolean S9xIdleFunc (gpointer data)
/* Move to a timer-based function to use less CPU */
g_timeout_add (100, S9xPauseFunc, NULL);
top_level->update_statusbar ();
return false;
}

View File

@ -5,6 +5,7 @@
\*****************************************************************************/
#include "gtk_2_3_compat.h"
#include "gtk_config.h"
#ifdef GDK_WINDOWING_X11
#include <X11/Xatom.h>
#endif
@ -103,14 +104,6 @@ event_toggle_interface (GtkWidget *widget, gpointer data)
return true;
}
static gboolean
event_show_statusbar (GtkWidget *widget, gpointer data)
{
((Snes9xWindow *) data)->toggle_statusbar ();
return true;
}
static gboolean
event_sync_clients (GtkWidget *widget, gpointer data)
{
@ -601,7 +594,6 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
{ "rom_info", G_CALLBACK (event_rom_info) },
{ "sync_clients", G_CALLBACK (event_sync_clients) },
{ "toggle_interface", G_CALLBACK (event_toggle_interface) },
{ "show_statusbar", G_CALLBACK (event_show_statusbar) },
{ "exact_1x", G_CALLBACK (event_exact_pixels_1x) },
{ "exact_2x", G_CALLBACK (event_exact_pixels_2x) },
{ "exact_3x", G_CALLBACK (event_exact_pixels_3x) },
@ -658,10 +650,6 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (drawing_area)), NULL, false);
#endif
gtk_check_menu_item_set_active (
GTK_CHECK_MENU_ITEM (get_widget ("show_statusbar_item")),
config->statusbar_visible ? 1 : 0);
#ifndef USE_OPENGL
gtk_widget_hide (get_widget ("shader_parameters_separator"));
gtk_widget_hide (get_widget ("shader_parameters_item"));
@ -1322,81 +1310,6 @@ Snes9xWindow::set_menu_item_selected (const char *name)
gtk_check_menu_item_set_active (item, 1);
}
static gboolean
statusbar_timeout (gpointer data)
{
gtk_statusbar_pop (GTK_STATUSBAR (data),
gtk_statusbar_get_context_id (GTK_STATUSBAR (data),
"info"));
return false;
}
void
Snes9xWindow::show_status_message (const char *message)
{
GtkStatusbar *statusbar = GTK_STATUSBAR (get_widget ("statusbar"));
gtk_statusbar_pop (statusbar, gtk_statusbar_get_context_id (statusbar, "info"));
gtk_statusbar_push (statusbar, gtk_statusbar_get_context_id (statusbar, "info"), message);
g_timeout_add (2000, statusbar_timeout, statusbar);
}
void
Snes9xWindow::update_statusbar ()
{
GtkStatusbar *bar = GTK_STATUSBAR (get_widget ("statusbar"));
char status_string[256];
char title_string[1024];
if (!config->rom_loaded)
{
snprintf (title_string, 1024, "Snes9x");
status_string[0] = '\0';
}
else
{
if (config->netplay_activated)
{
if (config->netplay_server_up)
{
snprintf (status_string,
256,
_("%sHosting NetPlay - %s"),
is_paused () || NetPlay.Paused ? _("Paused - ") : "",
S9xBasenameNoExt (Memory.ROMFilename));
}
else
{
snprintf (status_string,
256,
_("%s%s on NetPlay %s:%d - Player %d"),
is_paused () || NetPlay.Paused ? _("Paused - ") : "",
S9xBasenameNoExt (Memory.ROMFilename),
NetPlay.ServerHostName,
NetPlay.Port,
NetPlay.Player);
}
}
else
{
snprintf (status_string,
256,
"%s%s",
is_paused () ? _("Paused - ") : "",
S9xBasenameNoExt (Memory.ROMFilename));
}
snprintf (title_string, 1024, "%s", S9xBasenameNoExt (Memory.ROMFilename));
}
gtk_window_set_title (GTK_WINDOW (window), title_string);
gtk_statusbar_pop (bar, gtk_statusbar_get_context_id (bar, "none"));
gtk_statusbar_push (bar, gtk_statusbar_get_context_id (bar, "none"), status_string);
}
void
Snes9xWindow::show_rom_info ()
{
@ -1488,34 +1401,29 @@ Snes9xWindow::configure_widgets ()
if (!config->fullscreen)
{
gtk_widget_show (get_widget ("menubar"));
gtk_widget_set_visible (get_widget ("statusbar"),
config->statusbar_visible);
}
else
{
gtk_widget_hide (get_widget ("menubar"));
gtk_widget_hide (get_widget ("statusbar"));
}
gtk_widget_hide (get_widget ("hide_ui"));
gtk_widget_hide (get_widget ("hide_ui_separator"));
}
else
{
enable_widget ("fullscreen_item", true);
gtk_widget_show (get_widget ("hide_ui"));
gtk_widget_show (get_widget ("hide_ui_separator"));
if (config->ui_visible)
{
gtk_widget_show (get_widget ("menubar"));
gtk_widget_set_visible (get_widget ("statusbar"),
config->statusbar_visible);
}
else
{
gtk_widget_hide (get_widget ("menubar"));
gtk_widget_hide (get_widget ("statusbar"));
}
}
@ -1726,7 +1634,8 @@ Snes9xWindow::enter_fullscreen_mode ()
gdk_display_sync (gdk_display_get_default ());
gtk_window_present (GTK_WINDOW (window));
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))))
if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))) &&
config->default_esc_behavior != ESC_TOGGLE_MENUBAR)
{
set_bypass_compositor (gdk_x11_display_get_xdisplay (gtk_widget_get_display (GTK_WIDGET (window))),
gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window))),
@ -1801,33 +1710,6 @@ Snes9xWindow::leave_fullscreen_mode ()
configure_widgets ();
}
void
Snes9xWindow::toggle_statusbar ()
{
GtkWidget *item;
GtkAllocation allocation;
int width = 0;
int height = 0;
item = get_widget ("menubar");
gtk_widget_get_allocation (item, &allocation);
height += gtk_widget_get_visible (item) ? allocation.height : 0;
item = get_widget ("drawingarea");
gtk_widget_get_allocation (item, &allocation);
height += allocation.height;
width = allocation.width;
config->statusbar_visible = !config->statusbar_visible;
configure_widgets ();
item = get_widget ("statusbar");
gtk_widget_get_allocation (item, &allocation);
height += gtk_widget_get_visible (item) ? allocation.height : 0;
resize (width, height);
}
void
Snes9xWindow::resize_viewport (int width, int height)
{
@ -1839,10 +1721,6 @@ Snes9xWindow::resize_viewport (int width, int height)
gtk_widget_get_allocation (item, &allocation);
y_padding += gtk_widget_get_visible (item) ? allocation.height : 0;
item = get_widget ("statusbar");
gtk_widget_get_allocation (item, &allocation);
y_padding += gtk_widget_get_visible (item) ? allocation.height : 0;
resize (width, height + y_padding);
}
@ -1989,7 +1867,6 @@ Snes9xWindow::propagate_pause_state ()
}
configure_widgets ();
update_statusbar ();
}
}

View File

@ -53,9 +53,6 @@ class Snes9xWindow : public GtkBuilderWindow
/* GTK-base-related functions */
void show ();
void show_status_message (const char *message);
void update_statusbar ();
void toggle_statusbar ();
void set_menu_item_selected (const char *name);
void set_mouseable_area (int x, int y, int width, int height);
void set_menu_item_accel_to_binding (const char *name,

View File

@ -1669,15 +1669,6 @@
<signal name="activate" handler="toggle_interface" swapped="no"/>
</object>
</child>
<child>
<object class="GtkCheckMenuItem" id="show_statusbar_item">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Status Bar</property>
<property name="use_underline">True</property>
<signal name="activate" handler="show_statusbar" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem" id="hide_ui_separator">
<property name="visible">True</property>
@ -1977,17 +1968,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkStatusbar" id="statusbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>