remove xcursor

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@641 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-11-08 22:40:41 +00:00
commit 9b45083747
7 changed files with 3863 additions and 3804 deletions

View file

@ -3,94 +3,111 @@
our $target = `uname -s`; our $target = `uname -s`;
$target =~ s/\r?\n$//; $target =~ s/\r?\n$//;
foreach my $l (@ARGV){ foreach my $l (@ARGV) {
if($l =~ /^--.+$/){ if ($l =~ /^--.+$/) {
}elsif($l =~ /^(.+)=(.+)$/){ }
$ENV{$1} = $2; elsif ($l =~ /^(.+)=(.+)$/) {
} $ENV{$1} = $2;
}
} }
our $cc = defined($ENV{CC}) ? $ENV{CC} : "gcc"; our $cc = defined($ENV{CC}) ? $ENV{CC} : "gcc";
our $incdir = "-I include"; our $incdir = "-I include";
our $cflags = "-fPIC -D_MILSKO"; our $cflags = "-fPIC -D_MILSKO";
our $libdir = ""; our $libdir = "";
our $ldflags = ""; our $ldflags = "";
our $math = "-lm"; our $math = "-lm";
our $shared = "-shared"; our $shared = "-shared";
our $backend = ""; our $backend = "";
our $library_prefix = "lib"; our $library_prefix = "lib";
our $library_suffix = ".so"; our $library_suffix = ".so";
our $object_suffix = ".o"; our $object_suffix = ".o";
our $executable_suffix = ""; our $executable_suffix = "";
our @library_targets = (); our @library_targets = ();
our @examples_targets = (); our @examples_targets = ();
our %examples_libs = (); our %examples_libs = ();
our $cross = 0; our $cross = 0;
require("./pl/utils.pl"); require("./pl/utils.pl");
param_set("stb-image", 1); param_set("stb-image", 1);
param_set("stb-truetype", 0); param_set("stb-truetype", 0);
param_set("freetype2", 1); param_set("freetype2", 1);
param_set("opengl", 0); param_set("opengl", 0);
param_set("vulkan", 0); param_set("vulkan", 0);
param_set("vulkan-string-helper", 1); param_set("vulkan-string-helper", 1);
my %features = ( my %features = (
"stb-image" => "use stb_image instead of libjpeg/libpng", "stb-image" => "use stb_image instead of libjpeg/libpng",
"stb-truetype" => "use stb_truetype", "stb-truetype" => "use stb_truetype",
"freetype2" => "use FreeType2", "freetype2" => "use FreeType2",
"opengl" => "build OpenGL widget", "opengl" => "build OpenGL widget",
"vulkan" => "build Vulkan widget", "vulkan" => "build Vulkan widget",
"vulkan-string-helper" => "use Vulkan string helper" "vulkan-string-helper" => "use Vulkan string helper"
);
my @features_keys = (
"1stb-image", "1stb-truetype",
"1freetype2", "1opengl",
"1vulkan", "2vulkan-string-helper"
); );
my @features_keys = ("1stb-image", "1stb-truetype", "1freetype2", "1opengl", "1vulkan", "2vulkan-string-helper");
foreach my $l (@ARGV){ foreach my $l (@ARGV) {
if($l =~ /^--(with|enable)-(.+)$/){ if ($l =~ /^--(with|enable)-(.+)$/) {
param_set($2, 1); param_set($2, 1);
}elsif($l =~ /^--(without|disable)-(.+)$/){ }
param_set($2, 0); elsif ($l =~ /^--(without|disable)-(.+)$/) {
}elsif($l =~ /^--target=(.+)$/){ param_set($2, 0);
$target = $1; }
}elsif($l eq "--cross"){ elsif ($l =~ /^--target=(.+)$/) {
$cross = 1; $target = $1;
}elsif(($l eq "-h") or ($l eq "--help")){ }
print("Milsko Toolkit Configuration Utility\n"); elsif ($l eq "--cross") {
print("\n"); $cross = 1;
print("Usage: $0 [options]\n"); }
print("\n"); elsif (($l eq "-h") or ($l eq "--help")) {
print("Options:\n"); print("Milsko Toolkit Configuration Utility\n");
print(" -h --help Display this help\n"); print("\n");
print(" --target=TARGET Specify target\n"); print("Usage: $0 [options]\n");
print(" --cross Indicate cross compilation\n"); print("\n");
print("\n"); print("Options:\n");
print("Features:\n"); print(" -h --help Display this help\n");
print(" --enable-FEATURE Use FEATURE\n"); print(" --target=TARGET Specify target\n");
print(" --with-FEATURE Use FEATURE\n"); print(" --cross Indicate cross compilation\n");
print(" --disable-FEATURE Do not use FEATURE\n"); print("\n");
print(" --without-FEATURE Do not use FEATURE\n"); print("Features:\n");
foreach my $l (@features_keys){ print(" --enable-FEATURE Use FEATURE\n");
my $flag = ((substr($l, 0, 1) eq '1') ? (param_get(substr($l, 1)) ? "--disable-" : "--enable-") : (param_get(substr($l, 1)) ? "--without-" : "--with-")) . substr($l, 1); print(" --with-FEATURE Use FEATURE\n");
my $do = param_get(substr($l, 1)) ? "Do not " : ""; print(" --disable-FEATURE Do not use FEATURE\n");
my $feat = $features{substr($l, 1)}; print(" --without-FEATURE Do not use FEATURE\n");
if(not(param_get($l))){
$feat = uc(substr($feat, 0, 1)) . substr($feat, 1); foreach my $l (@features_keys) {
} my $flag =
print(" $flag" . (" " x (32 - length($flag))) . "${do}${feat}\n"); ( (substr($l, 0, 1) eq '1')
} ? (param_get(substr($l, 1)) ? "--disable-" : "--enable-")
exit(0); : (param_get(substr($l, 1)) ? "--without-" : "--with-"))
} . substr($l, 1);
my $do = param_get(substr($l, 1)) ? "Do not " : "";
my $feat = $features{ substr($l, 1) };
if (not(param_get($l))) {
$feat = uc(substr($feat, 0, 1)) . substr($feat, 1);
}
print(" $flag" . (" " x (32 - length($flag))) . "${do}${feat}\n");
}
exit(0);
}
} }
if(-f "./pl/ostype/${target}.pl"){ if (-f "./pl/ostype/${target}.pl") {
require("./pl/ostype/${target}.pl"); require("./pl/ostype/${target}.pl");
}else{ }
print("Perl file (pl/ostype/${target}.pl) was not found for your target. Please add one.\n"); else {
exit(1); print(
"Perl file (pl/ostype/${target}.pl) was not found for your target. Please add one.\n"
);
exit(1);
} }
require("./pl/rules.pl"); require("./pl/rules.pl");
@ -98,12 +115,13 @@ require("./pl/rules.pl");
print("Target : " . $target . "\n"); print("Target : " . $target . "\n");
my @l = (); my @l = ();
foreach my $e (param_list()){ foreach my $e (param_list()) {
if(($e eq "vulkan-string-helper") and param_get("vulkan")){ if (($e eq "vulkan-string-helper") and param_get("vulkan")) {
push(@l, $e); push(@l, $e);
}elsif(not($e eq "vulkan-string-helper") and param_get($e)){ }
push(@l, $e); elsif (not($e eq "vulkan-string-helper") and param_get($e)) {
} push(@l, $e);
}
} }
print("Enabled: " . join(" ", @l) . "\n"); print("Enabled: " . join(" ", @l) . "\n");
@ -117,46 +135,68 @@ print(OUT "LIBS = ${libs}\n");
print(OUT "MATH = ${math}\n"); print(OUT "MATH = ${math}\n");
print(OUT "SHARED = ${shared}\n"); print(OUT "SHARED = ${shared}\n");
print(OUT "\n"); print(OUT "\n");
print(OUT ".PHONY: all clean distclean lib examples\n"); print(OUT ".PHONY: all format clean distclean lib examples\n");
print(OUT "\n"); print(OUT "\n");
print(OUT "all: lib examples\n"); print(OUT "all: lib examples\n");
print(OUT "\n"); print(OUT "\n");
print(OUT "format:\n");
print(OUT
" clang-format --verbose -i `find src include -name \"*.c\" -or -name \"*.h\"`\n"
);
print(OUT
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools Makefile.pl -name \"*.pl\"`\n"
);
print(OUT "\n");
print(OUT "lib: src/${library_prefix}Mw${library_suffix}\n"); print(OUT "lib: src/${library_prefix}Mw${library_suffix}\n");
print(OUT "\n"); print(OUT "\n");
print(OUT "src/${library_prefix}Mw${library_suffix}: " . join(" ", @library_targets) . "\n"); print( OUT "src/${library_prefix}Mw${library_suffix}: "
print(OUT " \$(CC) \$(SHARED) \$(LDFLAGS\) \$(LIBDIR) -o src/${library_prefix}Mw${library_suffix} " . join(" ", @library_targets) . " \$(LIBS)\n"); . join(" ", @library_targets)
foreach my $l (@library_targets){ . "\n");
my $s = $l; print(OUT
my $o = $object_suffix; " \$(CC) \$(SHARED) \$(LDFLAGS\) \$(LIBDIR) -o src/${library_prefix}Mw${library_suffix} "
$o =~ s/\./\\\./g; . join(" ", @library_targets)
$s =~ s/$o$/.c/; . " \$(LIBS)\n");
print(OUT "${l}: ${s}\n"); foreach my $l (@library_targets) {
print(OUT " \$(CC) \$(CFLAGS\) \$\(INCDIR) -c -o ${l} ${s}\n"); my $s = $l;
my $o = $object_suffix;
$o =~ s/\./\\\./g;
$s =~ s/$o$/.c/;
print(OUT "${l}: ${s}\n");
print(OUT " \$(CC) \$(CFLAGS\) \$\(INCDIR) -c -o ${l} ${s}\n");
} }
print(OUT "\n"); print(OUT "\n");
print(OUT "\n"); print(OUT "\n");
print(OUT "examples: " . join(" ", @examples_targets) . "\n"); print(OUT "examples: " . join(" ", @examples_targets) . "\n");
print(OUT "\n"); print(OUT "\n");
foreach my $l (@examples_targets){ foreach my $l (@examples_targets) {
my $libs = ""; my $libs = "";
my $s = $l; my $s = $l;
my $o = $executable_suffix; my $o = $executable_suffix;
$o =~ s/\./\\\./g; $o =~ s/\./\\\./g;
$s =~ s/$o$//; $s =~ s/$o$//;
if(defined($examples_libs{$l})){ if (defined($examples_libs{$l})) {
$libs = $examples_libs{$l}; $libs = $examples_libs{$l};
} }
print(OUT "${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"); print(OUT
print(OUT " \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"); "${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
print(OUT "${s}${object_suffix}: ${s}.c\n"); );
print(OUT " \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"); print(OUT
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
);
print(OUT "${s}${object_suffix}: ${s}.c\n");
print(OUT
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
);
} }
print(OUT "\n"); print(OUT "\n");
print(OUT "clean:\n"); print(OUT "clean:\n");
print(OUT " rm -f */*.o */*/*.o */*/*/*.o src/*.so src/*.dll src/*.a " . join(" ", @examples_targets) . "\n"); print( OUT " rm -f */*.o */*/*.o */*/*/*.o src/*.so src/*.dll src/*.a "
. join(" ", @examples_targets)
. "\n");
print(OUT "\n"); print(OUT "\n");
print(OUT "distclean: clean\n"); print(OUT "distclean: clean\n");
print(OUT " rm -f Makefile\n"); print(OUT " rm -f Makefile\n");

