Compare commits

..

71 Commits

Author SHA1 Message Date
58cb1e763f
libui: Install the built library into the system root
All checks were successful
continuous-integration/drone/pr Build is passing
2023-08-22 13:36:47 +02:00
35d8075c4e
wind: Show memory usage in debug output 2023-08-22 13:36:47 +02:00
4462651138
wind: Handle ftruncate() and mmap() errors properly 2023-08-22 13:36:47 +02:00
686db5a1de
wind: Fix client references being out-of-date in windows when disconnecting other clients
Classic "keeping a pointer to an element inside a vector after the vector is updated" bug, ah yes.
2023-08-22 13:36:47 +02:00
550c93318c
taskbar: Wait for terminated child windows 2023-08-22 13:36:47 +02:00
55660511f7
wind: Add debug keybind 2023-08-22 13:36:47 +02:00
76ac39b3b4
wind+libos+libui: Handle interrupted reads properly 2023-08-22 13:36:47 +02:00
97305c0212
base: Actually add the start icon to source control 2023-08-22 13:36:47 +02:00
c54504bd22
libui: Add Buttons 2023-08-22 13:36:47 +02:00
c632112213
libui: Handle other mouse events 2023-08-22 13:36:47 +02:00
db2710099b
libui: Add aligned items using Containers, ImageWidget 2023-08-22 13:36:46 +02:00
042e154271
libui: Add VerticalLayout 2023-08-22 13:36:46 +02:00
2ea0a303b4
wind+libui+taskbar: Add GetScreenRect IPC, non-decorated windows, taskbar 2023-08-22 13:36:46 +02:00
da759d3b96
libui: Actually fill window backgrounds with the correct color 2023-08-22 13:36:46 +02:00
390d55243d
libui: Add basic widget and layout system =D 2023-08-22 13:36:46 +02:00
cac62db038
ui+wind: Send mouse move events through IPC 2023-08-22 13:36:46 +02:00
0e61c7b62d
wind+libui: Add protocol for window close requests 2023-08-22 13:36:46 +02:00
69bf171787
libos+libui+wind: Use uppercase for static struct IDs to avoid confusion with fields 2023-08-22 13:36:46 +02:00
46524ecc1d
libui+gclient: Add basic OOP wrappers around the IPC protocol 2023-08-22 13:36:46 +02:00
87f3922486
wind+gclient: Add SetWindowTitle and support shm buffers 2023-08-22 13:36:46 +02:00
ade6493fe6
gclient: Create two example windows 2023-08-22 13:36:45 +02:00
4a4e193559
wind: Handle CreateWindow IPC messages 2023-08-22 13:36:45 +02:00
7e4f4b91f8
libui: Add CreateWindow IPC message definitions 2023-08-22 13:36:45 +02:00
2bf0881fc1
libos: Add basic IPC message framework 2023-08-22 13:36:45 +02:00
180e9bd5b4
kernel: Fix poll syscall 2023-08-22 13:36:45 +02:00
886c393024
wind: Monitor data on client connections 2023-08-22 13:36:45 +02:00
4de29a09d2
kernel: Add POLLHUP and store it when a polled socket's peer disconnects 2023-08-22 13:36:45 +02:00
e1d7de2f21
libui: Add copyright/author text 2023-08-22 13:36:45 +02:00
7449f1a519
libos: Add copyright/author comments to LocalServer and LocalClient 2023-08-22 13:36:45 +02:00
688bd652dc
wind: Use init --user and pledge() 2023-08-22 13:36:45 +02:00
e679731a18
Update .gitignore 2023-08-22 13:36:44 +02:00
6727dc034a
libos: Remove some shared pointers and change them to owned/live on the stack 2023-08-22 13:36:44 +02:00
f31a90df16
wind: Spawn a new client process after startup
Also, create the socket after dropping privileges.
2023-08-22 13:36:44 +02:00
3686a25a76
apps: Add gclient 2023-08-22 13:36:44 +02:00
0871895cc5
libos: Add os::LocalClient 2023-08-22 13:36:44 +02:00
5085604aab
libui: Change 'into' to 'onto' 2023-08-22 13:36:44 +02:00
aa82c088a0
libui: Document ui::Font 2023-08-22 13:36:44 +02:00
ecd8c4c29c
libui+wind: Move some static variables inside functions 2023-08-22 13:36:44 +02:00
88141727a2
wind: Generate random windows on keypresses 2023-08-22 13:36:44 +02:00
bcf6bc3c97
wind: Make sure windows have a minimum size to fit the titlebar 2023-08-22 13:36:44 +02:00
3e6c9dbaa2
libui: Properly cut off the last drawn character if necessary 2023-08-22 13:36:43 +02:00
b1299aef9e
libui: Add Rect::contains(Rect) 2023-08-22 13:36:43 +02:00
594f42fdd6
libui: Render font characters properly with no spacing, matching the width calculations 2023-08-22 13:36:43 +02:00
45ff38f5e3
wind: Render an actual TGA mouse cursor 2023-08-22 13:36:43 +02:00
8b02bfebdb
wind: Add a close button to windows using a TGA icon 2023-08-22 13:36:43 +02:00
9382ec9eca
libui: Add support for TGA image loading 2023-08-22 13:36:43 +02:00
58f839927c
libui: Add an interface to fill a Canvas with an array of pixels 2023-08-22 13:36:43 +02:00
72704e445a
wind: Add window titlebars using ui::Font 2023-08-22 13:36:43 +02:00
7bc0f36661
libui: Add PSF font loading and rendering 2023-08-22 13:36:43 +02:00
c58f91c48d
libui: Add Color::GRAY 2023-08-22 13:36:43 +02:00
94f297a47f
libui: Rename Rect::absolute to normalized and add a new absolute function 2023-08-22 13:36:43 +02:00
00db974b97
libluna: Add assignment operators to Buffer 2023-08-22 13:36:42 +02:00
dc69f144ad
wind: Reorder drag sequence 2023-08-22 13:36:42 +02:00
714f6a90cc
libui: Add Rect::relative 2023-08-22 13:36:42 +02:00
9d412b7a32
libui: Remove redundant statement 2023-08-22 13:36:42 +02:00
62d56d31a3
libui: Add getters for separate color values 2023-08-22 13:36:42 +02:00
38912dce51
libui: Remove unnecessary stuff 2023-08-22 13:36:42 +02:00
eba2960df3
base: Remove startup items not necessary for GUI startup 2023-08-22 13:36:42 +02:00
54bfcfc8cb
libui+wind: (Draggable) windows 2023-08-22 13:36:42 +02:00
f02bf4bc95
wind: Create a local server object 2023-08-22 13:36:42 +02:00
7d35964c5c
libos: Add a new LocalServer class for local domain sockets 2023-08-22 13:36:42 +02:00
971e69ee8c
kernel: Support listening sockets in poll() 2023-08-22 13:36:41 +02:00
4b04ce1917
base: Start wind on startup instead of the shell 2023-08-22 13:36:41 +02:00
fa6534004a
wind: Add a simple display server skeleton using libui
No client functionality yet, but it's a start.
2023-08-22 13:36:41 +02:00
995aa97a58
libui: Add a GUI and graphics library 2023-08-22 13:36:41 +02:00
b4d9363302
kernel: Fix negative movement in the PS/2 mouse driver 2023-08-22 13:36:41 +02:00
e5905a33e1
init: Stop using the removed 'signal' pledge
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-22 13:36:33 +02:00
993e94cc76
kernel: Remove the 'signal' promise and make signal functions require stdio instead
Some checks failed
continuous-integration/drone/push Build is failing
This follows OpenBSD and makes it so stdio is sufficient for an abort() call.
2023-08-22 13:34:30 +02:00
746834e2d9
kernel: Silently ignore TTY writes in graphical mode
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-22 13:31:31 +02:00
ce3542e2bd
apps+base: Remove many legacy test apps
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-22 13:29:52 +02:00
e72bc55c6f tools: Maybe, this finally works for CI...
All checks were successful
continuous-integration/drone/push Build is passing
2023-08-22 10:19:17 +00:00
13 changed files with 6 additions and 350 deletions

View File

@ -28,8 +28,6 @@ luna_app(stat.cpp stat)
luna_app(uname.cpp uname) luna_app(uname.cpp uname)
luna_app(base64.cpp base64) luna_app(base64.cpp base64)
luna_app(login.cpp login) luna_app(login.cpp login)
luna_app(ipc-test.cpp ipc-test)
luna_app(signal-test.cpp signal-test)
luna_app(mount.cpp mount) luna_app(mount.cpp mount)
luna_app(umount.cpp umount) luna_app(umount.cpp umount)
luna_app(ps.cpp ps) luna_app(ps.cpp ps)
@ -41,11 +39,6 @@ luna_app(pivot_root.cpp pivot_root)
luna_app(cp.cpp cp) luna_app(cp.cpp cp)
luna_app(kill.cpp kill) luna_app(kill.cpp kill)
luna_app(gol.cpp gol) luna_app(gol.cpp gol)
luna_app(buffer-test.cpp buffer-test)
luna_app(socket-test.cpp socket-test)
luna_app(socket-client.cpp socket-client)
luna_app(input.cpp input)
luna_app(shmem-test.cpp shmem-test)
luna_app(touch.cpp touch) luna_app(touch.cpp touch)
luna_app(free.cpp free) luna_app(free.cpp free)
luna_app(gclient.cpp gclient) luna_app(gclient.cpp gclient)

View File

@ -1,27 +0,0 @@
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
fprintf(stderr, "Writing incomplete line to stdout (_IOLBF=%d)...\n", stdout->_buf.mode);
fputs("hi!", stdout);
sleep(3);
putchar('\n');
fprintf(stderr, "Incomplete line should have been written.\n");
FILE* f = fopen("/dev/console", "w+");
assert(f);
assert(setvbuf(f, NULL, _IOFBF, 0) == 0);
fprintf(stderr, "Writing long text to file (_IOFBF=%d)...\n", f->_buf.mode);
fputs("Hello world!\nHow are you doing!\nThis is a test for many lines of buffering.\n", f);
sleep(3);
fflush(f);
fprintf(stderr, "Long text should have been written.\n");
fclose(f);
}

View File

@ -339,7 +339,7 @@ Result<int> sysinit()
stdout = fopen("/dev/console", "w"); stdout = fopen("/dev/console", "w");
stderr = fopen("/dev/console", "w"); stderr = fopen("/dev/console", "w");
TRY(os::Security::pledge("stdio rpath wpath cpath fattr host mount proc exec signal id", nullptr)); TRY(os::Security::pledge("stdio rpath wpath cpath fattr host mount proc exec id", nullptr));
mount_tmpfs(); mount_tmpfs();
mount_shmfs(); mount_shmfs();

View File

@ -1,69 +0,0 @@
#include <errno.h>
#include <luna/String.h>
#include <moon/Keyboard.h>
#include <moon/Mouse.h>
#include <os/File.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <unistd.h>
Result<void> process_mouse_packet(const moon::MousePacket& packet)
{
bool right = packet.buttons & moon::MouseButton::Right;
bool left = packet.buttons & moon::MouseButton::Left;
bool middle = packet.buttons & moon::MouseButton::Middle;
Vector<StringView> buttons;
if (right) TRY(buttons.try_append("RIGHT"_sv));
if (left) TRY(buttons.try_append("LEFT"_sv));
if (middle) TRY(buttons.try_append("MIDDLE"_sv));
String button_string;
if (!buttons.size()) button_string = TRY(String::from_cstring("NONE"));
else
button_string = TRY(String::join(buttons, " | "_sv));
os::println("Mouse packet: xdelta=%d, ydelta=%d, buttons=(%s)", packet.xdelta, packet.ydelta,
button_string.chars());
return {};
}
Result<int> luna_main(int, char**)
{
auto mouse = TRY(os::File::open("/dev/mouse", os::File::ReadOnly));
mouse->set_buffer(os::File::NotBuffered);
auto keyboard = TRY(os::File::open("/dev/kbd", os::File::ReadOnly));
keyboard->set_buffer(os::File::NotBuffered);
ioctl(STDIN_FILENO, TTYSETGFX, 1);
while (1)
{
struct pollfd fds[] = {
{ .fd = mouse->fd(), .events = POLLIN, .revents = 0 },
{ .fd = keyboard->fd(), .events = POLLIN, .revents = 0 },
};
int rc = poll(fds, 2, 1000);
if (!rc) continue;
if (rc < 0) { os::println("poll: error: %s", strerror(errno)); }
if (fds[0].revents & POLLIN)
{
moon::MousePacket packet;
TRY(mouse->read_typed(packet));
TRY(process_mouse_packet(packet));
}
if (fds[1].revents & POLLIN)
{
moon::KeyboardPacket packet;
TRY(keyboard->read_typed(packet));
os::println("Keyboard packet: %s key %u", packet.released ? "released" : "pressed", packet.key);
}
}
return 0;
}

View File

@ -1,45 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
int main()
{
int pfds[2];
if (pipe(pfds) < 0)
{
perror("pipe");
return 1;
}
pid_t child = fork();
if (child == 0)
{
close(pfds[1]);
char buffer[4096];
size_t nread = read(pfds[0], buffer, sizeof(buffer) - 1);
buffer[nread] = 0;
close(pfds[0]);
puts(buffer);
return 0;
}
else if (child == -1)
{
perror("fork");
return 1;
}
close(pfds[0]);
const char* string = "Hello from a child process who just received this message from its parent!";
write(pfds[1], string, strlen(string));
close(pfds[1]);
wait(NULL);
return 0;
}

View File

@ -1,50 +0,0 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <unistd.h>
int main()
{
pledge("stdio rpath wpath cpath proc", nullptr);
int fd = shm_open("/shared", O_CREAT | O_RDWR, 0666);
if (fd < 0)
{
perror("shm_open");
return 1;
}
ftruncate(fd, PAGE_SIZE);
void* address = mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (address == MAP_FAILED)
{
perror("mmap");
return 1;
}
char* ptr = (char*)address;
printf("the value is %c\n", *ptr);
*ptr = 'a';
pid_t child = fork();
if (child < 0)
{
perror("fork");
return 1;
}
if (child == 0)
{
*ptr = 'e';
_exit(0);
}
waitpid(child, NULL, 0);
printf("the value is %c\n", *ptr);
return 0;
}

View File

@ -1,23 +0,0 @@
#include <signal.h>
#include <stdio.h>
#include <string.h>
void handler(int)
{
puts("I caught a segfault!");
}
int main()
{
struct sigaction sa;
sa.sa_handler = handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
sigaction(SIGSEGV, &sa, NULL);
#pragma GCC diagnostic ignored "-Wnonnull"
char* str = nullptr;
memset(str, 0, 2);
return 0;
}

View File

@ -1,48 +0,0 @@
#include <os/ArgumentParser.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
Result<int> luna_main(int argc, char** argv)
{
StringView message;
os::ArgumentParser parser;
parser.add_description("A UNIX domain socket client, to test said sockets.");
parser.add_system_program_info("socket-client"_sv);
parser.add_positional_argument(message, "message"_sv, "exit"_sv);
parser.parse(argc, argv);
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0)
{
perror("socket");
return 0;
}
struct sockaddr_un un;
un.sun_family = AF_UNIX;
strncpy(un.sun_path, "/tmp/local.sock", sizeof(un.sun_path));
if (connect(sockfd, (struct sockaddr*)&un, sizeof(un)) < 0)
{
perror("connect");
return 1;
}
char buf[4096];
ssize_t nread = read(sockfd, buf, sizeof(buf) - 1);
if (nread > 0)
{
buf[nread] = 0;
printf("Message from server: %s\n", buf);
}
write(sockfd, message.chars(), message.length());
close(sockfd);
return 0;
}

View File

