mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-24 04:02:09 +00:00
Respect monitor scale
This commit is contained in:
parent
c9bc79c956
commit
82fd62aa20
3 changed files with 10 additions and 4 deletions
|
@ -188,7 +188,12 @@ namespace Wayland
|
||||||
it->second.height = height;
|
it->second.height = height;
|
||||||
}
|
}
|
||||||
static void OnOutputDone(void*, wl_output* output) {}
|
static void OnOutputDone(void*, wl_output* output) {}
|
||||||
static void OnOutputScale(void*, wl_output*, int32_t) {}
|
static void OnOutputScale(void*, wl_output* output, int32_t scale)
|
||||||
|
{
|
||||||
|
auto it = monitors.find(output);
|
||||||
|
ASSERT(it != monitors.end(), "Error: OnOutputScale called on unknown monitor");
|
||||||
|
it->second.scale = scale;
|
||||||
|
}
|
||||||
static void OnOutputName(void*, wl_output* output, const char* name)
|
static void OnOutputName(void*, wl_output* output, const char* name)
|
||||||
{
|
{
|
||||||
auto it = monitors.find(output);
|
auto it = monitors.find(output);
|
||||||
|
@ -206,7 +211,7 @@ namespace Wayland
|
||||||
if (strcmp(interface, "wl_output") == 0)
|
if (strcmp(interface, "wl_output") == 0)
|
||||||
{
|
{
|
||||||
wl_output* output = (wl_output*)wl_registry_bind(registry, name, &wl_output_interface, 4);
|
wl_output* output = (wl_output*)wl_registry_bind(registry, name, &wl_output_interface, 4);
|
||||||
Monitor mon = Monitor{"", name, 0, 0, nullptr, (uint32_t)monitors.size()};
|
Monitor mon = Monitor{"", name, 0, 0, 0, nullptr, (uint32_t)monitors.size()};
|
||||||
monitors.emplace(output, mon);
|
monitors.emplace(output, mon);
|
||||||
|
|
||||||
LOG("Wayland: Register <pending> at ID " << mon.ID);
|
LOG("Wayland: Register <pending> at ID " << mon.ID);
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace Wayland
|
||||||
uint32_t wlName;
|
uint32_t wlName;
|
||||||
int32_t width;
|
int32_t width;
|
||||||
int32_t height;
|
int32_t height;
|
||||||
|
int32_t scale; // TODO: Handle fractional scaling
|
||||||
zext_workspace_group_handle_v1* workspaceGroup;
|
zext_workspace_group_handle_v1* workspaceGroup;
|
||||||
// The Gdk monitor index. This is only a hacky approximation, since there is no way to get the wl_output from a GdkMonitor
|
// The Gdk monitor index. This is only a hacky approximation, since there is no way to get the wl_output from a GdkMonitor
|
||||||
uint32_t ID;
|
uint32_t ID;
|
||||||
|
|
|
@ -246,7 +246,7 @@ int Window::GetWidth() const
|
||||||
|
|
||||||
const Wayland::Monitor* mon = Wayland::FindMonitorByName(m_MonitorName);
|
const Wayland::Monitor* mon = Wayland::FindMonitorByName(m_MonitorName);
|
||||||
ASSERT(mon, "Window: Couldn't find monitor");
|
ASSERT(mon, "Window: Couldn't find monitor");
|
||||||
return mon->width;
|
return mon->width / mon->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Window::GetHeight() const
|
int Window::GetHeight() const
|
||||||
|
@ -257,7 +257,7 @@ int Window::GetHeight() const
|
||||||
|
|
||||||
const Wayland::Monitor* mon = Wayland::FindMonitorByName(m_MonitorName);
|
const Wayland::Monitor* mon = Wayland::FindMonitorByName(m_MonitorName);
|
||||||
ASSERT(mon, "Window: Couldn't find monitor");
|
ASSERT(mon, "Window: Couldn't find monitor");
|
||||||
return mon->width;
|
return mon->height / mon->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::MonitorAdded(GdkDisplay*, GdkMonitor*)
|
void Window::MonitorAdded(GdkDisplay*, GdkMonitor*)
|
||||||
|
|
Loading…
Reference in a new issue