@@ -440,7 +440,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
440
440
// () use preferred mode, which is already last fallback
441
441
// (-1,-1) preference to refreshrate over resolution
442
442
// (-1,-2) preference to resolution
443
- // otherwise its a user provided mode
443
+ // otherwise its a user requested mode
444
444
if (RULE->resolution == Vector2D (-1 , -1 )) {
445
445
for (auto const & mode : output->modes ) {
446
446
if ((mode->pixelSize .x >= currentWidth && mode->pixelSize .y >= currentHeight && mode->refreshRate >= (currentRefresh - 1000 .f )) ||
@@ -456,10 +456,6 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
456
456
}
457
457
}
458
458
} else if (RULE->resolution != Vector2D ()) {
459
- // user requested a mode
460
- // try it regardless as custom if the next ones dont work
461
- requestedModes.push_back (makeShared<Aquamarine::SOutputMode>(Aquamarine::SOutputMode{.pixelSize = RULE->resolution , .refreshRate = WLRREFRESHRATE}));
462
-
463
459
// try any supported modes that are close first
464
460
for (auto const & mode : output->modes ) {
465
461
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it
@@ -494,8 +490,6 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
494
490
495
491
for (auto const & mode : requestedModes | std::views::reverse) {
496
492
if (mode->modeInfo .has_value () && mode->modeInfo ->type == DRM_MODE_TYPE_USERDEF) {
497
- // TODO: this ignores when requested mode is used as a custom mode as a fallback, since theres no modeinfo
498
- // maybe just add a custom flag
499
493
output->state ->setCustomMode (mode);
500
494
501
495
if (!state.test ()) {
@@ -536,6 +530,27 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
536
530
break ;
537
531
}
538
532
533
+ if (!success && RULE->resolution != Vector2D () && RULE->resolution != Vector2D (-1 , -1 ) && RULE->resolution != Vector2D (-1 , -2 )) {
534
+ // try requested as custom regardless
535
+ auto mode = makeShared<Aquamarine::SOutputMode>(Aquamarine::SOutputMode{.pixelSize = RULE->resolution , .refreshRate = WLRREFRESHRATE});
536
+
537
+ output->state ->setCustomMode (mode);
538
+
539
+ if (!state.test ()) {
540
+ Debug::log (ERR, " Monitor {}: REJECTED custom mode {:X0}@{:.2f}Hz!" , szName, mode->pixelSize , mode->refreshRate / 1000 .f );
541
+ } else {
542
+ Debug::log (LOG, " Monitor {}: requested {:X0}@{:.2f}Hz, using custom mode {:X0}@{:.2f}Hz" , szName, RULE->resolution , RULE->refreshRate , mode->pixelSize ,
543
+ mode->refreshRate / 1000 .f );
544
+
545
+ refreshRate = mode->refreshRate / 1000 .f ;
546
+ vecSize = mode->pixelSize ;
547
+ currentMode = mode;
548
+ customDrmMode = {};
549
+
550
+ success = true ;
551
+ }
552
+ }
553
+
539
554
// try any the modes if none of the above work
540
555
if (!success) {
541
556
for (auto const & mode : output->modes ) {
@@ -549,6 +564,11 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) {
549
564
Debug::log (WARN, errorMessage);
550
565
g_pHyprNotificationOverlay->addNotification (errorMessage, CHyprColor (0xff0000ff ), 5000 , ICON_WARNING);
551
566
567
+ refreshRate = mode->refreshRate / 1000 .f ;
568
+ vecSize = mode->pixelSize ;
569
+ currentMode = mode;
570
+ customDrmMode = {};
571
+
552
572
success = true ;
553
573
554
574
break ;
0 commit comments