@ -1,75 +0,0 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <unistd.h>
int main()
{
setgid(1000);
setuid(1000);
remove("/tmp/local.sock");
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0)
{
perror("socket");
return 0;
}
struct sockaddr_un un;
un.sun_family = AF_UNIX;
strncpy(un.sun_path, "/tmp/local.sock", sizeof(un.sun_path));
if (bind(sockfd, (struct sockaddr*)&un, sizeof(un)) < 0)
{
perror("bind");
return 1;
}
if (listen(sockfd, 10) < 0)
{
perror("listen");
return 1;
}
while (1)
{
int fd = accept(sockfd, NULL, NULL);
if (fd < 0)
{
perror("accept");
return 1;
}
puts("New connection from client, sending hello");
const char* message = "Hello, client!";
write(fd, message, strlen(message));
puts("Now waiting for client to message back");
char buf[4096];
ssize_t nread = read(fd, buf, sizeof(buf) - 1);
if (nread >= 0)
{
buf[nread] = 0;
printf("Message from client: %s\n", buf);
if (!strcasecmp(buf, "exit"))
{
close(fd);
close(sockfd);
remove("/tmp/local.sock");
return 0;
}
}
else { printf("Error reading from client: %s\n", strerror(errno)); }
puts("Transmission ended, closing connection");
close(fd);
}
}

View File

@ -4,7 +4,7 @@
#define enumerate_promises(_p) \ #define enumerate_promises(_p) \
_p(stdio) _p(rpath) _p(wpath) _p(cpath) _p(fattr) _p(chown) _p(unix) _p(tty) _p(proc) _p(exec) _p(prot_exec) \ _p(stdio) _p(rpath) _p(wpath) _p(cpath) _p(fattr) _p(chown) _p(unix) _p(tty) _p(proc) _p(exec) _p(prot_exec) \
_p(id) _p(mount) _p(signal) _p(host) _p(error) _p(id) _p(mount) _p(host) _p(error)
enum class Promise enum class Promise
{ {

View File

@ -63,7 +63,7 @@ Result<usize> ConsoleDevice::write(const u8* buf, usize, usize length)
{ {
if (m_settings.c_lflag & TOSTOP) TRY(handle_background_process_group(true, SIGTTOU)); if (m_settings.c_lflag & TOSTOP) TRY(handle_background_process_group(true, SIGTTOU));
// if (s_is_in_graphical_mode) return length; if (s_is_in_graphical_mode) return length;
TextConsole::write((const char*)buf, length); TextConsole::write((const char*)buf, length);
return length; return length;

View File

@ -19,7 +19,7 @@ Result<u64> sys_sigreturn(Registers* regs, SyscallArgs)
Result<u64> sys_sigaction(Registers*, SyscallArgs args) Result<u64> sys_sigaction(Registers*, SyscallArgs args)
{ {
auto* current = Scheduler::current(); auto* current = Scheduler::current();
TRY(check_pledge(current, Promise::p_signal)); TRY(check_pledge(current, Promise::p_stdio));
int signo = (int)args[0]; int signo = (int)args[0];
const struct sigaction* act = (const struct sigaction*)args[1]; const struct sigaction* act = (const struct sigaction*)args[1];
@ -71,7 +71,7 @@ Result<u64> sys_kill(Registers*, SyscallArgs args)
Result<u64> sys_sigprocmask(Registers*, SyscallArgs args) Result<u64> sys_sigprocmask(Registers*, SyscallArgs args)
{ {
auto* current = Scheduler::current(); auto* current = Scheduler::current();
TRY(check_pledge(current, Promise::p_signal)); TRY(check_pledge(current, Promise::p_stdio));
int how = (int)args[0]; int how = (int)args[0];
const sigset_t* set = (const sigset_t*)args[1]; const sigset_t* set = (const sigset_t*)args[1];

View File

@ -68,4 +68,4 @@ cmake -S $LUNA_ROOT -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
cmake --build $LUNA_BUILD_DIR --target libc cmake --build $LUNA_BUILD_DIR --target libc
make all-target-libstdc++-v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc) make all-target-libstdc++-v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc)
make DESTDIR=$LUNA_BASE/usr install-target-libstdc++-v3 make install-target-libstdc++-v3