Compare commits

..

7 Commits

Author SHA1 Message Date
b2c642f03d Don't make SHM extension dependent option
This was here because I though banan-os didn't define them, but they do
exist there :^)
2026-04-15 19:23:34 +03:00
654e878165 Allow compiling with just xorgproto installed 2026-04-15 19:22:56 +03:00
5076d3bbaf Add missing sys/socket.h include 2026-04-15 18:53:45 +03:00
7be8edada7 Add child window id to its parent
I had accidentally removed this in b228ef13c4 and it broke all programs
that were using child windows :D
2026-04-15 18:43:03 +03:00
07f2b5dbb7 Add hacky way to die when WindowServer dies
We keep a dummy window around which will receive a close event that
exits once WindowServer dies :^)
2026-04-15 18:21:03 +03:00
a497e4267f Add README and LICENSE 2026-04-15 17:54:40 +03:00
7252c985b8 Add banan-os as a submodule instead of manually copying libraries 2026-04-15 17:54:31 +03:00
7 changed files with 155 additions and 86 deletions

View File

@@ -1,6 +1,6 @@
From 075f6a11926e247ba64efd25a3acf7a3d3be0bbc Mon Sep 17 00:00:00 2001
From c9dd87198ce5262e6ddf6bf3b0c18eb84784d35e Mon Sep 17 00:00:00 2001
From: Oskari Alaranta <oskari.alaranta@bananymous.com>
Date: Wed, 15 Apr 2026 16:51:16 +0300
Date: Wed, 15 Apr 2026 17:52:54 +0300
Subject: [PATCH] linux-window-server-sdl2
---
@@ -13,8 +13,8 @@ Subject: [PATCH] linux-window-server-sdl2
userspace/programs/WindowServer/Window.cpp | 29 +-
.../programs/WindowServer/WindowServer.cpp | 47 ++-
.../programs/WindowServer/WindowServer.h | 1 +
userspace/programs/WindowServer/main.cpp | 362 ++++++++++++------
10 files changed, 338 insertions(+), 173 deletions(-)
userspace/programs/WindowServer/main.cpp | 357 ++++++++++++------
10 files changed, 340 insertions(+), 166 deletions(-)
diff --git a/userspace/libraries/LibGUI/Widget/Widget.cpp b/userspace/libraries/LibGUI/Widget/Widget.cpp
index d6489d87..c532fb04 100644
@@ -376,7 +376,7 @@ index 94fbc774..bcd7a6b9 100644
private:
void on_mouse_move_impl(int32_t new_x, int32_t new_y);
diff --git a/userspace/programs/WindowServer/main.cpp b/userspace/programs/WindowServer/main.cpp
index 41bd7e8c..cb066bd3 100644
index 46f2ba6d..520c8e7d 100644
--- a/userspace/programs/WindowServer/main.cpp
+++ b/userspace/programs/WindowServer/main.cpp
@@ -10,7 +10,6 @@
@@ -425,7 +425,7 @@ index 41bd7e8c..cb066bd3 100644
signal(sig, exit);
for (int sig : non_terminating_signals)
signal(sig, SIG_DFL);
@@ -208,55 +202,10 @@ int main()
@@ -208,51 +202,15 @@ int main()
signal(sig, SIG_IGN);
MUST(LibInput::KeyboardLayout::initialize());
@@ -469,20 +469,18 @@ index 41bd7e8c..cb066bd3 100644
dprintln("Window server started");
- if (access("/usr/bin/xbanan", X_OK) == 0)
- {
- if (fork() == 0)
- {
+ if (access("./build/xbanan/xbanan", X_OK) == 0)
{
if (fork() == 0)
{
- dup2(STDDBG_FILENO, STDOUT_FILENO);
- dup2(STDDBG_FILENO, STDERR_FILENO);
- execl("/usr/bin/xbanan", "xbanan", NULL);
- exit(1);
- }
- }
-
auto config = parse_config();
WindowServer window_server(framebuffer, config.corner_radius);
@@ -276,26 +225,23 @@ int main()
+ execl("./build/xbanan/xbanan", "xbanan", NULL);
exit(1);
}
}
@@ -276,26 +234,23 @@ int main()
uint64_t last_sync_us = get_current_us() - sync_interval_us;
while (!window_server.is_stopped())
{
@@ -520,7 +518,7 @@ index 41bd7e8c..cb066bd3 100644
if (epoll_events == -1 && errno != EINTR)
{
dwarnln("epoll_pwait2: {}", strerror(errno));
@@ -333,48 +279,6 @@ int main()
@@ -333,48 +288,6 @@ int main()
continue;
}
@@ -569,7 +567,7 @@ index 41bd7e8c..cb066bd3 100644
const int client_fd = events[i].data.fd;
if (events[i].events & (EPOLLHUP | EPOLLERR))
{
@@ -500,3 +404,237 @@ int main()
@@ -500,3 +413,237 @@ int main()
}
}
}

