summaryrefslogtreecommitdiffstats
path: root/src/detection/displayserver/displayserver_haiku.cpp
diff options
context:
space:
mode:
authorsumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
committersumuel <samuel@yakubos.org>2026-08-17 20:44:55 +0000
commit76424950e373d3b04ac3dd13019151bfba3e8423 (patch)
tree4c3cfdbda039e592b9186be3e28f8d7cfd439e8a /src/detection/displayserver/displayserver_haiku.cpp
Add the files
Diffstat (limited to 'src/detection/displayserver/displayserver_haiku.cpp')
-rw-r--r--src/detection/displayserver/displayserver_haiku.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/detection/displayserver/displayserver_haiku.cpp b/src/detection/displayserver/displayserver_haiku.cpp
new file mode 100644
index 0000000..c1ddaf6
--- /dev/null
+++ b/src/detection/displayserver/displayserver_haiku.cpp
@@ -0,0 +1,71 @@
+extern "C" {
+#include "displayserver.h"
+}
+
+#include <math.h>
+
+#include <Application.h>
+#include <Screen.h>
+
+extern "C" void ffConnectDisplayServerImpl(FFDisplayServerResult* ds);
+
+static void detectDisplays(FFDisplayServerResult* ds) {
+ // We need a valid be_app to query the app_server here.
+ BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
+ BScreen s{}; // default screen is the main one
+ bool main = true;
+
+ do {
+ if (!s.IsValid()) {
+ continue;
+ }
+
+ display_mode mode;
+ if (s.GetMode(&mode) != B_OK) {
+ continue;
+ }
+
+ FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateA(128);
+ monitor_info monitor;
+ // WARNING: This is experimental new Haiku API
+ status_t err = s.GetMonitorInfo(&monitor);
+ if (err == B_OK) {
+ ffStrbufSetF(&name, "%s %s", monitor.vendor, monitor.name);
+ ffStrbufTrimRightSpace(&name);
+ }
+
+ uint32_t width = (uint32_t) s.Frame().Width() + 1;
+ uint32_t height = (uint32_t) (uint32_t) s.Frame().Height() + 1;
+ FFDisplayResult* res = ffdsAppendDisplay(ds,
+ width,
+ height,
+ (double) mode.timing.pixel_clock * 1000 / (mode.timing.v_total * mode.timing.h_total),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ &name,
+ FF_DISPLAY_TYPE_UNKNOWN,
+ main,
+ (uint64_t) s.ID().id,
+ 0,
+ 0,
+ "BScreen");
+ if (err == B_OK) {
+ res->manufactureWeek = monitor.produced.week;
+ res->manufactureYear = monitor.produced.year;
+ }
+ main = false;
+ } while (s.SetToNext() == B_OK);
+
+ return;
+}
+
+void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) {
+ ffStrbufSetStatic(&ds->wmProcessName, "app_server");
+ ffStrbufSetStatic(&ds->wmPrettyName, "Application Server");
+ ffStrbufSetStatic(&ds->dePrettyName, "Application Kit");
+
+ detectDisplays(ds);
+}