refresh rates

This commit is contained in:
vaxerski 2022-03-19 21:46:29 +01:00
parent 3277321c26
commit 7b7ce638f4
5 changed files with 17 additions and 7 deletions

View file

@ -3,7 +3,7 @@
#
# Refer to the wiki for more information.
monitor=,1280x720,0x0,0.5,1
monitor=,1280x720@60,0x0,0.5,1
general {
max_fps=240

View file

@ -112,7 +112,10 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
nextItem();
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));
if (curitem.find_first_of('@') != std::string::npos)
newrule.refreshRate = stof(curitem.substr(curitem.find_first_of('@') + 1));
nextItem();

View file

@ -19,6 +19,7 @@ struct SMonitorRule {
Vector2D offset = Vector2D(0,0);
float mfact = 0.5;
float scale = 1;
float refreshRate = 60;
};
class CConfigManager {

View file

@ -29,6 +29,8 @@ void Events::listener_change(wl_listener* listener, void* data) {
CONFIGHEAD->state.mode = m.output->current_mode;
CONFIGHEAD->state.x = m.vecPosition.x;
CONFIGHEAD->state.y = m.vecPosition.y;
wlr_output_set_custom_mode(m.output, m.vecSize.x, m.vecSize.y, (int)(round(m.refreshRate * 1000)));
}
wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
@ -58,6 +60,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
// create it in the arr
newMonitor.vecPosition = monitorRule.offset;
newMonitor.vecSize = monitorRule.resolution;
newMonitor.refreshRate = monitorRule.refreshRate;
g_pCompositor->m_lMonitors.push_back(newMonitor);
//
@ -72,7 +75,9 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
wlr_output_layout_add(g_pCompositor->m_sWLROutputLayout, OUTPUT, monitorRule.offset.x, monitorRule.offset.y);
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", OUTPUT->name, (int)monitorRule.offset.x, (int)monitorRule.offset.y, (int)monitorRule.resolution.x, (int)monitorRule.resolution.y, OUTPUT);
wlr_output_set_custom_mode(OUTPUT, OUTPUT->width, OUTPUT->height, (int)(round(monitorRule.refreshRate * 1000)));
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i@%i, pointer %x", OUTPUT->name, (int)monitorRule.offset.x, (int)monitorRule.offset.y, (int)monitorRule.resolution.x, (int)monitorRule.resolution.y, (int)monitorRule.refreshRate, OUTPUT);
}
void Events::listener_monitorFrame(wl_listener* listener, void* data) {
@ -159,11 +164,8 @@ void Events::listener_destroyLayerSurface(wl_listener* listener, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
if (!PMONITOR)
return;
// remove the layersurface as it's not used anymore
PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->pending.layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
delete layersurface;
Debug::log(LOG, "LayerSurface %x destroyed", layersurface);
@ -194,6 +196,9 @@ void Events::listener_commitLayerSurface(wl_listener* listener, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
if (!PMONITOR)
return;
// fix if it changed its mon
if (layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);

View file

@ -21,6 +21,7 @@ struct SMonitor {
// WLR stuff
wlr_output* output = nullptr;
float refreshRate = 60;
// Double-linked list because we need to have constant mem addresses for signals
// We have to store pointers and use raw new/delete because they might be moved between them