summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-07-04 21:08:42 +0200
committerRaindropsSys <contact@minteck.org>2023-07-04 21:08:42 +0200
commite51ee45b622859efa5b1f4bbfc4f25d06b0fdbda (patch)
tree3d33d299506c185fe9413ae543d63cdbc478a9d2
parenta400da01412861f9f710e38af65c87ac939ec09e (diff)
downloadkirinos-e51ee45b622859efa5b1f4bbfc4f25d06b0fdbda.tar.gz
kirinos-e51ee45b622859efa5b1f4bbfc4f25d06b0fdbda.tar.bz2
kirinos-e51ee45b622859efa5b1f4bbfc4f25d06b0fdbda.zip
Updated 6 files and added core/status/icons/window.svg (automated)
-rw-r--r--ROADMAP.md4
-rw-r--r--core/desktop/index.html2
-rw-r--r--core/desktop/wm.js35
-rw-r--r--core/launcher/index.html2
-rw-r--r--core/status/icons/window.svg1
-rw-r--r--core/status/index.html23
-rw-r--r--main.js4
7 files changed, 51 insertions, 20 deletions
diff --git a/ROADMAP.md b/ROADMAP.md
index 8e359a2..2c0ac13 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -5,9 +5,9 @@
* [ ] Desktop
* [x] <s>Window manager **- Raindrops**</s>
* [x] <s>Application menu **- Raindrops**</s>
- * [ ] Task bar **- Raindrops**
+ * [x] <s>Task bar **- Raindrops**</s>
* [ ] Media keys
- * [ ] Application switcher
+ * [ ] Application switcher **- Raindrops**
* [ ] Notifications
* [x] <s>Status bar **- Raindrops**</s>
* [x] <s>Power options **- Raindrops**</s>
diff --git a/core/desktop/index.html b/core/desktop/index.html
index 7719cce..e8e578b 100644
--- a/core/desktop/index.html
+++ b/core/desktop/index.html
@@ -413,7 +413,7 @@
let config = JSON.parse(fs.readFileSync(file + "/app.json").toString());
if (!fs.existsSync(file + "/index.html")) throw new Error("No index.html found");
- config['application'] = file;
+ config['application'] = name;
config['title'] = name;
config['sandbox'] = true;
config['isolatedPath'] = file;
diff --git a/core/desktop/wm.js b/core/desktop/wm.js
index c2bfcda..d4db82c 100644
--- a/core/desktop/wm.js
+++ b/core/desktop/wm.js
@@ -1,5 +1,4 @@
const uuid = require('uuid-v4');
-const { ipcRenderer } = require('electron');
const path = require("path");
const crypto = require("crypto");
@@ -37,6 +36,8 @@ class WindowManager {
index++;
}
+
+ document.getElementById("status").contentWindow.updateTitlebar();
}
getWindow(id) {
@@ -85,9 +86,6 @@ class WindowManager {
get maximizable() {
return properties[id]["maximizable"];
},
- get focused() {
- return properties[id]["focused"];
- },
get minimised() {
return properties[id]["minimised"];
},
@@ -236,7 +234,6 @@ class WindowManager {
maximizable: options['maximizable'] ?? true,
minimizable: options['minimizable'] ?? true,
debuggable: options['debuggable'] ?? false,
- focused: options['focused'] ?? true,
resizable: options['resizable'] ?? true,
minimised: options['minimised'] ?? false,
maximised: options['maximised'] ?? false
@@ -572,7 +569,7 @@ class WindowManager {
}
function stopResize() {
- document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
+ if (document.querySelector('#window-' + id + ' .window-contents-webview')) document.querySelector('#window-' + id + ' .window-contents-webview').style.pointerEvents = "";
window.removeEventListener('mousemove', resize)
}
}
@@ -582,6 +579,8 @@ class WindowManager {
i.#list.push(id);
i.#updateFocus();
+
+ res();
}
});
@@ -644,6 +643,8 @@ class WindowManager {
delete this.#properties[id];
this.#updateFocus();
+ document.getElementById("status").contentWindow.updateTitlebar();
+
// TODO: Broadcast a close event to the client
}
@@ -662,6 +663,8 @@ class WindowManager {
this.#updateFocus();
this.#properties[id].minimised = false;
+ document.getElementById("status").contentWindow.updateTitlebar();
+
// TODO: Broadcast an unminimise event to the client
}
@@ -670,7 +673,9 @@ class WindowManager {
document.getElementById("window-" + id).classList.add("window-minimised");
delete this.#stack[this.#stack.indexOf(id)];
this.#updateFocus();
- this.#properties[id].minimised = false;
+ this.#properties[id].minimised = true;
+
+ document.getElementById("status").contentWindow.updateTitlebar();
// TODO: Broadcast a minimise event to the client
}
@@ -679,10 +684,10 @@ class WindowManager {
if (!this.#properties[id].webContents) return;
document.getElementById("window-" + id + "-contents-webview").closeDevTools();
document.getElementById("window-" + id + "-contents-webview").openDevTools();
- ipcRenderer.send("blur");
}
focusWindow(id) {
+ if (document.getElementById("window-" + id).classList.contains("window-minimised")) wm.unminimiseWindow(id);
if (!document.getElementById("window-" + id).classList.contains("window-inactive")) return;
delete this.#stack[this.#stack.indexOf(id)];
this.#stack.unshift(id);
@@ -725,9 +730,19 @@ class WindowManager {
id,
title: win.title,
minimised: win.minimised,
- focused: wm.getWindow(id).focused,
- application: win.application ?? null
+ focused: !document.getElementById("window-" + id).classList.contains("window-inactive") && !document.getElementById("window-" + id).classList.contains("window-minimised"),
+ application: win.isolatedPath ?? null
}
});
}
+
+ taskbarAction(id) {
+ if (document.getElementById("window-" + id).classList.contains("window-minimised")) {
+ this.unminimiseWindow(id);
+ } else if (document.getElementById("window-" + id).classList.contains("window-inactive")) {
+ this.focusWindow(id);
+ } else if (this.#properties[id].minimizable) {
+ this.minimiseWindow(id);
+ }
+ }
} \ No newline at end of file
diff --git a/core/launcher/index.html b/core/launcher/index.html
index 233bfcb..a1c164a 100644
--- a/core/launcher/index.html
+++ b/core/launcher/index.html
@@ -111,7 +111,7 @@
<script>
function openAbout() {
parent.wm.createWindow({
- application: "system",
+ application: "(system)",
title: "About mangoOS",
sandbox: false,
frameless: true,
diff --git a/core/status/icons/window.svg b/core/status/icons/window.svg
new file mode 100644
index 0000000..e9c619c
--- /dev/null
+++ b/core/status/icons/window.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M180-120q-24.75 0-42.375-17.625T120-180v-600q0-24.75 17.625-42.375T180-840h600q24.75 0 42.375 17.625T840-780v600q0 24.75-17.625 42.375T780-120H180Zm0-60h600v-520H180v520Zm100-310v-60h390v60H280Zm0 160v-60h230v60H280Z"/></svg> \ No newline at end of file
diff --git a/core/status/index.html b/core/status/index.html
index e0094c8..aa9774c 100644
--- a/core/status/index.html
+++ b/core/status/index.html
@@ -33,6 +33,11 @@
.n {
font-family: "Roboto Mono", monospace;
}
+
+ #tasks-bar {
+ position: absolute;
+ margin-left: 10px;
+ }
</style>
</head>
<body>
@@ -52,9 +57,10 @@
<a onclick="parent.statusUpdate({ action: 'clickOn', item: 'menu' });" id="mango-menu" class="status-bar-clickable" style="height: 31px; display: inline-flex; align-items: center; justify-content: center; width: 31px;">
<img src="../../logo-symbolic.svg" style="width: 24px; pointer-events: none;">
</a>
+ <span id="tasks-bar"></span>
</div>
<div id="bar-right" style="margin-left: auto; display: inline-block; width: max-content; float: right; height: 100%;">
- <a onclick="prout(); parent.statusUpdate({ action: 'clickOn', item: 'volume' });" id="item-volume" class="status-bar-clickable" style="height: 31px; display: inline-flex; align-items: center; justify-content: center; width: 31px; vertical-align: middle;">
+ <a onclick="parent.statusUpdate({ action: 'clickOn', item: 'volume' });" id="item-volume" class="status-bar-clickable" style="height: 31px; display: inline-flex; align-items: center; justify-content: center; width: 31px; vertical-align: middle;">
<img id="item-volume-icon" src="" style="width: 24px; pointer-events: none; vertical-align: middle;">
</a><a onclick="parent.statusUpdate({ action: 'clickOn', item: 'network' });" id="item-network" class="status-bar-clickable" style="height: 31px; display: inline-flex; align-items: center; justify-content: center; width: 31px; vertical-align: middle;">
<img id="item-network-icon" src="" style="width: 24px; pointer-events: none; vertical-align: middle;">
@@ -150,15 +156,17 @@
let batteryInfo = await si.battery();
let battery = batteryInfo.percent;
let charging = batteryInfo.isCharging;
- let present = batteryInfo.hasBattery || batteryInfo.maxCapacity === 0 || batteryInfo.voltage === 0 || batteryInfo.designedCapacity === 0 || batteryInfo.capacityUnit === '';
+ let present = batteryInfo.hasBattery && batteryInfo.maxCapacity !== 0 && batteryInfo.voltage !== 0 && batteryInfo.designedCapacity !== 0 && batteryInfo.capacityUnit !== '';
let levelIcon = Math.floor(battery / 12.5);
let iconSuffix = charging ? "-charging" : "";
if (present) {
document.getElementById("item-battery-icon").src = "./icons/battery-" + levelIcon + iconSuffix + ".svg";
+ document.getElementById("item-battery").style.display = "inline-flex";
} else {
document.getElementById("item-battery-icon").src = "./icons/battery-error.svg";
+ document.getElementById("item-battery").style.display = "none";
}
let online = hasInternetAccess;
@@ -179,6 +187,17 @@
}
}
}, 1000);
+
+ function updateTitlebar() {
+ const fs = require('fs');
+
+ console.log(parent.wm.getTaskbarItems());
+ document.getElementById("tasks-bar").innerHTML = parent.wm.getTaskbarItems().map(i => `
+ <a onclick="parent.wm.taskbarAction('${i.id}');" id="item-${i.id}" class="status-bar-clickable" style="height: 30px; display: inline-flex; align-items: center; justify-content: center; width: 31px; vertical-align: middle;${i.focused ? 'border-bottom: 1px solid rgba(0, 0, 0, .25);' : 'padding-bottom: 1px;'}">
+ <img id="item-${i.id}-icon" src="${fs.existsSync(i.application + "/icon.png") ? i.application + "/icon.png" : "./icons/window.svg"}" style="${i.minimised ? 'opacity: .5;' : ''}border-radius: 999px; height: 24px; width: 24px; pointer-events: none; vertical-align: middle;">
+ </a>
+ `.trim()).join("");
+ }
</script>
</body>
</html> \ No newline at end of file
diff --git a/main.js b/main.js
index fa7d208..9a36226 100644
--- a/main.js
+++ b/main.js
@@ -24,10 +24,6 @@ const createWindow = () => {
mainWindow.maximize();
- ipcMain.on('blur', () => {
- mainWindow.blur();
- });
-
mainWindow.loadFile('./core/startup/index.html');
require("@electron/remote/main").enable(mainWindow.webContents);