View file

@ -636,23 +636,29 @@ void MwLLForceRender(MwLL handle) {
} }
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
XcursorImage* img = XcursorImageCreate(MwCursorDataHeight, MwCursorDataHeight); Cursor cur;
Cursor cur; int y, x, ys, xs;
int y, x, ys, xs; char* di = malloc(MwCursorDataHeight * MwCursorDataHeight * 4);
char* dm = malloc(MwCursorDataHeight * MwCursorDataHeight * 4);
XImage* cimage = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 1, ZPixmap, 0, di, MwCursorDataHeight, MwCursorDataHeight, 32, MwCursorDataHeight * 4);
XImage* cmask = XCreateImage(handle->display, DefaultVisual(handle->display, DefaultScreen(handle->display)), 1, ZPixmap, 0, dm, MwCursorDataHeight, MwCursorDataHeight, 32, MwCursorDataHeight * 4);
Pixmap pimage = XCreatePixmap(handle->display, handle->window, MwCursorDataHeight, MwCursorDataHeight, 1);
Pixmap pmask = XCreatePixmap(handle->display, handle->window, MwCursorDataHeight, MwCursorDataHeight, 1);
GC imagegc = XCreateGC(handle->display, pimage, 0, NULL);
GC maskgc = XCreateGC(handle->display, pmask, 0, NULL);
XColor cfg, cbg;
xs = -mask->x + image->x; xs = -mask->x + image->x;
ys = MwCursorDataHeight + mask->y; ys = MwCursorDataHeight + mask->y;
ys = MwCursorDataHeight + image->y - ys; ys = MwCursorDataHeight + image->y - ys;
img->xhot = xs; memset(cimage->data, 0, cimage->bytes_per_line * cimage->height);
img->yhot = ys; memset(cmask->data, 0, cmask->bytes_per_line * cmask->height);
memset(img->pixels, 0, MwCursorDataHeight * MwCursorDataHeight * sizeof(XcursorPixel));
for(y = 0; y < mask->height; y++) { for(y = 0; y < mask->height; y++) {
unsigned int l = mask->data[y]; unsigned int l = mask->data[y];
for(x = mask->width - 1; x >= 0; x--) { for(x = mask->width - 1; x >= 0; x--) {
if(l & 1) { if(l & 1) {
img->pixels[y * MwCursorDataHeight + x] = 0xff000000; XPutPixel(cmask, x, y, 1);
} }
l = l >> 1; l = l >> 1;
} }
@ -661,18 +667,35 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
unsigned int l = image->data[y]; unsigned int l = image->data[y];
for(x = image->width - 1; x >= 0; x--) { for(x = image->width - 1; x >= 0; x--) {
int px = 0; int px = 0;
if(l & 1) px = 255; if(l & 1) px = 1;
img->pixels[(ys + y) * MwCursorDataHeight + (xs + x)] |= (px << 16) | (px << 8) | (px); XPutPixel(cimage, xs + x, ys + y, px);
l = l >> 1; l = l >> 1;
} }
} }
cur = XcursorImageLoadCursor(handle->display, img); cfg.red = 65535;
cfg.green = 65535;
cfg.blue = 65535;
XAllocColor(handle->display, handle->colormap, &cfg);
cbg.red = 0;
cbg.green = 0;
cbg.blue = 0;
XAllocColor(handle->display, handle->colormap, &cbg);
XPutImage(handle->display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
XPutImage(handle->display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
cur = XCreatePixmapCursor(handle->display, pimage, pmask, &cfg, &cbg, xs, ys);
XDefineCursor(handle->display, handle->window, cur); XDefineCursor(handle->display, handle->window, cur);
XFreeCursor(handle->display, cur); XFreeCursor(handle->display, cur);
XcursorImageDestroy(img); XFreePixmap(handle->display, pimage);
XFreePixmap(handle->display, pmask);
XDestroyImage(cimage);
XDestroyImage(cmask);
} }
void MwLLDetach(MwLL handle, MwPoint* point) { void MwLLDetach(MwLL handle, MwPoint* point) {

View file

@ -9,7 +9,6 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xcursor/Xcursor.h>
#include <X11/extensions/Xrender.h> #include <X11/extensions/Xrender.h>
struct _MwLL { struct _MwLL {

3693
src/font/boldttf.c generated

File diff suppressed because it is too large Load diff

3671
src/font/ttf.c generated

File diff suppressed because it is too large Load diff

View file

@ -87,8 +87,7 @@ static int create(MwWidget handle) {
attribs[3] = 24; attribs[3] = 24;
attribs[4] = None; attribs[4] = None;
while(glpath[glincr] != NULL && (o->lib = dlopen(glpath[glincr++], RTLD_LAZY)) == NULL) while(glpath[glincr] != NULL && (o->lib = dlopen(glpath[glincr++], RTLD_LAZY)) == NULL);
;
o->glXChooseVisual = (MWglXChooseVisual)dlsym(o->lib, "glXChooseVisual"); o->glXChooseVisual = (MWglXChooseVisual)dlsym(o->lib, "glXChooseVisual");
o->glXCreateContext = (MWglXCreateContext)dlsym(o->lib, "glXCreateContext"); o->glXCreateContext = (MWglXCreateContext)dlsym(o->lib, "glXCreateContext");

View file

@ -130,7 +130,7 @@ static void draw(MwWidget handle) {
} }
static void mouse_move(MwWidget handle) { static void mouse_move(MwWidget handle) {
int or = MwGetInteger(handle, MwNorientation); int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal; scrollbar_t* scr = handle->internal;
if(!handle->pressed) return; if(!handle->pressed) return;
@ -158,9 +158,9 @@ static void mouse_move(MwWidget handle) {
} }
static void mouse_down(MwWidget handle, void* ptr) { static void mouse_down(MwWidget handle, void* ptr) {
int ww = MwGetInteger(handle, MwNwidth); int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight); int wh = MwGetInteger(handle, MwNheight);
int or = MwGetInteger(handle, MwNorientation); int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal; scrollbar_t* scr = handle->internal;
MwLLMouse* m = ptr; MwLLMouse* m = ptr;