Skip to content

Commit

Permalink
Fix position error bug in multi screen device.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Nov 1, 2020
1 parent 61f3faa commit a2abde5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/OpenArk/common/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,31 @@ void OpenArkConfig::GetMainGeometry(int &x, int &y, int &w, int &h)

if (!(Contains(section + "x") || Contains(section + "y") ||
Contains(section + "w") || Contains(section + "h"))) {
QRect desk = QApplication::desktop()->availableGeometry();
double scale = (double)desk.height() / desk.width();
double width = desk.width() / 1.7;
double height = width * scale;
double pos_x = desk.width() / 8;
double pos_y = desk.height() / 8;
x = (int)pos_x;
y = (int)pos_y;
w = (int)width;
h = (int)height;
return;
return GetMainDefaultGeometry(x, y, w, h);
}

x = GetValue(section + "x").toInt();
y = GetValue(section + "y").toInt();
w = GetValue(section + "w").toInt();
h = GetValue(section + "h").toInt();

if (GetSystemMetrics(SM_CMONITORS) <= 1 && (x <= 0 || y <= 0))
OpenArkConfig::Instance()->GetMainDefaultGeometry(x, y, w, h);
}

void OpenArkConfig::GetMainDefaultGeometry(int &x, int &y, int &w, int &h)
{
QRect desk = QApplication::desktop()->availableGeometry();
double scale = (double)desk.height() / desk.width();
double width = desk.width() / 1.7;
double height = width * scale;
double pos_x = desk.width() / 8;
double pos_y = desk.height() / 8;
x = (int)pos_x;
y = (int)pos_y;
w = (int)width;
h = (int)height;
return;
}

void OpenArkConfig::SetMainGeometry(int x, int y, int w, int h)
Expand Down
1 change: 1 addition & 0 deletions src/OpenArk/common/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class OpenArkConfig {
QStringList GetJunkDirs();
QString GetConsole(const QString &name);
void GetMainGeometry(int &x, int &y, int &w, int &h);
void GetMainDefaultGeometry(int &x, int &y, int &w, int &h);
void SetMainGeometry(int x, int y, int w, int h);
void GetMainMaxed(bool &maxed);
void SetMainMaxed(bool maxed);
Expand Down

0 comments on commit a2abde5

Please sign in to comment.