Cleanup extensions
This commit is contained in:
parent
6124525439
commit
24baab2e84
|
|
@ -3073,6 +3073,8 @@ BAN::ErrorOr<void> handle_packet(Client& client_info, BAN::ConstByteSpan packet)
|
||||||
continue;
|
continue;
|
||||||
reply.present = xTrue;
|
reply.present = xTrue;
|
||||||
reply.major_opcode = extension.major_opcode;
|
reply.major_opcode = extension.major_opcode;
|
||||||
|
reply.first_event = extension.event_base;
|
||||||
|
reply.first_error = extension.error_base;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
Base.cpp
|
Base.cpp
|
||||||
Extensions.cpp
|
Extensions.cpp
|
||||||
|
ExtBigReg.cpp
|
||||||
ExtRANDR.cpp
|
ExtRANDR.cpp
|
||||||
Keymap.cpp
|
Keymap.cpp
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "Extensions.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#include <X11/X.h>
|
||||||
|
#include <X11/extensions/bigreqsproto.h>
|
||||||
|
|
||||||
|
BAN::ErrorOr<void> extension_bigrequests(Client& client_info, BAN::ConstByteSpan packet)
|
||||||
|
{
|
||||||
|
switch (packet[1])
|
||||||
|
{
|
||||||
|
case X_BigReqEnable:
|
||||||
|
{
|
||||||
|
xGenericReply reply {
|
||||||
|
.type = X_Reply,
|
||||||
|
.sequenceNumber = client_info.sequence,
|
||||||
|
.length = 0,
|
||||||
|
.data00 = (16 << 20) / 4, // 16 MiB
|
||||||
|
};
|
||||||
|
TRY(encode(client_info.output_buffer, reply));
|
||||||
|
|
||||||
|
client_info.has_bigrequests = true;
|
||||||
|
|
||||||
|
dprintln("client enabled big requests");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
dwarnln("invalid BIG-REQUESTS minor opcode {}", packet[1]);
|
||||||
|
return BAN::Error::from_errno(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct BigRegInstaller
|
||||||
|
{
|
||||||
|
BigRegInstaller()
|
||||||
|
{
|
||||||
|
install_extension(XBigReqExtensionName, XBigReqNumberEvents, XBigReqNumberErrors, extension_bigrequests);
|
||||||
|
}
|
||||||
|
} installer;
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Extensions.h"
|
#include "Extensions.h"
|
||||||
#include "ExtRANDR.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
|
|
@ -7,15 +6,7 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
static struct RANDRInstaller
|
static BAN::ErrorOr<void> extension_randr(Client& client_info, BAN::ConstByteSpan packet)
|
||||||
{
|
|
||||||
RANDRInstaller()
|
|
||||||
{
|
|
||||||
install_extension(RANDR_NAME, extension_randr);
|
|
||||||
}
|
|
||||||
} installer;
|
|
||||||
|
|
||||||
BAN::ErrorOr<void> extension_randr(Client& client_info, BAN::ConstByteSpan packet)
|
|
||||||
{
|
{
|
||||||
static CARD32 crtc_id = 5;
|
static CARD32 crtc_id = 5;
|
||||||
static CARD32 output_id = 6;
|
static CARD32 output_id = 6;
|
||||||
|
|
@ -479,3 +470,11 @@ BAN::ErrorOr<void> extension_randr(Client& client_info, BAN::ConstByteSpan packe
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct RANDRInstaller
|
||||||
|
{
|
||||||
|
RANDRInstaller()
|
||||||
|
{
|
||||||
|
install_extension(RANDR_NAME, RRNumberEvents, RRNumberErrors, extension_randr);
|
||||||
|
}
|
||||||
|
} installer;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Definitions.h"
|
|
||||||
|
|
||||||
BAN::ErrorOr<void> extension_randr(Client& client_info, BAN::ConstByteSpan packet);
|
|
||||||
|
|
@ -1,14 +1,23 @@
|
||||||
#include "Extensions.h"
|
#include "Extensions.h"
|
||||||
|
|
||||||
|
#include <X11/X.h>
|
||||||
|
|
||||||
static uint8_t g_extension_opcode { 128 };
|
static uint8_t g_extension_opcode { 128 };
|
||||||
|
static uint8_t g_extension_event_base { LASTEvent };
|
||||||
|
static uint8_t g_extension_error_base { FirstExtensionError };
|
||||||
|
|
||||||
BAN::Array<Extension, 128> g_extensions;
|
BAN::Array<Extension, 128> g_extensions;
|
||||||
|
|
||||||
void install_extension(BAN::StringView name, BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan))
|
void install_extension(BAN::StringView name, uint8_t event_count, uint8_t error_count, BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan))
|
||||||
{
|
{
|
||||||
g_extensions[g_extension_opcode - 128] = {
|
g_extensions[g_extension_opcode - 128] = {
|
||||||
.name = name,
|
.name = name,
|
||||||
.major_opcode = g_extension_opcode,
|
.major_opcode = g_extension_opcode,
|
||||||
|
.event_base = g_extension_event_base,
|
||||||
|
.error_base = g_extension_error_base,
|
||||||
.handler = handler,
|
.handler = handler,
|
||||||
};
|
};
|
||||||
g_extension_opcode++;
|
g_extension_opcode++;
|
||||||
|
g_extension_event_base += event_count;
|
||||||
|
g_extension_error_base += error_count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ struct Extension
|
||||||
{
|
{
|
||||||
BAN::StringView name;
|
BAN::StringView name;
|
||||||
uint8_t major_opcode;
|
uint8_t major_opcode;
|
||||||
uint8_t opcode_count;
|
uint8_t event_base;
|
||||||
|
uint8_t error_base;
|
||||||
BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan);
|
BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan);
|
||||||
};
|
};
|
||||||
|
|
||||||
void install_extension(BAN::StringView name, BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan));
|
void install_extension(BAN::StringView name, uint8_t event_count, uint8_t error_count, BAN::ErrorOr<void> (*handler)(Client&, BAN::ConstByteSpan));
|
||||||
|
|
||||||
extern BAN::Array<Extension, 128> g_extensions;
|
extern BAN::Array<Extension, 128> g_extensions;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "Definitions.h"
|
#include "Definitions.h"
|
||||||
#include "Extensions.h"
|
|
||||||
#include "Keymap.h"
|
#include "Keymap.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
|
@ -95,34 +94,6 @@ ATOM g_atom_value = XA_LAST_PREDEFINED + 1;
|
||||||
int g_epoll_fd;
|
int g_epoll_fd;
|
||||||
BAN::HashMap<int, EpollThingy> g_epoll_thingies;
|
BAN::HashMap<int, EpollThingy> g_epoll_thingies;
|
||||||
|
|
||||||
BAN::ErrorOr<void> extension_bigrequests(Client& client_info, BAN::ConstByteSpan packet)
|
|
||||||
{
|
|
||||||
switch (packet[1])
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
xGenericReply reply {
|
|
||||||
.type = X_Reply,
|
|
||||||
.sequenceNumber = client_info.sequence,
|
|
||||||
.length = 0,
|
|
||||||
.data00 = (16 << 20) / 4, // 16 MiB
|
|
||||||
};
|
|
||||||
TRY(encode(client_info.output_buffer, reply));
|
|
||||||
|
|
||||||
client_info.has_bigrequests = true;
|
|
||||||
|
|
||||||
dprintln("client enabled big requests");
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
dwarnln("invalid BIG-REQUESTS minor opcode {}", packet[1]);
|
|
||||||
return BAN::Error::from_errno(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
for (int sig = 1; sig < NSIG; sig++)
|
for (int sig = 1; sig < NSIG; sig++)
|
||||||
|
|
@ -269,8 +240,6 @@ int main()
|
||||||
|
|
||||||
MUST(initialize_keymap());
|
MUST(initialize_keymap());
|
||||||
|
|
||||||
install_extension("BIG-REQUESTS"_sv, extension_bigrequests);
|
|
||||||
|
|
||||||
printf("xbanan started\n");
|
printf("xbanan started\n");
|
||||||
|
|
||||||
const auto close_client =
|
const auto close_client =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue