diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-12 00:52:19 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-12 00:52:19 +0100 |
commit | 133706d697b7e7441a7f4968b5a52dfc0323d34b (patch) | |
tree | e2af7b65b49ce66a9e003278a0508913f644c578 /Kernel | |
parent | bb31d961b4b7041ec1b748ce65f256df64e113de (diff) | |
download | serenity-133706d697b7e7441a7f4968b5a52dfc0323d34b.zip |
Add API's and plumbing for WindowServer clients to make menus.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Process.h | 8 | ||||
-rw-r--r-- | Kernel/ProcessGUI.cpp | 46 | ||||
-rw-r--r-- | Kernel/Syscall.cpp | 16 | ||||
-rw-r--r-- | Kernel/Syscall.h | 8 |
4 files changed, 78 insertions, 0 deletions
diff --git a/Kernel/Process.h b/Kernel/Process.h index 09741b84e2..b219cb6adb 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -230,6 +230,14 @@ public: int gui$get_window_rect(int window_id, GUI_Rect*); int gui$set_window_rect(int window_id, const GUI_Rect*); int gui$set_global_cursor_tracking_enabled(int window_id, bool enabled); + int gui$menubar_create(); + int gui$menubar_destroy(int menubar_id); + int gui$menubar_add_menu(int menubar_id, int menu_id); + int gui$menu_create(const char* name); + int gui$menu_destroy(int menu_id); + int gui$menu_add_separator(int menu_id); + int gui$menu_add_item(int menu_id, unsigned identifier, const char* text); + int gui$set_menubar(int menubar_id); DisplayInfo set_video_resolution(int width, int height); diff --git a/Kernel/ProcessGUI.cpp b/Kernel/ProcessGUI.cpp index 556a25199b..da4e35b736 100644 --- a/Kernel/ProcessGUI.cpp +++ b/Kernel/ProcessGUI.cpp @@ -6,6 +6,7 @@ #include <WindowServer/WSMessageLoop.h> #include <WindowServer/WSWindow.h> #include <WindowServer/WSWindowManager.h> +#include <WindowServer/WSMenuBar.h> #include <Kernel/BochsVGADevice.h> //#define LOG_GUI_SYSCALLS @@ -284,3 +285,48 @@ DisplayInfo Process::set_video_resolution(int width, int height) BochsVGADevice::the().set_resolution(width, height); return info; } + +int Process::gui$menubar_create() +{ + return WSWindowManager::the().api$menubar_create(); +} + +int Process::gui$menubar_destroy(int menubar_id) +{ + return WSWindowManager::the().api$menubar_destroy(menubar_id); +} + +int Process::gui$menubar_add_menu(int menubar_id, int menu_id) +{ + return WSWindowManager::the().api$menubar_add_menu(menubar_id, menu_id); +} + +int Process::gui$menu_create(const char* name) +{ + if (!validate_read_str(name)) + return -EFAULT; + return WSWindowManager::the().api$menu_create(String(name)); +} + +int Process::gui$menu_destroy(int menu_id) +{ + return WSWindowManager::the().api$menu_destroy(menu_id); +} + +int Process::gui$menu_add_separator(int menu_id) +{ + return WSWindowManager::the().api$menu_add_separator(menu_id); +} + +int Process::gui$menu_add_item(int menu_id, unsigned identifier, const char* text) +{ + if (!validate_read_str(text)) + return -EFAULT; + return WSWindowManager::the().api$menu_add_item(menu_id, identifier, String(text)); +} + +int Process::gui$set_menubar(int menubar_id) +{ + kprintf("gui$set_menubar %d\n", menubar_id); + return WSWindowManager::the().api$app_set_menubar(menubar_id); +} diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index a96a9de536..6f18495bfd 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -223,6 +223,22 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2, return current->sys$rmdir((const char*)arg1); case Syscall::SC_chmod: return current->sys$chmod((const char*)arg1, (mode_t)arg2); + case Syscall::SC_gui_menubar_create: + return current->gui$menubar_create(); + case Syscall::SC_gui_menubar_destroy: + return current->gui$menubar_destroy((int)arg1); + case Syscall::SC_gui_menubar_add_menu: + return current->gui$menubar_add_menu((int)arg1, (int)arg2); + case Syscall::SC_gui_menu_create: + return current->gui$menu_create((const char*)arg1); + case Syscall::SC_gui_menu_destroy: + return current->gui$menu_destroy((int)arg1); + case Syscall::SC_gui_menu_add_separator: + return current->gui$menu_add_separator((int)arg1); + case Syscall::SC_gui_menu_add_item: + return current->gui$menu_add_item((int)arg1, (unsigned)arg2, (const char*)arg3); + case Syscall::SC_gui_app_set_menubar: + return current->gui$set_menubar((int)arg1); default: kprintf("<%u> int0x80: Unknown function %u requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3); break; diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index 964426454d..2e54127879 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -85,6 +85,14 @@ __ENUMERATE_SYSCALL(rmdir) \ __ENUMERATE_SYSCALL(chmod) \ __ENUMERATE_SYSCALL(usleep) \ + __ENUMERATE_SYSCALL(gui_menubar_create) \ + __ENUMERATE_SYSCALL(gui_menubar_destroy) \ + __ENUMERATE_SYSCALL(gui_menubar_add_menu) \ + __ENUMERATE_SYSCALL(gui_menu_create) \ + __ENUMERATE_SYSCALL(gui_menu_destroy) \ + __ENUMERATE_SYSCALL(gui_menu_add_separator) \ + __ENUMERATE_SYSCALL(gui_menu_add_item) \ + __ENUMERATE_SYSCALL(gui_app_set_menubar) \ #ifdef SERENITY |