Skip to content

Commit a487d0a

Browse files
fix: dump_default_config no longer interfere current config
1 parent da279b7 commit a487d0a

File tree

5 files changed

+62
-71
lines changed

5 files changed

+62
-71
lines changed

src/shell/config.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@ void config::animated_float_conf::apply_to(ui::animated_color &anim,
168168
apply_to(anim.b, delay);
169169
apply_to(anim.a, delay);
170170
}
171+
std::string config::dump_default_config() { return rfl::json::write(config{}); }
171172
} // namespace mb_shell

src/shell/config.h

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -72,40 +72,40 @@ struct config {
7272
float acrylic_opacity = 0.1;
7373
bool use_dwm_if_available = true;
7474
bool use_self_drawn_border = true;
75-
struct animation {
76-
struct main {
77-
animated_float_conf y;
78-
} main;
79-
struct item {
80-
animated_float_conf opacity{.delay_scale = 0.6f};
81-
animated_float_conf x{.easing = ui::easing_type::mutation},
82-
y;
83-
animated_float_conf width;
84-
animated_float_conf blur{
85-
.easing = ui::easing_type::ease_in_out,
86-
.delay_scale = 0.7f,
87-
};
88-
float appear_blur = 2.5f;
89-
} item;
90-
struct bg {
91-
animated_float_conf opacity;
92-
animated_float_conf x, y, w, h;
93-
float appear_w_scale = 0.6f;
94-
float appear_h_scale = 0.6f;
95-
} main_bg, submenu_bg;
96-
} animation;
97-
} theme;
75+
struct animation {
76+
struct main {
77+
animated_float_conf y;
78+
} main;
79+
struct item {
80+
animated_float_conf opacity{.delay_scale = 0.6f};
81+
animated_float_conf x{.easing = ui::easing_type::mutation},
82+
y;
83+
animated_float_conf width;
84+
animated_float_conf blur{
85+
.easing = ui::easing_type::ease_in_out,
86+
.delay_scale = 0.7f,
87+
};
88+
float appear_blur = 2.5f;
89+
} item;
90+
struct bg {
91+
animated_float_conf opacity;
92+
animated_float_conf x, y, w, h;
93+
float appear_w_scale = 0.6f;
94+
float appear_h_scale = 0.6f;
95+
} main_bg, submenu_bg;
96+
} animation;
97+
} theme;
9898

9999
bool vsync = true;
100100
bool ignore_owner_draw = true;
101101
bool reverse_if_open_to_up = true;
102-
bool experimental_ownerdraw_support = false;
103-
bool hotkeys = true;
104-
bool show_settings_button = true;
105-
bool patch_explorerframe_dll = true;
106-
107-
// debug purpose only
108-
bool search_large_dwItemData_range = false;
102+
bool experimental_ownerdraw_support = false;
103+
bool hotkeys = true;
104+
bool show_settings_button = true;
105+
bool patch_explorerframe_dll = true;
106+
107+
// debug purpose only
108+
bool search_large_dwItemData_range = false;
109109

110110
struct position {
111111
int padding_vertical = 20;
@@ -139,8 +139,9 @@ struct config {
139139
static void write_config();
140140
static void run_config_loader();
141141
static std::string dump_config();
142+
static std::string dump_default_config();
142143

143144
static std::filesystem::path data_directory();
144145
void apply_fonts_to_nvg(NVGcontext *nvg);
145146
};
146-
} // namespace mb_shell
147+
} // namespace mb_shell

src/shell/contextmenu/hooks.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ mb_shell::track_popup_menu(mb_shell::menu menu, int x, int y,
374374
bool run_js) {
375375
auto thread_id_orig = GetCurrentThreadId();
376376
auto selected_menu_future = renderer_thread.add_task([&]() {
377+
set_thread_name("breeze::renderer_thread");
377378
try {
378379
struct live_menu_guard {
379380
explicit live_menu_guard(HMENU hMenu) {

src/shell/entry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void main() {
203203
script_ctx.is_js_ready.wait(false);
204204
spdlog::info("Is js ready: %d", script_ctx.is_js_ready.load());
205205
try {
206-
auto res = syncAwait(script_ctx.eval_string("throw new Error('Hello from ASAN environment!');",
206+
auto res = syncAwait(script_ctx.eval_string("setInterval(globalThis.showConfigPage, 1300);",
207207
"asan.js")->await());
208208
spdlog::info("ASAN eval result: {}", res.as<std::string>());
209209
} catch (const std::exception &e) {

src/shell/script/binding_types.cc

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#include <Windows.h>
2-
#include <WinUser.h>
3-
#include <roapi.h>
4-
#include <roerrorapi.h>
5-
#include <winstring.h>
6-
7-
#include "binding_types.hpp"
8-
#include "async_simple/Promise.h"
9-
#include "binding_types_breeze_ui.h"
10-
#include "breeze-js/quickjspp.hpp"
1+
#include <Windows.h>
2+
#include <WinUser.h>
3+
#include <roapi.h>
4+
#include <roerrorapi.h>
5+
#include <winstring.h>
6+
7+
#include "binding_types.hpp"
8+
#include "async_simple/Promise.h"
9+
#include "binding_types_breeze_ui.h"
10+
#include "breeze-js/quickjspp.hpp"
1111
#include <filesystem>
1212
#include <iostream>
1313
#include <memory>
1414
#include <mutex>
15-
#include <print>
16-
#include <ranges>
17-
#include <regex>
18-
#include <shlobj_core.h>
19-
#include <thread>
20-
#include <variant>
15+
#include <print>
16+
#include <ranges>
17+
#include <regex>
18+
#include <shlobj_core.h>
19+
#include <thread>
20+
#include <variant>
2121

2222
#include "spdlog/spdlog.h"
2323

@@ -220,20 +220,20 @@ static void to_menu_item(menu_item &data, const js_menu_data &js_data) {
220220
}
221221
}
222222

223-
void menu_item_controller::set_data(js_menu_data data) {
224-
if (!valid())
225-
return;
223+
void menu_item_controller::set_data(js_menu_data data) {
224+
if (!valid())
225+
return;
226226

227227
auto item = $item.lock();
228228

229229
to_menu_item(item->item, data);
230-
if (auto menu = std::get_if<std::weak_ptr<menu_widget>>(&$parent))
231-
if (auto m = menu->lock()) {
232-
m->update_icon_width();
233-
}
234-
}
235-
void menu_item_controller::update_data(js_menu_data data) { set_data(data); }
236-
void menu_item_controller::remove() {
230+
if (auto menu = std::get_if<std::weak_ptr<menu_widget>>(&$parent))
231+
if (auto m = menu->lock()) {
232+
m->update_icon_width();
233+
}
234+
}
235+
void menu_item_controller::update_data(js_menu_data data) { set_data(data); }
236+
void menu_item_controller::remove() {
237237
if (!valid())
238238
return;
239239
auto item = $item.lock();
@@ -658,19 +658,7 @@ std::string breeze::data_directory() {
658658
return config::data_directory().generic_string();
659659
}
660660
std::string breeze::default_config() {
661-
auto previous_default_animation = config::_default_animation;
662-
auto previous_config = std::move(config::current);
663-
664-
if (previous_config) {
665-
config::_default_animation = previous_config->default_animation;
666-
}
667-
668-
config::current = std::make_unique<mb_shell::config>();
669-
auto result = config::dump_config();
670-
671-
config::current = std::move(previous_config);
672-
config::_default_animation = previous_default_animation;
673-
return result;
661+
return config::dump_default_config();
674662
}
675663
bool breeze::should_show_settings_button() {
676664
return mb_shell::config::current->context_menu.show_settings_button;

0 commit comments

Comments
 (0)