24
LICENSE Normal file
View File

@@ -0,0 +1,24 @@
BSD 2-Clause License
Copyright (c) 2026, Oskari Alaranta
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

29
README.md Normal file
View File

@@ -0,0 +1,29 @@
# xbanan
An X11 compatibility layer for [banan-os's](https://git.bananymous.com/Bananymous/banan-os) native GUI windowing system.
## Running on linux
### Building
```sh
git clone --recursive https://git.bananymous.com/Bananymous/xbanan.git
cd xbanan
cd banan-os
git apply ../0001-linux-window-server-sdl2.patch
cd ..
cmake -B build -S . -G Ninja
cmake --build build
```
### Running
To start the WindowServer, run the following command in project root
```sh
./build/banan-os/userspace/programs/WindowServer/WindowServer
```
To run X11 apps specify `DISPLAY=:69` environment variable. For example
```sh
DISPLAY=:69 xeyes
```

View File

@@ -1400,6 +1400,8 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
if (event_mask != 0)
TRY(object_it->value->object.get<Object::Window>().event_masks.insert(&client_info, event_mask));
TRY(parent_window.children.push_back(request.wid));
if (gui_window_ptr)
{
const WINDOW wid = request.wid;

View File

@@ -12,12 +12,7 @@ set(SOURCES
)
option(ENABLE_GLX "enable glx extension" ON)
include(CheckSymbolExists)
include(CMakeDependentOption)
check_symbol_exists(shmat "sys/shm.h" HAVE_SHMAT)
check_symbol_exists(shmdt "sys/shm.h" HAVE_SHMDT)
cmake_dependent_option(ENABLE_SHM "enable shm extension" ON "HAVE_SHMAT;HAVE_SHMDT" OFF)
option(ENABLE_SHM "enable shm extension" ON)
if(ENABLE_GLX)
set(SOURCES ${SOURCES} ExtGLX.cpp)

View File

@@ -1,8 +1,8 @@
#include "Extensions.h"
#include "Utils.h"
#include <GL/glx.h>
#include <GL/glxproto.h>
#include <GL/glxtokens.h>
using BOOL32 = CARD32;
@@ -12,11 +12,11 @@ CARD32 g_fb_configs[2][24][2] {
{ GLX_VISUAL_ID, g_visual.visualID },
{ GLX_BUFFER_SIZE, 32 },
{ GLX_LEVEL, 0 },
{ GLX_DOUBLEBUFFER, True },
{ GLX_STEREO, False },
{ GLX_DOUBLEBUFFER, xTrue },
{ GLX_STEREO, xFalse },
{ GLX_RENDER_TYPE, GLX_RGBA_BIT },
{ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT },
{ GLX_X_RENDERABLE, True },
{ GLX_X_RENDERABLE, xTrue },
{ GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR },
{ GLX_CONFIG_CAVEAT, GLX_NONE },
{ GLX_TRANSPARENT_TYPE, GLX_NONE },
@@ -30,19 +30,19 @@ CARD32 g_fb_configs[2][24][2] {
{ GLX_ACCUM_GREEN_SIZE, 0 },
{ GLX_ACCUM_BLUE_SIZE, 0 },
{ GLX_ACCUM_ALPHA_SIZE, 0 },
{ GLX_SAMPLE_BUFFERS, 0 },
{ GLX_SAMPLES, 0 },
{ GLX_SAMPLE_BUFFERS_SGIS, 0 },
{ GLX_SAMPLES_SGIS, 0 },
},
{
{ GLX_FBCONFIG_ID, 2 },
{ GLX_VISUAL_ID, g_visual.visualID },
{ GLX_BUFFER_SIZE, 32 },
{ GLX_LEVEL, 0 },
{ GLX_DOUBLEBUFFER, False },
{ GLX_STEREO, False },
{ GLX_DOUBLEBUFFER, xFalse },
{ GLX_STEREO, xFalse },
{ GLX_RENDER_TYPE, GLX_RGBA_BIT },
{ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT },
{ GLX_X_RENDERABLE, True },
{ GLX_X_RENDERABLE, xTrue },
{ GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR },
{ GLX_CONFIG_CAVEAT, GLX_NONE },
{ GLX_TRANSPARENT_TYPE, GLX_NONE },
@@ -56,8 +56,8 @@ CARD32 g_fb_configs[2][24][2] {
{ GLX_ACCUM_GREEN_SIZE, 0 },
{ GLX_ACCUM_BLUE_SIZE, 0 },
{ GLX_ACCUM_ALPHA_SIZE, 0 },
{ GLX_SAMPLE_BUFFERS, 0 },
{ GLX_SAMPLES, 0 },
{ GLX_SAMPLE_BUFFERS_SGIS, 0 },
{ GLX_SAMPLES_SGIS, 0 },
},
};

View File

@@ -7,6 +7,7 @@
#include <signal.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -18,18 +19,19 @@
#include <netinet/in.h>
#endif
static const xRectangle s_screen_bounds =
static BAN::UniqPtr<LibGUI::Window> s_dummy_window =
[]() {
auto attributes = LibGUI::Window::default_attributes;
attributes.shown = false;
auto window = MUST(LibGUI::Window::create(0, 0, ""_sv, attributes));
return xRectangle {
return MUST(LibGUI::Window::create(0, 0, ""_sv, attributes));
}();
static const xRectangle s_screen_bounds = {
.x = 0,
.y = 0,
.width = static_cast<CARD16>(window->width()),
.height = static_cast<CARD16>(window->height()),
.width = static_cast<CARD16>(s_dummy_window->width()),
.height = static_cast<CARD16>(s_dummy_window->height()),
};
}();
const xPixmapFormat g_formats[6] {
{
@@ -172,12 +174,25 @@ int main()
return 1;
}
{
epoll_event event { .events = EPOLLIN, .data = { .ptr = nullptr } };
if (epoll_ctl(g_epoll_fd, EPOLL_CTL_ADD, server_sock, &event) == -1)
{
perror("xbanan: epoll_ctl");
return 1;
}
}
{
epoll_event event { .events = EPOLLIN, .data = { .ptr = (void*)1 } };
if (epoll_ctl(g_epoll_fd, EPOLL_CTL_ADD, s_dummy_window->server_fd(), &event) == -1)
{
perror("xbanan: epoll_ctl");
return 1;
}
s_dummy_window->request_resize(1, 1);
}
#define APPEND_ATOM(name) do { \
MUST(g_atoms_id_to_name.insert(name, #name##_sv.substring(3))); \
@@ -397,6 +412,12 @@ int main()
continue;
}
if (events[i].data.ptr == (void*)1)
{
s_dummy_window->poll_events();
continue;
}
auto it = g_epoll_thingies.find(events[i].data.fd);
if (it == g_epoll_thingies.end())
continue;