Skip to content

Commit

Permalink
core: fix being able to assign a wallpaper to a nonexistent monitor (#…
Browse files Browse the repository at this point in the history
…141)

clarified README to specifics of the handleWallpaper function
  • Loading branch information
stephentoth committed Feb 25, 2024
1 parent 897cf0a commit dfd3d09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ splash = true
```

Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty for a wildcard (aka fallback). You can also use `desc:` followed by the monitor's description without the (PORT) at the end)
Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty to set all monitors without an active wallpaper. You can also use `desc:` followed by the monitor's description without the (PORT) at the end)

You may add `contain:` before the file path in `wallpaper=` to set the mode to contain instead of cover:

Expand Down
23 changes: 14 additions & 9 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,29 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) {
return result;
}

g_pHyprpaper->clearWallpaperFromMonitor(MONITOR);
g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER;
g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain;

if (MONITOR.empty()) {
if (MONITOR.empty()) { //if the monitor string is empty we set all the empty monitors to the same wallpaper
for (auto& m : g_pHyprpaper->m_vMonitors) {
if (!m->hasATarget || m->wildcard) {
Debug::log(LOG, "Setting wallpaper for monitor %s", m->name);
g_pHyprpaper->clearWallpaperFromMonitor(m->name);
g_pHyprpaper->m_mMonitorActiveWallpapers[m->name] = WALLPAPER;
g_pHyprpaper->m_mMonitorWallpaperRenderData[m->name].contain = contain;
}
}
} else {
const auto PMON = g_pHyprpaper->getMonitorFromName(MONITOR);
if (PMON)
PMON->wildcard = false;
return result;
}

const auto PMON = g_pHyprpaper->getMonitorFromName(MONITOR);
if (!PMON){ //does monitor by name of MONITOR exist?
result.setError("wallpaper failed (no such monitor)");
return result;
}

g_pHyprpaper->clearWallpaperFromMonitor(MONITOR); //should be fine to keep using MONITOR instead of using PMON->name here
g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER;
g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain;

PMON->wildcard = false;
return result;
}

Expand Down

0 comments on commit dfd3d09

Please sign in to comment.