Skip to content

Commit

Permalink
Fix some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
nomi-san committed Aug 6, 2023
1 parent b98f0b8 commit 52d332f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
1 change: 0 additions & 1 deletion core/src/browser/browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extern int remote_debugging_port_;
void OpenDevTools(cef_browser_t *browser);
void OpenRemoteDevTools();
void PrepareRemoteDevTools();
void SetUpBrowserWindow(cef_browser_t *browser, cef_frame_t *frame);

void RegisterAssetsSchemeHandlerFactory();
void RegisterRiotClientSchemeHandlerFactory();
Expand Down
4 changes: 2 additions & 2 deletions core/src/browser/devtools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ static void SetUpDevToolsWindow(HWND window)
SendMessageW(window, WM_SETICON, ICON_SMALL, (LPARAM)icon_sm);
SendMessageW(window, WM_SETICON, ICON_BIG, (LPARAM)icon_bg);

bool IsWindowsLightTheme();
bool IsWindowsDarkTheme();
void ForceDarkTheme(HWND);

if (!IsWindowsLightTheme())
if (IsWindowsDarkTheme())
{
// Force dark theme.
ForceDarkTheme(window);
Expand Down
2 changes: 1 addition & 1 deletion core/src/commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct V8Value : V8ValueBase
inline struct V8Object *asObject() { return reinterpret_cast<struct V8Object *>(&_); }

static inline V8Value *undefined() {
return (V8Value *)cef_v8value_create_null();
return (V8Value *)cef_v8value_create_undefined();
}

static inline V8Value *null() {
Expand Down
13 changes: 8 additions & 5 deletions core/src/renderer/renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ static V8Value *native_OpenAssetsFolder(const vec<V8Value *> &args)
static V8Value *native_OpenPluginsFolder(const vec<V8Value *> &args)
{
wstr destPath = config::pluginsDir();
if (args.size()) {
destPath = destPath + L"\\" + args[0]->asString()->str;
if (!utils::isDir(destPath)) {

if (args.size() > 0)
{
CefScopedStr path = args[0]->asString();
destPath += L"\\" + path.cstr();

if (!utils::isDir(destPath))
return V8Value::boolean(false);
}
}
utils::openLink(destPath);

utils::openLink(destPath);
return V8Value::boolean(true);
}

Expand Down
16 changes: 8 additions & 8 deletions core/src/renderer/winbrancy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void ClearAcrylic(HWND hwnd, bool unified)
//return Err(VibeError::UnsupportedPlatform("\"clear_acrylic()\" is only available on Windows 7+"));
}

bool IsWindowsLightTheme()
bool IsWindowsDarkTheme()
{
// based on https://stackoverflow.com/questions/51334674/how-to-detect-windows-10-light-dark-mode-in-win32-application

Expand All @@ -211,15 +211,15 @@ bool IsWindowsLightTheme()
&cbData);

if (res != ERROR_SUCCESS)
return true;
return false;

// convert bytes written to our buffer to an int, assuming little-endian
auto i = int(buffer[3] << 24 |
buffer[2] << 16 |
buffer[1] << 8 |
buffer[0]);

return i == 1;
return i != 1;
}

void ForceDarkTheme(HWND hwnd)
Expand Down Expand Up @@ -287,7 +287,8 @@ void ClearMica(HWND hwnd)
ResetClientArea(hwnd);
DwmSetWindowAttribute(hwnd, DWMWA_SYSTEMBACKDROP_TYPE, &value, sizeof(value));
}
else if (IsWin11()) {
else if (IsWin11())
{
DWORD value = 0;
ResetClientArea(hwnd);
DwmSetWindowAttribute(hwnd, DWMWA_MICA_EFFECT, &value, sizeof(value));
Expand All @@ -296,7 +297,6 @@ void ClearMica(HWND hwnd)
//throw "Mica effect is only available on Windows 11.";
}


bool ApplyEffect(std::wstring name, uint32_t option_color)
{
if (RCLIENT_WINDOW == nullptr)
Expand Down Expand Up @@ -412,7 +412,7 @@ V8Value *native_SetWindowEffect(const vec<V8Value *> &args)
}
else if (args[0]->isString())
{
CefScopedStr name{ args[0]->asString() };
CefScopedStr name = args[0]->asString();
uint32_t tintColor = 0;

if (args.size() >= 2 && args[1]->isObject())
Expand All @@ -429,8 +429,8 @@ V8Value *native_SetWindowEffect(const vec<V8Value *> &args)
}
}

//if (ClearEffect(m_current))
// m_current = L"";
if (ClearEffect(m_current))
m_current = L"";

if (success = ApplyEffect(name.str, tintColor))
m_current.assign(name.str, name.length);
Expand Down
16 changes: 8 additions & 8 deletions plugins/src/preload/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ window.openAssetsFolder = function () {
};

window.openPluginsFolder = function (path?: string) {
if(arguments.length > 1) return false;
if (path === undefined) return native.OpenPluginsFolder();
if(typeof path !== 'string') return false;

if(path.includes('..')) return false;
if(path === "") path = ".";

return native.OpenPluginsFolder(path);
if (typeof path === 'string' && path) {
if (!path.startsWith('..') && !/[\\\/]\.\.[\\\/]/.test(path)) {
if (/^[\\/]/.test(path))
path = path.substring(1);
return native.OpenPluginsFolder(path);
}
}
return native.OpenPluginsFolder();
};

window.reloadClient = function () {
Expand Down

0 comments on commit 52d332f

Please sign in to comment.