forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
@ -0,0 +1,221 @@
|
||||
|
||||
#include "x11.h"
|
||||
#include <string.h>
|
||||
|
||||
// TODO: deal with monitor hotplugging and such
|
||||
|
||||
void kinc_x11_display_init(void) {
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
bool hasXinerama = (xlib.XineramaQueryExtension(x11_ctx.display, &eventBase, &errorBase) && xlib.XineramaIsActive(x11_ctx.display));
|
||||
XineramaScreenInfo *xinerama_screens = NULL;
|
||||
int xinerama_screen_count = 0;
|
||||
if (hasXinerama) {
|
||||
xinerama_screens = xlib.XineramaQueryScreens(x11_ctx.display, &xinerama_screen_count);
|
||||
}
|
||||
|
||||
Window root_window = RootWindow(x11_ctx.display, DefaultScreen(x11_ctx.display));
|
||||
XRRScreenResources *screen_resources = xlib.XRRGetScreenResourcesCurrent(x11_ctx.display, root_window);
|
||||
RROutput primary_output = xlib.XRRGetOutputPrimary(x11_ctx.display, root_window);
|
||||
|
||||
for (int i = 0; i < screen_resources->noutput; i++) {
|
||||
if (i >= MAXIMUM_DISPLAYS) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Too many screens (maximum %i)", MAXIMUM_DISPLAYS);
|
||||
break;
|
||||
}
|
||||
|
||||
XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[i]);
|
||||
if (output_info->connection != RR_Connected || output_info->crtc == None) {
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
continue;
|
||||
}
|
||||
|
||||
XRRCrtcInfo *crtc_info = xlib.XRRGetCrtcInfo(x11_ctx.display, screen_resources, output_info->crtc);
|
||||
|
||||
struct kinc_x11_display *display = &x11_ctx.displays[x11_ctx.num_displays++];
|
||||
display->index = i;
|
||||
strncpy(display->name, output_info->name, sizeof(display->name));
|
||||
display->x = crtc_info->x;
|
||||
display->y = crtc_info->y;
|
||||
display->width = crtc_info->width;
|
||||
display->height = crtc_info->height;
|
||||
display->primary = screen_resources->outputs[i] == primary_output;
|
||||
display->crtc = output_info->crtc;
|
||||
display->output = screen_resources->outputs[i];
|
||||
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeCrtcInfo(crtc_info);
|
||||
}
|
||||
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
if (hasXinerama) {
|
||||
xlib.XFree(xinerama_screens);
|
||||
}
|
||||
}
|
||||
|
||||
int kinc_x11_display_primary(void) {
|
||||
for (int i = 0; i < x11_ctx.num_displays; i++) {
|
||||
if (x11_ctx.displays[i].primary) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kinc_x11_count_displays(void) {
|
||||
return x11_ctx.num_displays;
|
||||
}
|
||||
|
||||
bool kinc_x11_display_available(int display_index) {
|
||||
if (display_index >= MAXIMUM_DISPLAYS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return x11_ctx.displays[display_index].output != None;
|
||||
}
|
||||
|
||||
const char *kinc_x11_display_name(int display_index) {
|
||||
if (display_index >= MAXIMUM_DISPLAYS) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return x11_ctx.displays[display_index].name;
|
||||
}
|
||||
|
||||
kinc_display_mode_t kinc_x11_display_current_mode(int display_index) {
|
||||
if (display_index >= MAXIMUM_DISPLAYS)
|
||||
display_index = 0;
|
||||
struct kinc_x11_display *display = &x11_ctx.displays[display_index];
|
||||
kinc_display_mode_t mode;
|
||||
mode.x = 0;
|
||||
mode.y = 0;
|
||||
mode.width = display->width;
|
||||
mode.height = display->height;
|
||||
mode.frequency = 60;
|
||||
mode.bits_per_pixel = 32;
|
||||
mode.pixels_per_inch = 96;
|
||||
|
||||
Window root_window = DefaultRootWindow(x11_ctx.display);
|
||||
XRRScreenResources *screen_resources = xlib.XRRGetScreenResourcesCurrent(x11_ctx.display, root_window);
|
||||
|
||||
XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]);
|
||||
if (output_info->connection != RR_Connected || output_info->crtc == None) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Display %i not connected.", display_index);
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return mode;
|
||||
}
|
||||
|
||||
XRRCrtcInfo *crtc_info = xlib.XRRGetCrtcInfo(x11_ctx.display, screen_resources, output_info->crtc);
|
||||
for (int j = 0; j < output_info->nmode; j++) {
|
||||
RRMode rr_mode = crtc_info->mode;
|
||||
XRRModeInfo *mode_info = NULL;
|
||||
for (int k = 0; k < screen_resources->nmode; k++) {
|
||||
if (screen_resources->modes[k].id == rr_mode) {
|
||||
mode_info = &screen_resources->modes[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode_info == NULL) {
|
||||
continue;
|
||||
}
|
||||
mode.x = display->x;
|
||||
mode.y = display->y;
|
||||
mode.width = mode_info->width;
|
||||
mode.height = mode_info->height;
|
||||
mode.pixels_per_inch = 96;
|
||||
mode.bits_per_pixel = 32;
|
||||
if (mode_info->hTotal && mode_info->vTotal) {
|
||||
mode.frequency = (mode_info->dotClock / (mode_info->hTotal * mode_info->vTotal));
|
||||
}
|
||||
else {
|
||||
mode.frequency = 60;
|
||||
}
|
||||
}
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeCrtcInfo(crtc_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return mode;
|
||||
}
|
||||
|
||||
int kinc_x11_display_count_available_modes(int display_index) {
|
||||
if (display_index >= MAXIMUM_DISPLAYS)
|
||||
display_index = 0;
|
||||
struct kinc_x11_display *display = &x11_ctx.displays[display_index];
|
||||
|
||||
Window root_window = RootWindow(x11_ctx.display, DefaultScreen(x11_ctx.display));
|
||||
XRRScreenResources *screen_resources = xlib.XRRGetScreenResourcesCurrent(x11_ctx.display, root_window);
|
||||
|
||||
XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]);
|
||||
if (output_info->connection != RR_Connected || output_info->crtc == None) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Display %i not connected.", display_index);
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int num_modes = output_info->nmode;
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return num_modes;
|
||||
}
|
||||
|
||||
kinc_display_mode_t kinc_x11_display_available_mode(int display_index, int mode_index) {
|
||||
if (display_index >= MAXIMUM_DISPLAYS)
|
||||
display_index = 0;
|
||||
struct kinc_x11_display *display = &x11_ctx.displays[display_index];
|
||||
kinc_display_mode_t mode;
|
||||
mode.x = 0;
|
||||
mode.y = 0;
|
||||
mode.width = display->width;
|
||||
mode.height = display->height;
|
||||
mode.frequency = 60;
|
||||
mode.bits_per_pixel = 32;
|
||||
mode.pixels_per_inch = 96;
|
||||
|
||||
Window root_window = RootWindow(x11_ctx.display, DefaultScreen(x11_ctx.display));
|
||||
XRRScreenResources *screen_resources = xlib.XRRGetScreenResourcesCurrent(x11_ctx.display, root_window);
|
||||
|
||||
XRROutputInfo *output_info = xlib.XRRGetOutputInfo(x11_ctx.display, screen_resources, screen_resources->outputs[display->index]);
|
||||
if (output_info->connection != RR_Connected || output_info->crtc == None) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Display %i not connected.", display_index);
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return mode;
|
||||
}
|
||||
|
||||
if (mode_index >= output_info->nmode) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Invalid mode index %i.", mode_index);
|
||||
}
|
||||
|
||||
RRMode rr_mode = output_info->modes[mode_index];
|
||||
XRRModeInfo *mode_info = NULL;
|
||||
|
||||
for (int k = 0; k < screen_resources->nmode; k++) {
|
||||
if (screen_resources->modes[k].id == rr_mode) {
|
||||
mode_info = &screen_resources->modes[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode_info != NULL) {
|
||||
mode.x = display->x;
|
||||
mode.y = display->y;
|
||||
mode.width = mode_info->width;
|
||||
mode.height = mode_info->height;
|
||||
mode.pixels_per_inch = 96;
|
||||
mode.bits_per_pixel = 32;
|
||||
if (mode_info->hTotal && mode_info->vTotal) {
|
||||
mode.frequency = (mode_info->dotClock / (mode_info->hTotal * mode_info->vTotal));
|
||||
}
|
||||
else {
|
||||
mode.frequency = 60;
|
||||
}
|
||||
}
|
||||
|
||||
xlib.XRRFreeOutputInfo(output_info);
|
||||
xlib.XRRFreeScreenResources(screen_resources);
|
||||
return mode;
|
||||
}
|
1055
Kha/Kinc/Backends/System/Linux/Sources/kinc/backend/x11/system.c.h
Normal file
1055
Kha/Kinc/Backends/System/Linux/Sources/kinc/backend/x11/system.c.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,206 @@
|
||||
#include "x11.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct MwmHints {
|
||||
// These correspond to XmRInt resources. (VendorSE.c)
|
||||
int flags;
|
||||
int functions;
|
||||
int decorations;
|
||||
int input_mode;
|
||||
int status;
|
||||
};
|
||||
#define MWM_HINTS_DECORATIONS (1L << 1)
|
||||
|
||||
void kinc_x11_window_set_title(int window_index, const char *title);
|
||||
void kinc_x11_window_change_mode(int window_index, kinc_window_mode_t mode);
|
||||
|
||||
int kinc_x11_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
|
||||
int window_index = -1;
|
||||
for (int i = 0; i < MAXIMUM_WINDOWS; i++) {
|
||||
if (x11_ctx.windows[i].window == None) {
|
||||
window_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (window_index == -1) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "Too much windows (maximum is %i)", MAXIMUM_WINDOWS);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
window->window_index = window_index;
|
||||
window->width = win->width;
|
||||
window->height = win->height;
|
||||
|
||||
Visual *visual = NULL;
|
||||
XSetWindowAttributes set_window_attribs = {0};
|
||||
|
||||
set_window_attribs.border_pixel = 0;
|
||||
set_window_attribs.event_mask =
|
||||
KeyPressMask | KeyReleaseMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask | FocusChangeMask;
|
||||
int screen = DefaultScreen(x11_ctx.display);
|
||||
visual = DefaultVisual(x11_ctx.display, screen);
|
||||
int depth = DefaultDepth(x11_ctx.display, screen);
|
||||
set_window_attribs.colormap = xlib.XCreateColormap(x11_ctx.display, RootWindow(x11_ctx.display, screen), visual, AllocNone);
|
||||
window->window = xlib.XCreateWindow(x11_ctx.display, RootWindow(x11_ctx.display, DefaultScreen(x11_ctx.display)), 0, 0, win->width, win->height, 0, depth,
|
||||
InputOutput, visual, CWBorderPixel | CWColormap | CWEventMask, &set_window_attribs);
|
||||
|
||||
static char nameClass[256];
|
||||
static const char *nameClassAddendum = "_KincApplication";
|
||||
strncpy(nameClass, kinc_application_name(), sizeof(nameClass) - strlen(nameClassAddendum) - 1);
|
||||
strcat(nameClass, nameClassAddendum);
|
||||
char resNameBuffer[256];
|
||||
strncpy(resNameBuffer, kinc_application_name(), 256);
|
||||
XClassHint classHint = {.res_name = resNameBuffer, .res_class = nameClass};
|
||||
xlib.XSetClassHint(x11_ctx.display, window->window, &classHint);
|
||||
|
||||
xlib.XSetLocaleModifiers("@im=none");
|
||||
window->xInputMethod = xlib.XOpenIM(x11_ctx.display, NULL, NULL, NULL);
|
||||
window->xInputContext = xlib.XCreateIC(window->xInputMethod, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, window->window, NULL);
|
||||
xlib.XSetICFocus(window->xInputContext);
|
||||
|
||||
window->mode = KINC_WINDOW_MODE_WINDOW;
|
||||
kinc_x11_window_change_mode(window_index, win->mode);
|
||||
|
||||
xlib.XMapWindow(x11_ctx.display, window->window);
|
||||
|
||||
Atom XdndVersion = 5;
|
||||
xlib.XChangeProperty(x11_ctx.display, window->window, x11_ctx.atoms.XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char *)&XdndVersion, 1);
|
||||
xlib.XSetWMProtocols(x11_ctx.display, window->window, &x11_ctx.atoms.WM_DELETE_WINDOW, 1);
|
||||
|
||||
kinc_x11_window_set_title(window_index, win->title);
|
||||
|
||||
if (x11_ctx.pen.id != -1) {
|
||||
xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.pen.motionClass, 1);
|
||||
}
|
||||
|
||||
if (x11_ctx.eraser.id != -1) {
|
||||
xlib.XSelectExtensionEvent(x11_ctx.display, window->window, &x11_ctx.eraser.motionClass, 1);
|
||||
}
|
||||
|
||||
x11_ctx.num_windows++;
|
||||
return window_index;
|
||||
}
|
||||
|
||||
void kinc_x11_window_destroy(int window_index) {
|
||||
xlib.XFlush(x11_ctx.display);
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XDestroyIC(window->xInputContext);
|
||||
xlib.XCloseIM(window->xInputMethod);
|
||||
xlib.XDestroyWindow(x11_ctx.display, window->window);
|
||||
xlib.XFlush(x11_ctx.display);
|
||||
*window = (struct kinc_x11_window){0};
|
||||
x11_ctx.num_windows--;
|
||||
}
|
||||
|
||||
void kinc_x11_window_set_title(int window_index, const char *_title) {
|
||||
const char *title = _title == NULL ? "" : _title;
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XChangeProperty(x11_ctx.display, window->window, x11_ctx.atoms.NET_WM_NAME, x11_ctx.atoms.UTF8_STRING, 8, PropModeReplace, (unsigned char *)title,
|
||||
strlen(title));
|
||||
|
||||
xlib.XChangeProperty(x11_ctx.display, window->window, x11_ctx.atoms.NET_WM_ICON_NAME, x11_ctx.atoms.UTF8_STRING, 8, PropModeReplace, (unsigned char *)title,
|
||||
strlen(title));
|
||||
|
||||
xlib.XFlush(x11_ctx.display);
|
||||
}
|
||||
|
||||
int kinc_x11_window_x(int window_index) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "x11 does not support getting the window position.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kinc_x11_window_y(int window_index) {
|
||||
kinc_log(KINC_LOG_LEVEL_ERROR, "x11 does not support getting the window position.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kinc_x11_window_move(int window_index, int x, int y) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XMoveWindow(x11_ctx.display, window->window, x, y);
|
||||
}
|
||||
|
||||
int kinc_x11_window_width(int window_index) {
|
||||
return x11_ctx.windows[window_index].width;
|
||||
}
|
||||
|
||||
int kinc_x11_window_height(int window_index) {
|
||||
return x11_ctx.windows[window_index].height;
|
||||
}
|
||||
|
||||
void kinc_x11_window_resize(int window_index, int width, int height) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XResizeWindow(x11_ctx.display, window->window, width, height);
|
||||
}
|
||||
|
||||
void kinc_x11_window_show(int window_index) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XMapWindow(x11_ctx.display, window->window);
|
||||
}
|
||||
|
||||
void kinc_x11_window_hide(int window_index) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
xlib.XUnmapWindow(x11_ctx.display, window->window);
|
||||
}
|
||||
|
||||
kinc_window_mode_t kinc_x11_window_get_mode(int window_index) {
|
||||
return x11_ctx.windows[window_index].mode;
|
||||
}
|
||||
|
||||
void kinc_x11_window_change_mode(int window_index, kinc_window_mode_t mode) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
if (mode == window->mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool fullscreen = false;
|
||||
|
||||
switch (mode) {
|
||||
case KINC_WINDOW_MODE_WINDOW:
|
||||
if (window->mode == KINC_WINDOW_MODE_FULLSCREEN) {
|
||||
window->mode = KINC_WINDOW_MODE_WINDOW;
|
||||
fullscreen = false;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case KINC_WINDOW_MODE_FULLSCREEN:
|
||||
case KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
|
||||
if (window->mode == KINC_WINDOW_MODE_WINDOW) {
|
||||
window->mode = KINC_WINDOW_MODE_FULLSCREEN;
|
||||
fullscreen = true;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
XEvent xev;
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = window->window;
|
||||
xev.xclient.message_type = x11_ctx.atoms.NET_WM_STATE;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = fullscreen ? 1 : 0;
|
||||
xev.xclient.data.l[1] = x11_ctx.atoms.NET_WM_STATE_FULLSCREEN;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
xlib.XMapWindow(x11_ctx.display, window->window);
|
||||
|
||||
xlib.XSendEvent(x11_ctx.display, DefaultRootWindow(x11_ctx.display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||
|
||||
xlib.XFlush(x11_ctx.display);
|
||||
}
|
||||
|
||||
int kinc_x11_window_display(int window_index) {
|
||||
struct kinc_x11_window *window = &x11_ctx.windows[window_index];
|
||||
return window->display_index;
|
||||
}
|
||||
|
||||
int kinc_x11_count_windows() {
|
||||
return x11_ctx.num_windows;
|
||||
}
|
200
Kha/Kinc/Backends/System/Linux/Sources/kinc/backend/x11/x11.h
Normal file
200
Kha/Kinc/Backends/System/Linux/Sources/kinc/backend/x11/x11.h
Normal file
@ -0,0 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
#include <kinc/display.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XInput.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
|
||||
#ifdef KINC_EGL
|
||||
#define EGL_NO_PLATFORM_SPECIFIC_TYPES
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
#define MAXIMUM_WINDOWS 16
|
||||
#define MAXIMUM_DISPLAYS 16
|
||||
|
||||
struct kinc_x11_window {
|
||||
int display_index;
|
||||
int window_index;
|
||||
int width;
|
||||
int height;
|
||||
kinc_window_mode_t mode;
|
||||
Window window;
|
||||
XIM xInputMethod;
|
||||
XIC xInputContext;
|
||||
};
|
||||
|
||||
struct kinc_x11_display {
|
||||
int index;
|
||||
int current_mode;
|
||||
int num_modes;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
bool primary;
|
||||
char name[64];
|
||||
|
||||
RROutput output;
|
||||
RRCrtc crtc;
|
||||
};
|
||||
|
||||
struct kinc_x11_mouse {
|
||||
int current_window;
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct kinc_x11_atoms {
|
||||
Atom XdndAware;
|
||||
Atom XdndDrop;
|
||||
Atom XdndEnter;
|
||||
Atom XdndTextUriList;
|
||||
Atom XdndStatus;
|
||||
Atom XdndActionCopy;
|
||||
Atom XdndSelection;
|
||||
Atom CLIPBOARD;
|
||||
Atom UTF8_STRING;
|
||||
Atom XSEL_DATA;
|
||||
Atom TARGETS;
|
||||
Atom MULTIPLE;
|
||||
Atom TEXT_PLAIN;
|
||||
Atom WM_DELETE_WINDOW;
|
||||
Atom MOTIF_WM_HINTS;
|
||||
Atom NET_WM_NAME;
|
||||
Atom NET_WM_ICON_NAME;
|
||||
Atom NET_WM_STATE;
|
||||
Atom NET_WM_STATE_FULLSCREEN;
|
||||
|
||||
Atom MOUSE;
|
||||
Atom TABLET;
|
||||
Atom KEYBOARD;
|
||||
Atom TOUCHSCREEN;
|
||||
Atom TOUCHPAD;
|
||||
Atom BUTTONBOX;
|
||||
Atom BARCODE;
|
||||
Atom TRACKBALL;
|
||||
Atom QUADRATURE;
|
||||
Atom ID_MODULE;
|
||||
Atom ONE_KNOB;
|
||||
Atom NINE_KNOB;
|
||||
Atom KNOB_BOX;
|
||||
Atom SPACEBALL;
|
||||
Atom DATAGLOVE;
|
||||
Atom EYETRACKER;
|
||||
Atom CURSORKEYS;
|
||||
Atom FOOTMOUSE;
|
||||
Atom JOYSTICK;
|
||||
};
|
||||
|
||||
struct kinc_x11_libs {
|
||||
void *X11;
|
||||
void *Xcursor;
|
||||
void *Xi;
|
||||
void *Xinerama;
|
||||
void *Xrandr;
|
||||
};
|
||||
|
||||
struct kinc_x11_procs {
|
||||
Display *(*XOpenDisplay)(const char *name);
|
||||
Status (*XInternAtoms)(Display *display, char **names, int count, Bool only_if_exists, Atom *atoms_return);
|
||||
int (*XCloseDisplay)(Display *display);
|
||||
XErrorHandler (*XSetErrorHandler)(XErrorHandler handler);
|
||||
int (*XGetErrorText)(Display *, int, char *, int);
|
||||
int (*XPending)(Display *display);
|
||||
int (*XFlush)(Display *display);
|
||||
int (*XNextEvent)(Display *display, XEvent *event_return);
|
||||
int (*XPeekEvent)(Display *display, XEvent *event_return);
|
||||
int (*XRefreshKeyboardMapping)(XMappingEvent *event_map);
|
||||
int (*XwcLookupString)(XIC, XKeyPressedEvent *, wchar_t *, int, KeySym *, int *);
|
||||
int (*XFilterEvent)(XEvent *, Window);
|
||||
int (*XConvertSelection)(Display *, Atom, Atom, Atom, Window, Time);
|
||||
int (*XSetSelectionOwner)(Display *, Atom, Window, Time);
|
||||
int (*XLookupString)(XKeyEvent *, char *, int, KeySym *, XComposeStatus *);
|
||||
KeySym (*XkbKeycodeToKeysym)(Display *, KeyCode, int, int);
|
||||
int (*XSendEvent)(Display *, Window, int, long, XEvent *);
|
||||
int (*XGetWindowProperty)(Display *, Window, Atom, long, long, int, Atom, Atom *, int *, unsigned long *, unsigned long *, unsigned char **);
|
||||
int (*XFree)(void *);
|
||||
int (*XChangeProperty)(Display *, Window, Atom, Atom, int, int, const unsigned char *, int);
|
||||
int (*XDefineCursor)(Display *, Window, Cursor);
|
||||
int (*XUndefineCursor)(Display *, Window);
|
||||
Pixmap (*XCreateBitmapFromData)(Display *, Drawable, const char *, unsigned int, unsigned int);
|
||||
Cursor (*XCreatePixmapCursor)(Display *, Pixmap, Pixmap, XColor *, XColor *, unsigned int, unsigned int);
|
||||
int (*XFreePixmap)(Display *, Pixmap);
|
||||
Cursor (*XcursorLibraryLoadCursor)(Display *, const char *);
|
||||
int (*XWarpPointer)(Display *, Window, Window, int, int, unsigned int, unsigned int, int, int);
|
||||
int (*XQueryPointer)(Display *, Window, Window *, Window *, int *, int *, int *, int *, unsigned int *);
|
||||
Colormap (*XCreateColormap)(Display *, Window, Visual *, int);
|
||||
Window (*XCreateWindow)(Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth,
|
||||
unsigned int class, Visual *visual, unsigned long valuemask, XSetWindowAttributes *attributes);
|
||||
int (*XMoveWindow)(Display *, Window, int, int);
|
||||
int (*XResizeWindow)(Display *, Window, unsigned int, unsigned int);
|
||||
int (*XDestroyWindow)(Display *, Window);
|
||||
int (*XSetClassHint)(Display *, Window, XClassHint *);
|
||||
char *(*XSetLocaleModifiers)(const char *);
|
||||
XIM (*XOpenIM)(Display *, struct _XrmHashBucketRec *, char *, char *);
|
||||
int (*XCloseIM)(XIM);
|
||||
XIC (*XCreateIC)(XIM, ...);
|
||||
void (*XDestroyIC)(XIC);
|
||||
void (*XSetICFocus)(XIC);
|
||||
int (*XMapWindow)(Display *, Window);
|
||||
int (*XUnmapWindow)(Display *, Window);
|
||||
int (*XSetWMProtocols)(Display *, Window, Atom *, int);
|
||||
|
||||
XDeviceInfo *(*XListInputDevices)(Display *, int *);
|
||||
void (*XFreeDeviceList)(XDeviceInfo *);
|
||||
XDevice *(*XOpenDevice)(Display *display, XID device_id);
|
||||
int (*XCloseDevice)(Display *display, XDevice *device);
|
||||
int (*XSelectExtensionEvent)(Display *, Window, XEventClass *, int);
|
||||
|
||||
int (*XineramaQueryExtension)(Display *dpy, int *event_base, int *error_base);
|
||||
int (*XineramaIsActive)(Display *dpy);
|
||||
XineramaScreenInfo *(*XineramaQueryScreens)(Display *dpy, int *number);
|
||||
|
||||
XRRScreenResources *(*XRRGetScreenResourcesCurrent)(Display *dpy, Window window);
|
||||
RROutput (*XRRGetOutputPrimary)(Display *dpy, Window window);
|
||||
XRROutputInfo *(*XRRGetOutputInfo)(Display *dpy, XRRScreenResources *resources, RROutput output);
|
||||
void (*XRRFreeOutputInfo)(XRROutputInfo *outputInfo);
|
||||
XRRCrtcInfo *(*XRRGetCrtcInfo)(Display *dpy, XRRScreenResources *resources, RRCrtc crtc);
|
||||
void (*XRRFreeCrtcInfo)(XRRCrtcInfo *crtcInfo);
|
||||
void (*XRRFreeScreenResources)(XRRScreenResources *resources);
|
||||
};
|
||||
|
||||
struct x11_pen_device {
|
||||
XID id;
|
||||
uint32_t motionEvent;
|
||||
XEventClass motionClass;
|
||||
uint32_t maxPressure;
|
||||
float current_pressure;
|
||||
|
||||
void (*press)(int /*window*/, int /*x*/, int /*y*/, float /*pressure*/);
|
||||
void (*move)(int /*window*/, int /*x*/, int /*y*/, float /*pressure*/);
|
||||
void (*release)(int /*window*/, int /*x*/, int /*y*/, float /*pressure*/);
|
||||
};
|
||||
|
||||
struct x11_context {
|
||||
Display *display;
|
||||
struct kinc_x11_libs libs;
|
||||
struct kinc_x11_atoms atoms;
|
||||
struct kinc_x11_mouse mouse;
|
||||
|
||||
struct x11_pen_device pen;
|
||||
struct x11_pen_device eraser;
|
||||
|
||||
int num_windows;
|
||||
struct kinc_x11_window windows[MAXIMUM_WINDOWS];
|
||||
int num_displays;
|
||||
struct kinc_x11_display displays[MAXIMUM_DISPLAYS];
|
||||
};
|
||||
|
||||
struct kinc_x11_procs xlib;
|
||||
struct x11_context x11_ctx;
|
||||
|
||||
void kinc_x11_copy_to_clipboard(const char *text);
|
Reference in New Issue
Block a user