Skip to content

Commit

Permalink
Add an option to disable FPS limiter
Browse files Browse the repository at this point in the history
Cherry-pick of commit d7921f3.
  • Loading branch information
jyrkive committed Oct 22, 2018
1 parent c926f2c commit cca79af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions data/gui/window/preferences/03_display.cfg
Expand Up @@ -260,6 +260,19 @@
[/grid]
[/column]
[/row]
[row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"

[toggle_button]
id = "fps_limiter"
label = _ "FPS limiter"
tooltip = _ "Disabling this increases CPU usage to 100 % but may slightly improve performance at high resolutions"
[/toggle_button]
[/column]
[/row]
#enddef

#define _GUI_PREFERENCES_DISPLAY_GRID_2
Expand Down
2 changes: 1 addition & 1 deletion src/display.cpp
Expand Up @@ -1689,7 +1689,7 @@ void display::draw_init()
void display::draw_wrap(bool update, bool force)
{
static int time_between_draws = preferences::draw_delay();
if(time_between_draws == 0) {
if(time_between_draws < 0) {
time_between_draws = 1000 / screen_.current_refresh_rate();
}

Expand Down
4 changes: 4 additions & 0 deletions src/gui/dialogs/preferences_dialog.cpp
Expand Up @@ -474,6 +474,10 @@ void preferences_dialog::post_build(window& window)
register_integer("scaling_slider", true,
font_scaling, set_font_scaling);

/* FPS LIMITER */
register_bool("fps_limiter", true,
[]() { return draw_delay() != 0; }, [](bool v) { set_draw_delay(v ? -1 : 0); });

/* SELECT THEME */
connect_signal_mouse_left_click(
find_widget<button>(&window, "choose_theme", false),
Expand Down
6 changes: 2 additions & 4 deletions src/preferences/general.cpp
Expand Up @@ -51,8 +51,6 @@ bool no_preferences_save = false;

bool fps = false;

int draw_delay_ = 0;

config prefs;
}

Expand Down Expand Up @@ -974,12 +972,12 @@ void set_show_fps(bool value)

int draw_delay()
{
return draw_delay_;
return prefs["draw_delay"].to_int(-1);
}

void set_draw_delay(int value)
{
draw_delay_ = value;
prefs["draw_delay"] = value;
}

bool use_color_cursors()
Expand Down

0 comments on commit cca79af

Please sign in to comment.