diff options
-rw-r--r-- | WindowServer/WSMessageLoop.cpp | 26 | ||||
-rw-r--r-- | WindowServer/WSScreen.cpp | 30 | ||||
-rw-r--r-- | WindowServer/WSScreen.h | 8 | ||||
-rw-r--r-- | WindowServer/WSWindowManager.cpp | 8 | ||||
-rw-r--r-- | WindowServer/WSWindowManager.h | 5 | ||||
-rw-r--r-- | WindowServer/main.cpp | 28 |
6 files changed, 47 insertions, 58 deletions
diff --git a/WindowServer/WSMessageLoop.cpp b/WindowServer/WSMessageLoop.cpp index b49dde17b5..df0ed7bf3f 100644 --- a/WindowServer/WSMessageLoop.cpp +++ b/WindowServer/WSMessageLoop.cpp @@ -1,18 +1,18 @@ -#include "WSMessageLoop.h" -#include "WSMessage.h" -#include "WSMessageReceiver.h" -#include "WSWindowManager.h" -#include "WSScreen.h" +#include <WindowServer/WSMessageLoop.h> +#include <WindowServer/WSMessage.h> +#include <WindowServer/WSMessageReceiver.h> +#include <WindowServer/WSWindowManager.h> +#include <WindowServer/WSScreen.h> #include <WindowServer/WSClientConnection.h> -#include <Kernel/KeyCode.h> #include <WindowServer/WSAPITypes.h> -#include <unistd.h> -#include <time.h> -#include <sys/socket.h> -#include <sys/select.h> -#include <fcntl.h> -#include <stdio.h> -#include <errno.h> +#include <Kernel/KeyCode.h> +#include <LibC/sys/socket.h> +#include <LibC/sys/select.h> +#include <LibC/unistd.h> +#include <LibC/time.h> +#include <LibC/fcntl.h> +#include <LibC/stdio.h> +#include <LibC/errno.h> //#define WSEVENTLOOP_DEBUG diff --git a/WindowServer/WSScreen.cpp b/WindowServer/WSScreen.cpp index e2e2ce7610..dbeeeca6b3 100644 --- a/WindowServer/WSScreen.cpp +++ b/WindowServer/WSScreen.cpp @@ -2,6 +2,10 @@ #include "WSMessageLoop.h" #include "WSMessage.h" #include "WSWindowManager.h" +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/mman.h> static WSScreen* s_the; @@ -11,15 +15,29 @@ WSScreen& WSScreen::the() return *s_the; } -WSScreen::WSScreen(RGBA32* framebuffer, unsigned width, unsigned height) - : m_framebuffer(framebuffer) - , m_width(width) +WSScreen::WSScreen(unsigned width, unsigned height) + : m_width(width) , m_height(height) { ASSERT(!s_the); s_the = this; m_cursor_location = rect().center(); + + m_framebuffer_fd = open("/dev/bxvga", O_RDWR); + ASSERT(m_framebuffer_fd >= 0); + + struct BXVGAResolution { + int width; + int height; + }; + BXVGAResolution resolution { (int)width, (int)height}; + int rc = ioctl(m_framebuffer_fd, 1985, (int)&resolution); + ASSERT(rc == 0); + + size_t framebuffer_size_in_bytes = resolution.width * resolution.height * sizeof(RGBA32) * 2; + m_framebuffer = (RGBA32*)mmap(nullptr, framebuffer_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebuffer_fd, 0); + ASSERT(m_framebuffer && m_framebuffer != (void*)-1); } WSScreen::~WSScreen() @@ -68,3 +86,9 @@ void WSScreen::on_receive_keyboard_data(KeyEvent kernel_event) message->m_alt = kernel_event.alt(); WSMessageLoop::the().post_message(&WSWindowManager::the(), move(message)); } + +void WSScreen::set_y_offset(int offset) +{ + int rc = ioctl(m_framebuffer_fd, 1982, offset); + ASSERT(rc == 0); +} diff --git a/WindowServer/WSScreen.h b/WindowServer/WSScreen.h index e9c41373e1..851a12fd95 100644 --- a/WindowServer/WSScreen.h +++ b/WindowServer/WSScreen.h @@ -7,7 +7,7 @@ class WSScreen { public: - WSScreen(RGBA32*, unsigned width, unsigned height); + WSScreen(unsigned width, unsigned height); ~WSScreen(); void set_resolution(int width, int height); @@ -21,6 +21,8 @@ public: Size size() const { return { width(), height() }; } Rect rect() const { return { 0, 0, width(), height() }; } + void set_y_offset(int); + Point cursor_location() const { return m_cursor_location; } bool left_mouse_button_pressed() const { return m_left_mouse_button_pressed; } bool right_mouse_button_pressed() const { return m_right_mouse_button_pressed; } @@ -28,14 +30,12 @@ public: void on_receive_mouse_data(int dx, int dy, bool left_button, bool right_button); void on_receive_keyboard_data(KeyEvent); -protected: - WSScreen(unsigned width, unsigned height); - private: RGBA32* m_framebuffer { nullptr }; int m_width { 0 }; int m_height { 0 }; + int m_framebuffer_fd { -1 }; Point m_cursor_location; bool m_left_mouse_button_pressed { false }; diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 665f747c97..811033437a 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -11,7 +11,6 @@ #include "WSMenuBar.h" #include "WSMenuItem.h" #include <WindowServer/WSClientConnection.h> -#include <sys/ioctl.h> #include <unistd.h> #include <stdio.h> #include <time.h> @@ -128,11 +127,8 @@ void WSWindowManager::flip_buffers() { swap(m_front_bitmap, m_back_bitmap); swap(m_front_painter, m_back_painter); - if (m_framebuffer_fd != -1) { - int new_y_offset = m_buffers_are_flipped ? 0 : m_screen_rect.height(); - int rc = ioctl(m_framebuffer_fd, 1982, new_y_offset); - ASSERT(rc == 0); - } + int new_y_offset = m_buffers_are_flipped ? 0 : m_screen_rect.height(); + WSScreen::the().set_y_offset(new_y_offset); m_buffers_are_flipped = !m_buffers_are_flipped; } diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index 08631f3b92..0ef8ec07eb 100644 --- a/WindowServer/WSWindowManager.h +++ b/WindowServer/WSWindowManager.h @@ -66,9 +66,6 @@ public: Color menu_selection_color() const { return m_menu_selection_color; } int menubar_menu_margin() const; - int framebuffer_fd() const { return m_framebuffer_fd; } - void set_framebuffer_fd(int fd) { m_framebuffer_fd = fd; } - private: void process_mouse_event(WSMouseEvent&); void handle_menu_mouse_event(WSMenu&, WSMouseEvent&); @@ -149,6 +146,4 @@ private: Color m_menu_selection_color; WeakPtr<WSMenuBar> m_current_menubar; WeakPtr<WSMenu> m_current_menu; - - int m_framebuffer_fd { -1 }; }; diff --git a/WindowServer/main.cpp b/WindowServer/main.cpp index f74ad07f76..2ffa3957f8 100644 --- a/WindowServer/main.cpp +++ b/WindowServer/main.cpp @@ -1,40 +1,14 @@ -#include <SharedGraphics/Font.h> #include <WindowServer/WSScreen.h> #include <WindowServer/WSWindowManager.h> #include <WindowServer/WSMessageLoop.h> -#include <WindowServer/WSWindow.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/ioctl.h> -#include <sys/mman.h> int main(int, char**) { - dbgprintf("WindowServer starting...\n"); WSMessageLoop loop; - - int bxvga_fd = open("/dev/bxvga", O_RDWR); - ASSERT(bxvga_fd >= 0); - - struct BXVGAResolution { - int width; - int height; - }; - BXVGAResolution resolution { 1024, 768 }; - int rc = ioctl(bxvga_fd, 1985, (int)&resolution); - ASSERT(rc == 0); - - size_t framebuffer_size_in_bytes = resolution.width * resolution.height * sizeof(RGBA32) * 2; - void* framebuffer = mmap(nullptr, framebuffer_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, bxvga_fd, 0); - ASSERT(framebuffer && framebuffer != (void*)-1); - - WSScreen screen((dword*)framebuffer, resolution.width, resolution.height); - + WSScreen screen(1024, 768); WSWindowManager window_manager; - window_manager.set_framebuffer_fd(bxvga_fd); dbgprintf("Entering WindowServer main loop.\n"); WSMessageLoop::the().exec(); - ASSERT_NOT_REACHED(); } |