wind+libui+taskbar: Add a request for setting special window attributes
This lets the taskbar window stay unfocused even when it's clicked.
This commit is contained in:
parent
9bb66716a4
commit
02f8102d38
@ -60,6 +60,7 @@ Result<int> luna_main(int, char**)
|
||||
app.set_main_window(window);
|
||||
|
||||
window->set_background(TASKBAR_COLOR);
|
||||
window->set_special_attributes(ui::UNFOCUSEABLE);
|
||||
|
||||
ui::HorizontalLayout layout(ui::Margins { 0, 0, 0, 0 }, ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
||||
window->set_main_widget(layout);
|
||||
|
@ -54,6 +54,8 @@ namespace ui
|
||||
|
||||
void close();
|
||||
|
||||
void set_special_attributes(WindowAttributes attributes);
|
||||
|
||||
Result<void> draw();
|
||||
Result<ui::EventResult> handle_mouse_leave();
|
||||
Result<ui::EventResult> handle_mouse_move(ui::Point position);
|
||||
|
@ -80,4 +80,17 @@ namespace ui
|
||||
int window;
|
||||
int height;
|
||||
};
|
||||
|
||||
enum WindowAttributes : u8
|
||||
{
|
||||
UNFOCUSEABLE = 1,
|
||||
};
|
||||
|
||||
struct SetSpecialWindowAttributesRequest
|
||||
{
|
||||
static constexpr u8 ID = SET_SPECIAL_WINDOW_ATTRIBUTES_ID;
|
||||
|
||||
int window;
|
||||
WindowAttributes attributes;
|
||||
};
|
||||
}
|
||||
|
@ -117,6 +117,14 @@ namespace ui
|
||||
app.unregister_window(this, {});
|
||||
}
|
||||
|
||||
void Window::set_special_attributes(WindowAttributes attributes)
|
||||
{
|
||||
ui::SetSpecialWindowAttributesRequest request;
|
||||
request.window = m_id;
|
||||
request.attributes = attributes;
|
||||
App::the().client().send_async(request);
|
||||
}
|
||||
|
||||
Result<void> Window::draw()
|
||||
{
|
||||
if (m_background.has_value()) m_window_canvas.fill(*m_background);
|
||||
|
@ -8,6 +8,7 @@ struct Client
|
||||
OwnedPtr<os::IPC::ClientConnection> conn;
|
||||
Vector<Window*> windows;
|
||||
const bool privileged { false };
|
||||
bool should_be_disconnected { false };
|
||||
|
||||
Client(OwnedPtr<os::IPC::ClientConnection>&& client, bool priv)
|
||||
#ifdef CLIENT_IMPLEMENTATION
|
||||
|
21
wind/IPC.cpp
21
wind/IPC.cpp
@ -160,6 +160,26 @@ static Result<void> handle_set_titlebar_height_message(Client& client)
|
||||
return {};
|
||||
}
|
||||
|
||||
static Result<void> handle_set_special_window_attributes_message(Client& client)
|
||||
{
|
||||
ui::SetSpecialWindowAttributesRequest request;
|
||||
if (!TRY(client.conn->read_message(request))) return {};
|
||||
|
||||
if (!client.privileged)
|
||||
{
|
||||
os::eprintln(
|
||||
"wind: Unprivileged client trying to call privileged request (SetSpecialWindowAttributes), disconnecting!");
|
||||
client.should_be_disconnected = true;
|
||||
return {};
|
||||
}
|
||||
|
||||
CHECK_WINDOW_ID(request);
|
||||
|
||||
client.windows[request.window]->attributes = request.attributes;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
namespace wind
|
||||
{
|
||||
void handle_ipc_message(os::IPC::ClientConnection&, u8 id, void* c)
|
||||
@ -174,6 +194,7 @@ namespace wind
|
||||
case ui::CLOSE_WINDOW_ID: handle_close_window_message(client); break;
|
||||
case ui::GET_SCREEN_RECT_ID: handle_get_screen_rect_message(client); break;
|
||||
case ui::SET_TITLEBAR_HEIGHT_ID: handle_set_titlebar_height_message(client); break;
|
||||
case ui::SET_SPECIAL_WINDOW_ATTRIBUTES_ID: handle_set_special_window_attributes_message(client); break;
|
||||
default: os::eprintln("wind: Invalid IPC message from client!"); return;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void Mouse::update(const moon::MousePacket& packet)
|
||||
{
|
||||
if (window->surface.contains(m_position))
|
||||
{
|
||||
window->focus();
|
||||
if (!(window->attributes & ui::UNFOCUSEABLE)) window->focus();
|
||||
|
||||
if (window->surface.absolute(window->titlebar).contains(m_position))
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ struct Window : public LinkedListNode<Window>
|
||||
bool dirty { false };
|
||||
Client* client;
|
||||
int id;
|
||||
ui::WindowAttributes attributes { 0 };
|
||||
|
||||
Window(ui::Rect, String&&);
|
||||
~Window();
|
||||
|
@ -183,7 +183,8 @@ Result<int> luna_main(int argc, char** argv)
|
||||
for (usize i = 0; i < clients.size(); i++)
|
||||
{
|
||||
if (fds[i + 4].revents & POLLIN) clients[i]->conn->check_for_messages();
|
||||
if (fds[i + 4].revents & POLLHUP)
|
||||
if (fds[i + 4].revents & POLLHUP) clients[i]->should_be_disconnected = true;
|
||||
if (clients[i]->should_be_disconnected)
|
||||
{
|
||||
os::println("wind: Client %d disconnected", i);
|
||||
fds.remove_at(i + 4);
|
||||
|
Loading…
Reference in New Issue
Block a user