mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
WindowServer: Move video mode setup to WSScreen.
This commit is contained in:
parent
809266a9fb
commit
82768e7ac5
6 changed files with 47 additions and 58 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue