|
|
|
|
@@ -941,7 +941,7 @@ static void on_window_focus_event(WINDOW wid, bool focused)
|
|
|
|
|
MUST(window.send_event(event, FocusChangeMask));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void send_key_button_pointer_event(WINDOW root_wid, BYTE detail, uint32_t event_mask, BYTE event_type)
|
|
|
|
|
static void send_key_button_pointer_event(WINDOW root_wid, BYTE detail, uint32_t event_mask, BYTE event_type, KeyButMask state)
|
|
|
|
|
{
|
|
|
|
|
int32_t root_x, root_y;
|
|
|
|
|
int32_t event_x, event_y;
|
|
|
|
|
@@ -986,12 +986,12 @@ static void send_key_button_pointer_event(WINDOW root_wid, BYTE detail, uint32_t
|
|
|
|
|
.time = static_cast<CARD32>(time(nullptr)),
|
|
|
|
|
.root = g_root.windowId,
|
|
|
|
|
.event = wid,
|
|
|
|
|
.child = child_wid,
|
|
|
|
|
.child = static_cast<CARD32>(child_wid == wid ? None : child_wid),
|
|
|
|
|
.rootX = static_cast<INT16>(root_x),
|
|
|
|
|
.rootY = static_cast<INT16>(root_y),
|
|
|
|
|
.eventX = static_cast<INT16>(event_x),
|
|
|
|
|
.eventY = static_cast<INT16>(event_y),
|
|
|
|
|
.state = static_cast<KeyButMask>(s_keymask | s_butmask),
|
|
|
|
|
.state = state,
|
|
|
|
|
.sameScreen = xTrue,
|
|
|
|
|
}
|
|
|
|
|
}};
|
|
|
|
|
@@ -1057,7 +1057,7 @@ static void on_mouse_move_event(WINDOW wid, int32_t x, int32_t y)
|
|
|
|
|
if (s_butmask & Button3Mask) event_mask |= Button3MotionMask;
|
|
|
|
|
if (s_butmask & Button4Mask) event_mask |= Button4MotionMask;
|
|
|
|
|
if (s_butmask & Button5Mask) event_mask |= Button5MotionMask;
|
|
|
|
|
send_key_button_pointer_event(wid, NotifyNormal, event_mask, MotionNotify);
|
|
|
|
|
send_key_button_pointer_event(wid, NotifyNormal, event_mask, MotionNotify, s_keymask | s_butmask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void on_mouse_button_event(WINDOW wid, uint8_t xbutton, bool pressed)
|
|
|
|
|
@@ -1072,6 +1072,8 @@ static void on_mouse_button_event(WINDOW wid, uint8_t xbutton, bool pressed)
|
|
|
|
|
case Button5: mask = Button5Mask; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto state = s_keymask | s_butmask;
|
|
|
|
|
|
|
|
|
|
if (pressed)
|
|
|
|
|
s_butmask |= mask;
|
|
|
|
|
else
|
|
|
|
|
@@ -1081,7 +1083,8 @@ static void on_mouse_button_event(WINDOW wid, uint8_t xbutton, bool pressed)
|
|
|
|
|
wid,
|
|
|
|
|
xbutton,
|
|
|
|
|
pressed ? ButtonPressMask : ButtonReleaseMask,
|
|
|
|
|
pressed ? ButtonPress : ButtonRelease
|
|
|
|
|
pressed ? ButtonPress : ButtonRelease,
|
|
|
|
|
state
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1103,6 +1106,8 @@ static void on_key_event(WINDOW wid, LibGUI::EventPacket::KeyEvent::event_t even
|
|
|
|
|
s_pressed_keys[byte] &= ~(1 << bit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto state = s_keymask | s_butmask;
|
|
|
|
|
|
|
|
|
|
s_keymask = 0;
|
|
|
|
|
if (event.shift())
|
|
|
|
|
s_keymask |= ShiftMask;
|
|
|
|
|
@@ -1117,7 +1122,8 @@ static void on_key_event(WINDOW wid, LibGUI::EventPacket::KeyEvent::event_t even
|
|
|
|
|
wid,
|
|
|
|
|
xkeycode,
|
|
|
|
|
event.pressed() ? KeyPressMask : KeyReleaseMask,
|
|
|
|
|
event.pressed() ? KeyPress : KeyRelease
|
|
|
|
|
event.pressed() ? KeyPress : KeyRelease,
|
|
|
|
|
state
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1275,6 +1281,37 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
dprintln(" visual: {}", request.visual);
|
|
|
|
|
dprintln(" mask: {8h}", request.mask);
|
|
|
|
|
|
|
|
|
|
auto& parent_window = TRY_REF(get_window(client_info, request.parent, opcode));
|
|
|
|
|
if (request.c_class == CopyFromParent)
|
|
|
|
|
request.c_class = parent_window.c_class;
|
|
|
|
|
|
|
|
|
|
if (request.depth == 0 && request.c_class == InputOutput)
|
|
|
|
|
request.depth = parent_window.depth;
|
|
|
|
|
|
|
|
|
|
bool valid_depth = false;
|
|
|
|
|
switch (request.c_class)
|
|
|
|
|
{
|
|
|
|
|
case InputOutput:
|
|
|
|
|
valid_depth = (request.depth == g_depth.depth);
|
|
|
|
|
break;
|
|
|
|
|
case InputOnly:
|
|
|
|
|
valid_depth = (request.depth == 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!valid_depth)
|
|
|
|
|
{
|
|
|
|
|
xError error {
|
|
|
|
|
.type = X_Error,
|
|
|
|
|
.errorCode = BadMatch,
|
|
|
|
|
.sequenceNumber = client_info.sequence,
|
|
|
|
|
.minorCode = 0,
|
|
|
|
|
.majorCode = opcode,
|
|
|
|
|
};
|
|
|
|
|
TRY(encode(client_info.output_buffer, error));
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t event_mask { 0 };
|
|
|
|
|
uint32_t background { 0x000000 };
|
|
|
|
|
CURSOR cursor_id = None;
|
|
|
|
|
@@ -1288,18 +1325,20 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
switch (i)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
dprintln(" background-pixmap: {8h}", value);
|
|
|
|
|
if (value == None || value == ParentRelative)
|
|
|
|
|
background = LibGUI::Texture::color_invisible;
|
|
|
|
|
else
|
|
|
|
|
dprintln(" {8h}: {8h}", 1 << i, value);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
dprintln(" background-pixel: {8h}", value);
|
|
|
|
|
background = value;
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
dprintln(" event-mask: {8h}", value);
|
|
|
|
|
event_mask = value;
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
dprintln(" cursor: {8h}", value);
|
|
|
|
|
cursor_id = value;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
@@ -1342,12 +1381,6 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
window = BAN::move(gui_window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto& parent_object = g_objects[request.parent];
|
|
|
|
|
ASSERT(parent_object->type == Object::Type::Window);
|
|
|
|
|
|
|
|
|
|
auto& parent_window = parent_object->object.get<Object::Window>();
|
|
|
|
|
TRY(parent_window.children.push_back(request.wid));
|
|
|
|
|
|
|
|
|
|
TRY(client_info.objects.insert(request.wid));
|
|
|
|
|
auto object_it = TRY(g_objects.insert(
|
|
|
|
|
request.wid,
|
|
|
|
|
@@ -1359,7 +1392,7 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
.y = request.y,
|
|
|
|
|
.parent = request.parent,
|
|
|
|
|
.cursor = cursor_id,
|
|
|
|
|
.c_class = request.c_class == CopyFromParent ? parent_window.c_class : request.c_class,
|
|
|
|
|
.c_class = request.c_class,
|
|
|
|
|
.window = BAN::move(window),
|
|
|
|
|
},
|
|
|
|
|
}))
|
|
|
|
|
@@ -1385,7 +1418,7 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
gui_window_ptr->set_mouse_move_event_callback([wid](auto event) {
|
|
|
|
|
on_mouse_move_event(wid, event.x, event.y);
|
|
|
|
|
});
|
|
|
|
|
gui_window_ptr->set_mouse_button_event_callback([&client_info, wid](auto event) {
|
|
|
|
|
gui_window_ptr->set_mouse_button_event_callback([wid](auto event) {
|
|
|
|
|
uint8_t xbutton = 0;
|
|
|
|
|
switch (event.button)
|
|
|
|
|
{
|
|
|
|
|
@@ -1429,8 +1462,8 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
auto request = decode<xChangeWindowAttributesReq>(packet).value();
|
|
|
|
|
|
|
|
|
|
dprintln("ChangeWindowAttributes");
|
|
|
|
|
dprintln(" window: {}", request.window);
|
|
|
|
|
dprintln(" valueMask: {8h}", request.valueMask);
|
|
|
|
|
dprintln(" window: {}", request.window);
|
|
|
|
|
dprintln(" valueMask: {8h}", request.valueMask);
|
|
|
|
|
|
|
|
|
|
auto& window = TRY_REF(get_window(client_info, request.window, opcode));
|
|
|
|
|
|
|
|
|
|
@@ -1446,21 +1479,23 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
|
|
|
|
switch (i)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
dprintln(" background-pixmap: {8h}", value);
|
|
|
|
|
if (value == None || value == ParentRelative)
|
|
|
|
|
background = LibGUI::Texture::color_invisible;
|
|
|
|
|
else
|
|
|
|
|
dprintln(" {8h}: {8h}", 1 << i, value);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
dprintln(" background-pixel: {8h}", value);
|
|
|
|
|
background = value;
|
|
|
|
|
break;
|
|
|
|
|
case 11:
|
|
|
|
|
dprintln(" event-mask: {8h}", value);
|
|
|
|
|
if (value != 0)
|
|
|
|
|
TRY(window.event_masks.emplace_or_assign(&client_info, value));
|
|
|
|
|
else
|
|
|
|
|
window.event_masks.remove(&client_info);
|
|
|
|
|
break;
|
|
|
|
|
case 14:
|
|
|
|
|
dprintln(" cursor: {8h}", value);
|
|
|
|
|
cursor_id = value;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
|