summaryrefslogtreecommitdiff
path: root/gui-apps/wcm/files/wcm-0.11.0-workspace-backgrounds-budget.patch
blob: 5686404c61c86c4373c58ff0af7d4d25eedb4f0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- a/src/backgrounds.cpp
+++ b/src/backgrounds.cpp
@@ -43,7 +43,7 @@
     workspace.set_border_width(10); backdrop.set_border_width(10);
     tabs.append_page(workspace, "Workspace images"); tabs.append_page(backdrop, "Fixed backdrop");
     help.set_text("Each workspace has its own image. Transparent areas reveal the other cube faces, including while the cube is at rest. The fixed backdrop stays behind the cube. Selecting a workspace here does not switch your desktop.");
-    label_style(help); label_style(status); label_style(backdrop_help); label_style(backdrop_status);
+    label_style(help); label_style(status); label_style(memory); label_style(backdrop_help); label_style(backdrop_status);
     workspace.pack_start(help, false, false);
     outputs.get_accessible()->set_name("Background desktop output");
     selection.get_accessible()->set_name("Background workspace"); mode.get_accessible()->set_name("Workspace background layout");
@@ -53,6 +53,7 @@
     workspace.pack_start(mode, false, false); workspace.pack_start(editor, false, false);
     buttons.pack_start(reload, false, false); buttons.pack_start(all, false, false); buttons.pack_end(apply, false, false);
     workspace.pack_start(buttons, false, false); workspace.pack_start(status, false, false);
+    workspace.pack_start(memory, false, false);
     all.set_tooltip_text("Replace every workspace override on this output with the selected layout.");
     backdrop_help.set_text("This image remains behind the cube. Use rotation keeps the existing Wallhaven wallpaper service in control. Workspace backgrounds have a separate Apply button.");
     backdrop.pack_start(backdrop_help, false, false);
@@ -108,6 +109,7 @@
             try
             {
                 auto next = request("workspace-backgrounds/status");
+                show_memory(next);
                 if (next["completed_job"].get<uint64_t>() == pending_job)
                 {
                     pending_job = 0;
@@ -130,6 +132,14 @@
     }, 200);
 }
 BackgroundsPage::~BackgroundsPage() { timer.disconnect(); if (fixed_worker.valid()) fixed_worker.wait(); }
+void BackgroundsPage::show_memory(const json& renderer)
+{
+    const auto mib = 1024 * 1024;
+    auto used = renderer.value("texture_bytes", uint64_t(0));
+    auto limit = renderer.value("texture_budget", uint64_t(0));
+    memory.set_text("Image memory: " + std::to_string((used + mib - 1) / mib) + " / " +
+        std::to_string(limit / mib) + " MiB. Adjustable in Workspace backgrounds → Texture budget.");
+}
 void BackgroundsPage::refresh()
 {
     try
@@ -139,6 +149,7 @@
         if (std::filesystem::weakly_canonical(next["config_file"].get<std::string>()) != std::filesystem::weakly_canonical(config_file))
             throw std::runtime_error("Open WCM with the running session's configuration to edit workspace backgrounds");
         state = next; draft = original = state["settings"]; available = true;
+        show_memory(state);
         loading = true; outputs.remove_all();
         for (auto& output : state["outputs"]) outputs.append(output["name"].get<std::string>(), output["name"].get<std::string>());
         if (!outputs.set_active_id(selected_output) && !state["outputs"].empty()) outputs.set_active(0);
--- a/src/backgrounds.hpp
+++ b/src/backgrounds.hpp
@@ -10,7 +10,7 @@
     Gtk::Box workspace{Gtk::ORIENTATION_VERTICAL, 10}, backdrop{Gtk::ORIENTATION_VERTICAL, 10};
     Gtk::Box editor{Gtk::ORIENTATION_VERTICAL, 8}, backdrop_editor{Gtk::ORIENTATION_VERTICAL, 8};
     Gtk::Box buttons{Gtk::ORIENTATION_HORIZONTAL, 8}, backdrop_buttons{Gtk::ORIENTATION_HORIZONTAL, 8};
-    Gtk::Label help, status, backdrop_help, backdrop_status;
+    Gtk::Label help, status, memory, backdrop_help, backdrop_status;
     Gtk::ComboBoxText outputs, selection, mode, backdrop_mode, backdrop_sizing;
     Gtk::Button apply{"Apply workspace backgrounds"}, reload{"Revert workspace changes"}, all{"Copy to all workspaces"};
     Gtk::Button backdrop_apply{"Apply fixed backdrop"}, backdrop_reload{"Revert backdrop changes"};
@@ -22,6 +22,7 @@
     sigc::connection timer;
     static json request(const std::string& method, const json& data = json::object());
     void refresh();
+    void show_memory(const json& renderer);
     void select_output();
     void show_layout();
     json current_layout() const;