Compare commits
7 Commits
refactor/r
...
riir
| Author | SHA1 | Date | |
|---|---|---|---|
| 6097395d45 | |||
| c527a9f007 | |||
| b4a91efedc | |||
| 49e2a9071d | |||
| e71673e46b | |||
| 386e3ca307 | |||
| 36e5eb1bde |
1
.gitignore
vendored
@@ -157,4 +157,5 @@ WINGs/wings-rs/Cargo.lock
|
||||
WINGs/wings-rs/src/WINGsP.rs
|
||||
wmaker-rs/Cargo.lock
|
||||
wrlib-rs/src/ffi.rs
|
||||
wrlib-rs/Cargo.lock
|
||||
wutil-rs/Cargo.lock
|
||||
|
||||
@@ -39,7 +39,7 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
AM_DISTCHECK_CONFIGURE_FLAGS = --enable-silent-rules LINGUAS='*'
|
||||
|
||||
|
||||
SUBDIRS = wrlib wutil-rs WINGs wmaker-rs src util po WindowMaker wmlib WPrefs.app doc
|
||||
SUBDIRS = wrlib wrlib-rs wutil-rs WINGs wmaker-rs src util po WindowMaker wmlib WPrefs.app doc
|
||||
DIST_SUBDIRS = $(SUBDIRS) test
|
||||
|
||||
EXTRA_DIST = TODO BUGS BUGFORM FAQ INSTALL \
|
||||
|
||||
@@ -32,7 +32,6 @@ libWINGs_la_SOURCES = \
|
||||
wbox.c \
|
||||
wbrowser.c \
|
||||
wbutton.c \
|
||||
wcolor.c \
|
||||
wcolorpanel.c \
|
||||
wcolorwell.c \
|
||||
wconfig.h \
|
||||
|
||||
@@ -852,7 +852,7 @@ Pixmap WMGetPixmapMaskXID(WMPixmap *pixmap);
|
||||
|
||||
WMPixmap* WMGetSystemPixmap(WMScreen *scr, int image);
|
||||
|
||||
/* ---[ WINGs/wcolor.c ]-------------------------------------------------- */
|
||||
/* ---[ WINGs/wings-rs/src/color.rs ]------------------------------------- */
|
||||
|
||||
|
||||
WMColor* WMDarkGrayColor(WMScreen *scr);
|
||||
|
||||
@@ -67,8 +67,10 @@ typedef struct W_DraggingInfo {
|
||||
|
||||
/* ---[ Structures from WINGs.h ]----------------------------------------- */
|
||||
|
||||
/* Pre-definition of internal structs */
|
||||
/* Opaque primitive types defined in Rust. */
|
||||
typedef struct W_Color W_Color;
|
||||
|
||||
/* Pre-definition of internal structs */
|
||||
typedef struct W_Pixmap W_Pixmap;
|
||||
typedef struct W_View W_View;
|
||||
|
||||
@@ -130,10 +132,10 @@ typedef struct W_Screen {
|
||||
W_DraggingInfo dragInfo;
|
||||
|
||||
/* colors */
|
||||
W_Color *white;
|
||||
W_Color *black;
|
||||
W_Color *gray;
|
||||
W_Color *darkGray;
|
||||
WMColor *white;
|
||||
WMColor *black;
|
||||
WMColor *gray;
|
||||
WMColor *darkGray;
|
||||
|
||||
GC stippleGC;
|
||||
|
||||
@@ -413,23 +415,6 @@ void W_BalloonHandleEnterView(WMView *view);
|
||||
void W_BalloonHandleLeaveView(WMView *view);
|
||||
|
||||
|
||||
/* ---[ wcolor.c ]-------------------------------------------------------- */
|
||||
|
||||
struct W_Color {
|
||||
struct W_Screen *screen;
|
||||
|
||||
XColor color;
|
||||
unsigned short alpha;
|
||||
short refCount;
|
||||
GC gc;
|
||||
struct {
|
||||
unsigned int exact:1;
|
||||
} flags;
|
||||
};
|
||||
|
||||
#define W_PIXEL(c) (c)->color.pixel
|
||||
|
||||
|
||||
/* ---[ wevent.c ]-------------------------------------------------------- */
|
||||
|
||||
typedef struct W_EventHandler {
|
||||
|
||||
@@ -281,7 +281,7 @@ char* wtrimspace(const char *s);
|
||||
*/
|
||||
char *wshellquote(const char *s);
|
||||
|
||||
/* ---[ WINGs/misc.c ]--------------------------------------------------- */
|
||||
/* ---[ wutil-rs/src/range.rs ]------------------------------------------ */
|
||||
|
||||
WMRange wmkrange(int start, int count);
|
||||
|
||||
|
||||
10
WINGs/misc.c
@@ -24,16 +24,6 @@
|
||||
|
||||
#include "error.h"
|
||||
|
||||
WMRange wmkrange(int start, int count)
|
||||
{
|
||||
WMRange range;
|
||||
|
||||
range.position = start;
|
||||
range.count = count;
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
/*
|
||||
* wutil_shutdown - cleanup in WUtil when user program wants to exit
|
||||
*/
|
||||
|
||||
@@ -1292,7 +1292,7 @@ void WMSetColorPanelPickerMode(WMColorPanel * panel, WMColorPanelMode mode)
|
||||
panel->mode = mode;
|
||||
}
|
||||
|
||||
WMColor *WMGetColorPanelColor(WMColorPanel * panel)
|
||||
WMColor* WMGetColorPanelColor(WMColorPanel * panel)
|
||||
{
|
||||
return WMGetColorWellColor(panel->colorWell);
|
||||
}
|
||||
@@ -1301,9 +1301,9 @@ void WMSetColorPanelColor(WMColorPanel * panel, WMColor * color)
|
||||
{
|
||||
WMSetColorWellColor(panel->colorWell, color);
|
||||
|
||||
panel->color.rgb.red = color->color.red >> 8;
|
||||
panel->color.rgb.green = color->color.green >> 8;
|
||||
panel->color.rgb.blue = color->color.blue >> 8;
|
||||
panel->color.rgb.red = (WMRedComponentOfColor(color) >> 8);
|
||||
panel->color.rgb.green = (WMGreenComponentOfColor(color) >> 8);
|
||||
panel->color.rgb.blue = (WMBlueComponentOfColor(color) >> 8);
|
||||
panel->color.set = cpRGB;
|
||||
|
||||
if (panel->mode == panel->lastChanged)
|
||||
|
||||
@@ -725,14 +725,14 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
||||
gcv.graphics_exposures = False;
|
||||
|
||||
gcv.function = GXxor;
|
||||
gcv.foreground = W_PIXEL(scrPtr->white);
|
||||
gcv.foreground = WMColorPixel(scrPtr->white);
|
||||
if (gcv.foreground == 0)
|
||||
gcv.foreground = 1;
|
||||
scrPtr->xorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
| GCGraphicsExposures | GCForeground, &gcv);
|
||||
|
||||
gcv.function = GXxor;
|
||||
gcv.foreground = W_PIXEL(scrPtr->gray);
|
||||
gcv.foreground = WMColorPixel(scrPtr->gray);
|
||||
gcv.subwindow_mode = IncludeInferiors;
|
||||
scrPtr->ixorGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction
|
||||
| GCGraphicsExposures | GCForeground | GCSubwindowMode, &gcv);
|
||||
@@ -743,8 +743,8 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
||||
scrPtr->clipGC = XCreateGC(display, W_DRAWABLE(scrPtr), GCFunction | GCGraphicsExposures, &gcv);
|
||||
|
||||
stipple = XCreateBitmapFromData(display, W_DRAWABLE(scrPtr), STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
|
||||
gcv.foreground = W_PIXEL(scrPtr->darkGray);
|
||||
gcv.background = W_PIXEL(scrPtr->gray);
|
||||
gcv.foreground = WMColorPixel(scrPtr->darkGray);
|
||||
gcv.background = WMColorPixel(scrPtr->gray);
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
scrPtr->stippleGC = XCreateGC(display, W_DRAWABLE(scrPtr),
|
||||
@@ -1000,7 +1000,7 @@ void WMSetWidgetBackgroundColor(WMWidget * w, WMColor * color)
|
||||
WMRedisplayWidget(w);
|
||||
}
|
||||
|
||||
WMColor *WMGetWidgetBackgroundColor(WMWidget * w)
|
||||
WMColor * WMGetWidgetBackgroundColor(WMWidget * w)
|
||||
{
|
||||
return W_VIEW(w)->backColor;
|
||||
}
|
||||
|
||||
993
WINGs/wings-rs-tests/Cargo.lock
generated
@@ -1,993 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
||||
|
||||
[[package]]
|
||||
name = "atomic-write-file"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84790c55b5704b0d35130bf16a4ce22a8e70eb0ea773522557524d9a4852663d"
|
||||
dependencies = [
|
||||
"nix",
|
||||
"rand 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.56"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.20.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78cef5b5a1a6827c7322ae2a636368a573006b27cfa76c7ebd53e834daeaab6a"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "cfg_aliases"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dlib"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
|
||||
|
||||
[[package]]
|
||||
name = "fuchsia-cprng"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasip2",
|
||||
"wasip3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d95e1a3a19ae464a7286e14af9a90683c64d70c02532d88d87ce95056af3e6c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dca35da0d19a18f4575f3cb99fe1c9e029a2941af5662f326f738a21edaf294"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash 0.1.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||
dependencies = [
|
||||
"allocator-api2",
|
||||
"equivalent",
|
||||
"foldhash 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.16.1",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "insta"
|
||||
version = "1.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f40e41efb5f592d3a0764f818e2f08e5e21c4f368126f74f37c81bd4af7a0c6"
|
||||
dependencies = [
|
||||
"console",
|
||||
"once_cell",
|
||||
"similar",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "insta-image"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7996488b176249911af0e5d17b2bdfe43e33267f650291cb874c0d4654e1dcb8"
|
||||
dependencies = [
|
||||
"insta",
|
||||
"png",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.182"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.30.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom-language"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2de2bc5b451bfedaef92c90b8939a8fff5770bdcc1fafd6239d086aab8fa6b29"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "pango-sys"
|
||||
version = "0.21.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4f06627d36ed5ff303d2df65211fc2e52ba5b17bf18dd80ff3d9628d6e06cfd"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||
dependencies = [
|
||||
"fuchsia-cprng",
|
||||
"libc",
|
||||
"rand_core 0.3.1",
|
||||
"rdrand",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||
dependencies = [
|
||||
"rand_chacha",
|
||||
"rand_core 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
|
||||
dependencies = [
|
||||
"rand_core 0.4.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rdrand"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
|
||||
dependencies = [
|
||||
"rand_core 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8bbf91e5a4d6315eee45e704372590b30e260ee83af6639d64557f51b067776"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2"
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "7.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48c8f33736f986f16d69b6cb8b03f55ddcad5c41acc4ccc39dd88e84aa805e7f"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c"
|
||||
|
||||
[[package]]
|
||||
name = "tempdir"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||
dependencies = [
|
||||
"rand 0.4.6",
|
||||
"remove_dir_all",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82a72c767771b47409d2345987fda8628641887d5466101319899796367354a0"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.4.1",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.9.12+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde_core",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.5+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.0.9+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.0.6+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.2+wasi-0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip3"
|
||||
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
|
||||
dependencies = [
|
||||
"leb128fmt",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-metadata"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"hashbrown 0.15.5",
|
||||
"indexmap",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wings-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"wutil-rs",
|
||||
"x11",
|
||||
"yeslogic-fontconfig-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wings-rs-tests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"insta",
|
||||
"insta-image",
|
||||
"libc",
|
||||
"png",
|
||||
"tempdir",
|
||||
"wings-rs",
|
||||
"wutil-rs",
|
||||
"x11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
||||
dependencies = [
|
||||
"wit-bindgen-rust-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-core"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust-macro"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-component"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"wasm-encoder",
|
||||
"wasm-metadata",
|
||||
"wasmparser",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-parser"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"id-arena",
|
||||
"indexmap",
|
||||
"log",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"unicode-xid",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wutil-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"atomic-write-file",
|
||||
"cc",
|
||||
"hashbrown 0.16.1",
|
||||
"nom",
|
||||
"nom-language",
|
||||
"x11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yeslogic-fontconfig-sys"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "503a066b4c037c440169d995b869046827dbc71263f6e8f3be6d77d4f3229dbd"
|
||||
dependencies = [
|
||||
"dlib",
|
||||
"once_cell",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||
@@ -10,6 +10,7 @@ insta-image = { version = "1.0", features = ["png"] }
|
||||
png = "0.18"
|
||||
tempdir = "0.3.7"
|
||||
wings-rs = { path = "../wings-rs" }
|
||||
wrlib-rs = { path = "../../wrlib-rs" }
|
||||
wutil-rs = { path = "../../wutil-rs" }
|
||||
x11 = "2.21.0"
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@ RUST_EXTRA = \
|
||||
Cargo.lock \
|
||||
Cargo.toml
|
||||
|
||||
Cargo.lock:
|
||||
cargo build
|
||||
|
||||
rustlib: $(RUST_SOURCES) $(RUST_EXTRA)
|
||||
cargo build
|
||||
|
||||
@@ -37,4 +40,4 @@ all: rustlib
|
||||
# process, and WINGs currently assumes that it is running in a single-threaded
|
||||
# environment.
|
||||
test: rustlib
|
||||
LD_LIBRARY_PATH=../.libs $(CARGO) nextest run
|
||||
LD_LIBRARY_PATH=../.libs:../../wrlib/.libs $(CARGO) nextest run
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
fn main() {
|
||||
println!("cargo::rustc-link-search=../.libs");
|
||||
println!("cargo::rustc-link-search=../../wrlib/.libs");
|
||||
println!("cargo::rustc-link-arg=-lX11");
|
||||
|
||||
println!("cargo::rustc-link-arg-tests=-lWUtil");
|
||||
println!("cargo::rustc-link-arg-tests=-lWINGs");
|
||||
println!("cargo::rustc-link-arg-tests=-lXft");
|
||||
println!("cargo::rustc-link-arg-tests=-lpango-1.0");
|
||||
println!("cargo::rustc-link-arg-tests=-lpangoxft-1.0");
|
||||
println!("cargo::rustc-link-arg-tests=-lpangoft2-1.0");
|
||||
|
||||
println!("cargo::rustc-link-arg-examples=-lWUtil");
|
||||
println!("cargo::rustc-link-arg-examples=-lWINGs");
|
||||
println!("cargo::rustc-link-arg-examples=-lX11");
|
||||
println!("cargo::rustc-link-arg-examples=-lXft");
|
||||
println!("cargo::rustc-link-arg-examples=-lpango-1.0");
|
||||
println!("cargo::rustc-link-arg-examples=-lpangoxft-1.0");
|
||||
println!("cargo::rustc-link-arg-examples=-lpangoft2-1.0");
|
||||
println!("cargo::rustc-link-arg=-lWUtil");
|
||||
println!("cargo::rustc-link-arg=-lWINGs");
|
||||
println!("cargo::rustc-link-arg=-lwraster");
|
||||
println!("cargo::rustc-link-arg=-lX11");
|
||||
println!("cargo::rustc-link-arg=-lXft");
|
||||
println!("cargo::rustc-link-arg=-lpango-1.0");
|
||||
println!("cargo::rustc-link-arg=-lpangoxft-1.0");
|
||||
println!("cargo::rustc-link-arg=-lpangoft2-1.0");
|
||||
}
|
||||
|
||||
BIN
WINGs/wings-rs-tests/tests/image_128x120.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
WINGs/wings-rs-tests/tests/image_128x120_varying_alpha.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 63
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 41
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 142
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 160
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 175
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 36 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 58
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 204
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 222
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 268
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 286
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 304
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 239
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 130
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tests/wmpixmap_tests.rs
|
||||
assertion_line: 229
|
||||
expression: app.xvfb.png_screenshot()
|
||||
extension: png
|
||||
snapshot_kind: binary
|
||||
---
|
||||
|
After Width: | Height: | Size: 68 KiB |
450
WINGs/wings-rs-tests/tests/wmpixmap_tests.rs
Normal file
@@ -0,0 +1,450 @@
|
||||
use insta_image::assert_png_snapshot;
|
||||
use std::{
|
||||
ptr::{self, NonNull},
|
||||
time::Instant,
|
||||
};
|
||||
use wings_rs::WINGsP::{
|
||||
WMCreateBlendedPixmapFromFile, WMCreateBlendedPixmapFromRImage, WMCreatePixmap,
|
||||
WMCreatePixmapFromFile, WMCreatePixmapFromRImage, WMCreateScaledBlendedPixmapFromFile,
|
||||
WMDrawPixmap, WMReleasePixmap,
|
||||
};
|
||||
use wings_rs_tests::HeadlessApplication;
|
||||
use wrlib_rs::ffi::{RColor, RLoadImage, RReleaseImage};
|
||||
|
||||
#[test]
|
||||
fn draw_blank_pixmap() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let pixmap = NonNull::new(WMCreatePixmap(app.screen.as_ptr(), 128, 196, 24, 1)).unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("empty_window", app.xvfb.png_screenshot());
|
||||
|
||||
let gc = x11::xlib::XCreateGC(display, (*pixmap.as_ptr()).pixmap, 0, ptr::null_mut());
|
||||
x11::xlib::XSetForeground(display, gc, 0);
|
||||
x11::xlib::XFillRectangle(display, (*pixmap.as_ptr()).pixmap, gc, 0, 0, 128, 196);
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("empty_pixmap_on_window", app.xvfb.png_screenshot());
|
||||
|
||||
x11::xlib::XFreeGC(display, gc);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
// WMCreatePixmapFromXPixmaps is not tested because it simply fills in struct
|
||||
// fields. Coverage from other tests in this file should be adequate.
|
||||
|
||||
#[test]
|
||||
fn draw_pixmap_from_file() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let pixmap = NonNull::new(WMCreatePixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_128x120.png".as_ptr(),
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_file_pixmap", app.xvfb.png_screenshot());
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_pixmap_from_r_image_no_mask() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let rimage = RLoadImage(
|
||||
(*app.screen.as_ptr()).rcontext,
|
||||
c"tests/image_128x120.png".as_ptr(),
|
||||
0,
|
||||
);
|
||||
let pixmap =
|
||||
NonNull::new(WMCreatePixmapFromRImage(app.screen.as_ptr(), rimage, 255)).unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 70, 74);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_r_image_no_mask", app.xvfb.png_screenshot());
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_pixmap_from_r_image_with_mask() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XBlackPixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let rimage = NonNull::new(RLoadImage(
|
||||
(*app.screen.as_ptr()).rcontext,
|
||||
c"tests/image_128x120_varying_alpha.png".as_ptr(),
|
||||
255,
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
// The threshold given to WMCreatePixmapFromRImage is compared against
|
||||
// the image's alpha channel. Pixels whose transparency are below the
|
||||
// threshold are masked out. This should draw a quartet of images with
|
||||
// varying masks.
|
||||
|
||||
// Totally masked.
|
||||
let pixmap_255 = NonNull::new(WMCreatePixmapFromRImage(
|
||||
app.screen.as_ptr(),
|
||||
rimage.as_ptr(),
|
||||
255,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap_255.as_ptr(), win, 70, 74);
|
||||
// Three bubbles masked.
|
||||
let pixmap_200 = NonNull::new(WMCreatePixmapFromRImage(
|
||||
app.screen.as_ptr(),
|
||||
rimage.as_ptr(),
|
||||
200,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap_200.as_ptr(), win, 200, 74);
|
||||
// Two bubbles masked.
|
||||
let pixmap_128 = NonNull::new(WMCreatePixmapFromRImage(
|
||||
app.screen.as_ptr(),
|
||||
rimage.as_ptr(),
|
||||
128,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap_128.as_ptr(), win, 70, 200);
|
||||
// Nothing masked.
|
||||
let pixmap_0 = NonNull::new(WMCreatePixmapFromRImage(
|
||||
app.screen.as_ptr(),
|
||||
rimage.as_ptr(),
|
||||
0,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap_0.as_ptr(), win, 200, 200);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_r_image_with_mask", app.xvfb.png_screenshot());
|
||||
WMReleasePixmap(pixmap_255.as_ptr());
|
||||
WMReleasePixmap(pixmap_200.as_ptr());
|
||||
WMReleasePixmap(pixmap_128.as_ptr());
|
||||
WMReleasePixmap(pixmap_0.as_ptr());
|
||||
RReleaseImage(rimage.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_blended_pixmap_from_r_image() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let rimage = RLoadImage(
|
||||
(*app.screen.as_ptr()).rcontext,
|
||||
c"tests/image_128x120.png".as_ptr(),
|
||||
0,
|
||||
);
|
||||
let pixmap = NonNull::new(WMCreateBlendedPixmapFromRImage(
|
||||
app.screen.as_ptr(),
|
||||
rimage,
|
||||
&RColor {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
alpha: 255,
|
||||
} as *const _,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 70, 74);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_r_image_no_mask", app.xvfb.png_screenshot());
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_blended_pixmap_from_file() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let pixmap = NonNull::new(WMCreatePixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_with_transparent_dot_128x120.png".as_ptr(),
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_file_blended_base_pixmap", app.xvfb.png_screenshot());
|
||||
|
||||
x11::xlib::XUnmapWindow(display, win);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_blended_cleared_window",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
|
||||
let pixmap = NonNull::new(WMCreateBlendedPixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_with_transparent_dot_128x120.png".as_ptr(),
|
||||
&RColor {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
alpha: 255,
|
||||
} as *const _,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!("from_file_blended_with_red", app.xvfb.png_screenshot());
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_scaled_blended_pixmap_from_file() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let pixmap = NonNull::new(WMCreatePixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_with_transparent_dot_128x120.png".as_ptr(),
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_base_pixmap",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
|
||||
x11::xlib::XUnmapWindow(display, win);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_cleared_window",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
|
||||
let pixmap = NonNull::new(WMCreateScaledBlendedPixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_with_transparent_dot_128x120.png".as_ptr(),
|
||||
&RColor {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
alpha: 255,
|
||||
} as *const _,
|
||||
60,
|
||||
64,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_with_red",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn draw_scaled_blended_pixmap_from_file_non_integral_scaling() {
|
||||
let mut app = HeadlessApplication::new();
|
||||
unsafe {
|
||||
let display = (*app.screen.as_ptr()).display;
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
|
||||
let pixmap = NonNull::new(WMCreatePixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
c"tests/image_128x120.png".as_ptr(),
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_non_integral_base_pixmap",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
|
||||
x11::xlib::XUnmapWindow(display, win);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
|
||||
let win = x11::xlib::XCreateSimpleWindow(
|
||||
display,
|
||||
(*app.screen.as_ptr()).rootWin,
|
||||
0,
|
||||
0,
|
||||
512,
|
||||
512,
|
||||
1,
|
||||
1,
|
||||
x11::xlib::XWhitePixel(display, 0),
|
||||
);
|
||||
x11::xlib::XMapWindow(display, win);
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_non_integral_cleared_window",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
|
||||
let pixmap = NonNull::new(WMCreateScaledBlendedPixmapFromFile(
|
||||
app.screen.as_ptr(),
|
||||
// No alpha channel on this image, so no color blending happens.
|
||||
c"tests/image_128x120.png".as_ptr(),
|
||||
&RColor {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
alpha: 255,
|
||||
} as *const _,
|
||||
// Shrink by only a little bit, such that simple integer division
|
||||
// might be thrown off. This test ensures that rescaling will
|
||||
// actually happen.
|
||||
110,
|
||||
114,
|
||||
))
|
||||
.unwrap();
|
||||
WMDrawPixmap(pixmap.as_ptr(), win, 64, 96);
|
||||
|
||||
while app.pump_event_queue(Instant::now()) {}
|
||||
assert_png_snapshot!(
|
||||
"from_file_scaled_blended_non_integral_scaled",
|
||||
app.xvfb.png_screenshot()
|
||||
);
|
||||
WMReleasePixmap(pixmap.as_ptr());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ crate-type = ["cdylib", "rlib"]
|
||||
[dependencies]
|
||||
libc = "0.2.177"
|
||||
pango-sys = "0.21.2"
|
||||
wrlib-rs = { path = "../../wrlib-rs" }
|
||||
wutil-rs = { path = "../../wutil-rs" }
|
||||
x11 = "2.21.0"
|
||||
yeslogic-fontconfig-sys = "6.0"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
AUTOMAKE_OPTIONS =
|
||||
|
||||
RUST_SOURCES = \
|
||||
RUST_SRC = \
|
||||
src/WINGsP.rs \
|
||||
src/button.rs \
|
||||
src/color.rs \
|
||||
src/configuration.rs \
|
||||
src/ffi.rs \
|
||||
src/font.rs \
|
||||
src/font_panel.rs \
|
||||
src/lib.rs \
|
||||
@@ -19,7 +21,7 @@ RUST_EXTRA = \
|
||||
src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs/WUtil.h Makefile patch_WINGsP.sh
|
||||
$(BINDGEN) ../WINGs/WINGsP.h \
|
||||
--no-recursive-allowlist \
|
||||
--allowlist-type "^W_.+|^WM(View|Array|DragOperationType|Point|Data|OpenPanel|SavePanel|HashTable|DraggingInfo|SelectionProcs|Rect|EventProc|Widget|Size|Color|Pixmap|FilePanel)|R(Context|ContextAttributes|Image|RenderingMode|ScalingFilter|StdColormapMode|ImageFormat|Color)|_WINGsConfiguration" \
|
||||
--allowlist-type "^W_.+|^WM(View|Array|DragOperationType|Point|Data|OpenPanel|SavePanel|HashTable|DraggingInfo|SelectionProcs|Rect|EventProc|Widget|Size|Pixmap|FilePanel|List|ListItem)" \
|
||||
--allowlist-type "^WM(FontPanel|Screen|Button)" \
|
||||
--allowlist-function "^WMCreateScreen|^WM(Get|Show)FontPanel|^WMCreateCommandButton|^WM(Initialize|Release)Application|^WMScreenMainLoop|^WMHandleEvent" \
|
||||
--allowlist-function "^WMWidgetScreen|^WM(Initialize|Release)Application|^WM(ScreenMainLoop|HandleEvent)|^WM(((Get|Set)TextFieldFont)|GetTextFieldText|SetTextFieldText|SelectTextFieldRange)" \
|
||||
@@ -46,12 +48,10 @@ src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs
|
||||
--allowlist-function "^WM(CreateLabel|SetLabelText|SetLabelFont|SetLabelTextColor|SetLabelRelief|SetLabelTextAlignment)" \
|
||||
--allowlist-type "^WM(Button|ButtonBehaviorMask)" \
|
||||
--allowlist-function "^WM(CreateCustomButton|SetButtonText|SetButtonAction|SetButtonText)" \
|
||||
--allowlist-function "wmkrange" \
|
||||
--allowlist-type "^WM(View|Array|DragOperationType|Point|Data|OpenPanel|SavePanel|HashTable|DraggingInfo|SelectionProcs|Rect|EventProc|Widget|Size|Color|Pixmap|FilePanel|Screen|Range|List|ListItem)" \
|
||||
--allowlist-type "^R(Context|ContextAttributes|Image|RenderingMode|ScalingFilter|StdColormapMode|ImageFormat|Color)" \
|
||||
--allowlist-type "_WINGsConfiguration" \
|
||||
--allowlist-item "^WMAlignment" \
|
||||
--allowlist-item "^WMReliefType" \
|
||||
--allowlist-function "^WM(Create|Release|Draw)Pixmap|^WMCreate(|Blended|ScaledBlended)PixmapFromFile|^WMCreate(|Blended)PixmapFromRImage" \
|
||||
-o src/WINGsP.rs -- \
|
||||
@PANGO_CFLAGS@ \
|
||||
-I../../wrlib \
|
||||
@@ -60,7 +60,7 @@ src/WINGsP.rs: ../WINGs/WINGsP.h ../../wrlib/wraster.h ../WINGs/WINGs.h ../WINGs
|
||||
Cargo.lock:
|
||||
$(CARGO) build
|
||||
|
||||
target/debug/libwings_rs.so: $(RUST_SOURCES) $(RUST_EXTRA)
|
||||
target/debug/libwings_rs.so: $(RUST_SRC) $(RUST_EXTRA)
|
||||
$(CARGO) build
|
||||
|
||||
check-local:
|
||||
|
||||
@@ -15,7 +15,7 @@ fi
|
||||
FILE="$1"
|
||||
|
||||
exec sed -i -r \
|
||||
-e "1s/^/use x11::xlib::*;\nuse crate::font::ffi::WMFont;\n\n/" \
|
||||
-e "1s/^/use wrlib_rs::ffi::*;\nuse wutil_rs::range::ffi::*;\nuse x11::xlib::*;\nuse crate::ffi::*;\n\n/" \
|
||||
-e "s/_XftDraw/::std::ffi::c_void/g" \
|
||||
-e "s/_XftFont/::std::ffi::c_void/g" \
|
||||
-e "s/PangoLayout/::std::ffi::c_void/g" \
|
||||
|
||||
566
WINGs/wings-rs/src/color.rs
Normal file
@@ -0,0 +1,566 @@
|
||||
use crate::WINGsP::WMScreen;
|
||||
use std::cell::RefCell;
|
||||
use std::ffi::c_ulong;
|
||||
use std::ptr::{self, NonNull};
|
||||
use wrlib_rs::ffi::{RColor, RGetClosestXColor};
|
||||
|
||||
pub struct Color {
|
||||
screen: NonNull<WMScreen>,
|
||||
color: x11::xlib::XColor,
|
||||
alpha: RefCell<u16>,
|
||||
gc: RefCell<x11::xlib::GC>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Rgb {
|
||||
pub r: u16,
|
||||
pub g: u16,
|
||||
pub b: u16,
|
||||
}
|
||||
|
||||
impl Rgb {
|
||||
pub fn with_alpha(self, alpha: u16) -> Rgba {
|
||||
Rgba {
|
||||
r: self.r,
|
||||
g: self.g,
|
||||
b: self.b,
|
||||
a: alpha,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ColorMatch {
|
||||
Approximate,
|
||||
Exact,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Rgba {
|
||||
pub r: u16,
|
||||
pub g: u16,
|
||||
pub b: u16,
|
||||
pub a: u16,
|
||||
}
|
||||
|
||||
impl Color {
|
||||
const LIGHT_STIPPLE_WIDTH: u32 = 4;
|
||||
const LIGHT_STIPPLE_HEIGHT: u32 = 4;
|
||||
const LIGHT_STIPPLE_BITS: [u8; 4] = [0x05, 0x0a, 0x05, 0x0a];
|
||||
const DARK_STIPPLE_WIDTH: u32 = 4;
|
||||
const DARK_STIPPLE_HEIGHT: u32 = 4;
|
||||
const DARK_STIPPLE_BITS: [u8; 4] = [0x0a, 0x04, 0x0a, 0x01];
|
||||
|
||||
pub fn new_rgb(screen: NonNull<WMScreen>, rgb: Rgb, mtch: ColorMatch) -> Option<Self> {
|
||||
Self::new_rgba(screen, rgb.with_alpha(0xffff), mtch)
|
||||
}
|
||||
|
||||
pub fn new_rgba(screen: NonNull<WMScreen>, rgba: Rgba, mtch: ColorMatch) -> Option<Self> {
|
||||
match mtch {
|
||||
ColorMatch::Approximate => find_close_rgba(screen, rgba),
|
||||
ColorMatch::Exact => create_rgba(screen, rgba),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn red(&self) -> u16 {
|
||||
self.color.red
|
||||
}
|
||||
|
||||
pub fn green(&self) -> u16 {
|
||||
self.color.green
|
||||
}
|
||||
|
||||
pub fn blue(&self) -> u16 {
|
||||
self.color.blue
|
||||
}
|
||||
|
||||
pub fn alpha(&self) -> u16 {
|
||||
*self.alpha.borrow()
|
||||
}
|
||||
|
||||
pub fn pixel(&self) -> c_ulong {
|
||||
self.color.pixel
|
||||
}
|
||||
|
||||
pub fn to_xft_color(&self) -> x11::xft::XftColor {
|
||||
x11::xft::XftColor {
|
||||
color: x11::xrender::XRenderColor {
|
||||
red: self.red(),
|
||||
green: self.green(),
|
||||
blue: self.blue(),
|
||||
alpha: self.alpha(),
|
||||
},
|
||||
pixel: self.pixel(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_rcolor(&self) -> RColor {
|
||||
RColor {
|
||||
red: (self.red() >> 8) as u8,
|
||||
green: (self.green() >> 8) as u8,
|
||||
blue: (self.blue() >> 8) as u8,
|
||||
alpha: (self.alpha() >> 8) as u8,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gc(&self) -> x11::xlib::GC {
|
||||
let mut gc = self.gc.borrow_mut();
|
||||
if gc.is_null() {
|
||||
let mut gcv =
|
||||
unsafe { std::mem::MaybeUninit::<x11::xlib::XGCValues>::zeroed().assume_init() };
|
||||
gcv.foreground = self.pixel();
|
||||
gcv.graphics_exposures = 0;
|
||||
|
||||
*gc = unsafe {
|
||||
let screen = &mut *self.screen.as_ptr();
|
||||
x11::xlib::XCreateGC(
|
||||
screen.display,
|
||||
(*screen.rcontext).drawable,
|
||||
(x11::xlib::GCForeground | x11::xlib::GCGraphicsExposures) as u64,
|
||||
&mut gcv,
|
||||
)
|
||||
};
|
||||
}
|
||||
*gc
|
||||
}
|
||||
|
||||
pub fn hex_triplet(&self) -> String {
|
||||
format!(
|
||||
"#{:02x}{:02x}{:02x}",
|
||||
self.red() >> 8,
|
||||
self.green() >> 8,
|
||||
self.blue() >> 8
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: make the color creation code return the same WMColor for the
|
||||
* same colors.
|
||||
* make findCloseColor() find the closest color in the RContext pallette
|
||||
* or in the other colors allocated by WINGs.
|
||||
*/
|
||||
|
||||
fn find_close_rgba(screen: NonNull<WMScreen>, rgba: Rgba) -> Option<Color> {
|
||||
let rcontext = unsafe { (*screen.as_ptr()).rcontext };
|
||||
let display = unsafe { (*screen.as_ptr()).display };
|
||||
let colormap = unsafe { (*screen.as_ptr()).colormap };
|
||||
|
||||
let mut xcolor = x11::xlib::XColor {
|
||||
pixel: 0,
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
flags: 0,
|
||||
pad: 0,
|
||||
};
|
||||
let mut rcolor = RColor {
|
||||
red: (rgba.r >> 8) as u8,
|
||||
green: (rgba.g >> 8) as u8,
|
||||
blue: (rgba.b >> 8) as u8,
|
||||
alpha: (rgba.a >> 8) as u8,
|
||||
};
|
||||
if unsafe { RGetClosestXColor(rcontext, &mut rcolor, &mut xcolor) } == 0 {
|
||||
return None;
|
||||
}
|
||||
if unsafe { x11::xlib::XAllocColor(display, colormap, &mut xcolor) } == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(Color {
|
||||
screen: screen,
|
||||
color: xcolor,
|
||||
alpha: RefCell::new(rgba.a),
|
||||
gc: RefCell::new(ptr::null_mut()),
|
||||
})
|
||||
}
|
||||
|
||||
fn create_rgba(screen: NonNull<WMScreen>, rgba: Rgba) -> Option<Color> {
|
||||
let display = unsafe { (*screen.as_ptr()).display };
|
||||
let colormap = unsafe { (*screen.as_ptr()).colormap };
|
||||
let mut xcolor = x11::xlib::XColor {
|
||||
red: rgba.r,
|
||||
green: rgba.g,
|
||||
blue: rgba.b,
|
||||
flags: x11::xlib::DoRed | x11::xlib::DoGreen | x11::xlib::DoBlue,
|
||||
pad: 0,
|
||||
pixel: 0,
|
||||
};
|
||||
if unsafe { x11::xlib::XAllocColor(display, colormap, &mut xcolor) } == 0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(Color {
|
||||
screen: screen,
|
||||
color: xcolor,
|
||||
alpha: RefCell::new(rgba.a),
|
||||
gc: RefCell::new(ptr::null_mut()),
|
||||
})
|
||||
}
|
||||
|
||||
impl Drop for Color {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let display = (*self.screen.as_ptr()).display;
|
||||
let colormap = (*self.screen.as_ptr()).colormap;
|
||||
x11::xlib::XFreeColors(display, colormap, &mut self.color.pixel, 1, 0);
|
||||
let gc = self.gc.borrow();
|
||||
if !gc.is_null() {
|
||||
x11::xlib::XFreeGC(display, *gc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod ffi {
|
||||
use super::*;
|
||||
use std::ffi::{c_char, c_int, c_uint, c_ulong, c_ushort, CString};
|
||||
use std::ptr::NonNull;
|
||||
use std::rc::Rc;
|
||||
use wrlib_rs::ffi::RColor;
|
||||
|
||||
pub type WMColor = Rc<Color>;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMCreateRGBColor(
|
||||
screen: NonNull<WMScreen>,
|
||||
red: c_ushort,
|
||||
green: c_ushort,
|
||||
blue: c_ushort,
|
||||
exact: c_int,
|
||||
) -> *mut WMColor {
|
||||
Color::new_rgb(
|
||||
screen,
|
||||
Rgb {
|
||||
r: red,
|
||||
g: green,
|
||||
b: blue,
|
||||
},
|
||||
if exact == 0 {
|
||||
ColorMatch::Approximate
|
||||
} else {
|
||||
ColorMatch::Exact
|
||||
},
|
||||
)
|
||||
.map(|c| Box::leak(Box::new(Rc::new(c))) as *mut _)
|
||||
.unwrap_or(unsafe { (*screen.as_ptr()).black })
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMGetRColorFroMColor(color: NonNull<WMColor>) -> RColor {
|
||||
unsafe { (*color.as_ptr()).to_rcolor() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn pixel(c: &WMColor) -> c_ulong {
|
||||
c.color.pixel
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMCreateRGBAColor(
|
||||
screen: NonNull<WMScreen>,
|
||||
red: c_ushort,
|
||||
green: c_ushort,
|
||||
blue: c_ushort,
|
||||
alpha: c_ushort,
|
||||
exact: c_int,
|
||||
) -> *mut WMColor {
|
||||
Color::new_rgba(
|
||||
screen,
|
||||
Rgba {
|
||||
r: red,
|
||||
g: green,
|
||||
b: blue,
|
||||
a: alpha,
|
||||
},
|
||||
if exact == 0 {
|
||||
ColorMatch::Approximate
|
||||
} else {
|
||||
ColorMatch::Exact
|
||||
},
|
||||
)
|
||||
.map(|c| Box::leak(Box::new(Rc::new(c))) as *mut _)
|
||||
.unwrap_or(unsafe { (*screen.as_ptr()).black })
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMCreateNamedColor(
|
||||
screen: NonNull<WMScreen>,
|
||||
name: *const c_char,
|
||||
exact: c_int,
|
||||
) -> *mut WMColor {
|
||||
let display = unsafe { (*screen.as_ptr()).display };
|
||||
let colormap = unsafe { (*screen.as_ptr()).colormap };
|
||||
let mut xcolor = x11::xlib::XColor {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
flags: 0,
|
||||
pad: 0,
|
||||
pixel: 0,
|
||||
};
|
||||
if unsafe { x11::xlib::XParseColor(display, colormap, name, &mut xcolor) } == 0 {
|
||||
return ptr::null_mut();
|
||||
}
|
||||
let visual_class = unsafe { (*(*screen.as_ptr()).visual).class };
|
||||
let exact = visual_class == x11::xlib::TrueColor || exact != 0;
|
||||
if exact {
|
||||
if let Some(c) = Color::new_rgb(
|
||||
screen,
|
||||
Rgb {
|
||||
r: xcolor.red,
|
||||
g: xcolor.green,
|
||||
b: xcolor.blue,
|
||||
},
|
||||
ColorMatch::Exact,
|
||||
) {
|
||||
return Box::leak(Box::new(Rc::new(c))) as *mut _;
|
||||
}
|
||||
}
|
||||
match Color::new_rgb(
|
||||
screen,
|
||||
Rgb {
|
||||
r: xcolor.red,
|
||||
g: xcolor.green,
|
||||
b: xcolor.blue,
|
||||
},
|
||||
ColorMatch::Approximate,
|
||||
) {
|
||||
Some(c) => Box::leak(Box::new(Rc::new(c))) as *mut _,
|
||||
None => ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMRetainColor(color: NonNull<WMColor>) -> *mut WMColor {
|
||||
Box::leak(Box::new(unsafe { (*color.as_ptr()).clone() })) as *mut _
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMReleaseColor(color: NonNull<WMColor>) {
|
||||
unsafe {
|
||||
let _ = Box::from_raw(color.as_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMSetColorAlpha(color: NonNull<WMColor>, alpha: c_ushort) {
|
||||
unsafe {
|
||||
(&mut *color.as_ptr()).alpha.replace(alpha);
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMPaintColorSwatch(
|
||||
color: NonNull<WMColor>,
|
||||
d: x11::xlib::Drawable,
|
||||
x: c_int,
|
||||
y: c_int,
|
||||
width: c_uint,
|
||||
height: c_uint,
|
||||
) {
|
||||
unsafe {
|
||||
let color = &mut *color.as_ptr();
|
||||
let display = (*color.screen.as_ptr()).display;
|
||||
x11::xlib::XFillRectangle(display, d, color.gc(), x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMColorPixel(color: NonNull<WMColor>) -> c_ulong {
|
||||
unsafe { (*color.as_ptr()).pixel() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMColorGC(color: NonNull<WMColor>) -> x11::xlib::GC {
|
||||
unsafe { (&mut *color.as_ptr()).gc() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMSetColorInGC(color: NonNull<WMColor>, gc: x11::xlib::GC) {
|
||||
unsafe {
|
||||
let color = &mut *color.as_ptr();
|
||||
let display = (*color.screen.as_ptr()).display;
|
||||
x11::xlib::XSetForeground(display, gc, color.pixel());
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMWhiteColor(screen: NonNull<WMScreen>) -> *mut WMColor {
|
||||
unsafe {
|
||||
let scr = &mut *screen.as_ptr();
|
||||
if scr.white.is_null() {
|
||||
// TODO: warn if we couldn't allocate.
|
||||
scr.white = WMCreateRGBColor(screen, 0xffff, 0xffff, 0xffff, 1);
|
||||
}
|
||||
|
||||
NonNull::new(scr.white)
|
||||
.map(|c| WMRetainColor(c))
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMBlackColor(screen: NonNull<WMScreen>) -> *mut WMColor {
|
||||
unsafe {
|
||||
let scr = &mut *screen.as_ptr();
|
||||
if scr.black.is_null() {
|
||||
// TODO: warn or bail out if we couldn't allocate.
|
||||
scr.black = WMCreateRGBColor(screen, 0, 0, 0, 1);
|
||||
}
|
||||
|
||||
NonNull::new(scr.black)
|
||||
.map(|c| WMRetainColor(c))
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMGrayColor(screen: NonNull<WMScreen>) -> *mut WMColor {
|
||||
unsafe {
|
||||
let scr = &mut *screen.as_ptr();
|
||||
if scr.gray.is_null() {
|
||||
if scr.depth == 1 {
|
||||
let white = WMWhiteColor(screen);
|
||||
let black = WMBlackColor(screen);
|
||||
let stipple = x11::xlib::XCreateBitmapFromData(
|
||||
scr.display,
|
||||
(*scr.rcontext).drawable,
|
||||
Color::LIGHT_STIPPLE_BITS.as_ptr(),
|
||||
Color::LIGHT_STIPPLE_WIDTH,
|
||||
Color::LIGHT_STIPPLE_HEIGHT,
|
||||
);
|
||||
let color = create_rgba(
|
||||
screen,
|
||||
Rgba {
|
||||
r: 0,
|
||||
g: 0,
|
||||
b: 0,
|
||||
a: 0xffff,
|
||||
},
|
||||
)
|
||||
.expect("cannot create stipple color");
|
||||
let mut gcv =
|
||||
std::mem::MaybeUninit::<x11::xlib::XGCValues>::zeroed().assume_init();
|
||||
gcv.foreground = (&mut *white).color.pixel;
|
||||
gcv.background = (&mut *black).color.pixel;
|
||||
gcv.fill_style = x11::xlib::FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
*color.gc.borrow_mut() = x11::xlib::XCreateGC(
|
||||
scr.display,
|
||||
(*scr.rcontext).drawable,
|
||||
(x11::xlib::GCForeground
|
||||
| x11::xlib::GCBackground
|
||||
| x11::xlib::GCStipple
|
||||
| x11::xlib::GCFillStyle
|
||||
| x11::xlib::GCGraphicsExposures) as u64,
|
||||
&mut gcv,
|
||||
);
|
||||
x11::xlib::XFreePixmap(scr.display, stipple);
|
||||
if let Some(white) = NonNull::new(white) {
|
||||
WMReleaseColor(white);
|
||||
}
|
||||
if let Some(black) = NonNull::new(black) {
|
||||
WMReleaseColor(black);
|
||||
}
|
||||
} else {
|
||||
scr.gray = WMCreateRGBColor(screen, 0xaeba, 0xaaaa, 0xaeba, 1);
|
||||
// TODO: warn or bail if we couldn't allocate.
|
||||
}
|
||||
}
|
||||
NonNull::new(scr.gray)
|
||||
.map(|c| WMRetainColor(c))
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMDarkGrayColor(screen: NonNull<WMScreen>) -> *mut WMColor {
|
||||
unsafe {
|
||||
let scr = &mut *screen.as_ptr();
|
||||
if scr.darkGray.is_null() {
|
||||
if scr.depth == 1 {
|
||||
let white = WMWhiteColor(screen);
|
||||
let black = WMBlackColor(screen);
|
||||
let stipple = x11::xlib::XCreateBitmapFromData(
|
||||
scr.display,
|
||||
(*scr.rcontext).drawable,
|
||||
Color::DARK_STIPPLE_BITS.as_ptr(),
|
||||
Color::DARK_STIPPLE_WIDTH,
|
||||
Color::DARK_STIPPLE_HEIGHT,
|
||||
);
|
||||
let color = create_rgba(
|
||||
screen,
|
||||
Rgba {
|
||||
r: 0,
|
||||
g: 0,
|
||||
b: 0,
|
||||
a: 0xffff,
|
||||
},
|
||||
)
|
||||
.expect("cannot create dark stipple color");
|
||||
let mut gcv =
|
||||
std::mem::MaybeUninit::<x11::xlib::XGCValues>::zeroed().assume_init();
|
||||
gcv.foreground = (&mut *white).color.pixel;
|
||||
gcv.background = (&mut *black).color.pixel;
|
||||
gcv.fill_style = x11::xlib::FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
*color.gc.borrow_mut() = x11::xlib::XCreateGC(
|
||||
scr.display,
|
||||
(*scr.rcontext).drawable,
|
||||
(x11::xlib::GCForeground
|
||||
| x11::xlib::GCBackground
|
||||
| x11::xlib::GCStipple
|
||||
| x11::xlib::GCFillStyle
|
||||
| x11::xlib::GCGraphicsExposures) as u64,
|
||||
&mut gcv,
|
||||
);
|
||||
x11::xlib::XFreePixmap(scr.display, stipple);
|
||||
if let Some(white) = NonNull::new(white) {
|
||||
WMReleaseColor(white);
|
||||
}
|
||||
if let Some(black) = NonNull::new(black) {
|
||||
WMReleaseColor(black);
|
||||
}
|
||||
} else {
|
||||
scr.darkGray = WMCreateRGBColor(screen, 0x5144, 0x5555, 0x5144, 1);
|
||||
// TODO: warn or bail if we couldn't allocate.
|
||||
}
|
||||
}
|
||||
NonNull::new(scr.darkGray)
|
||||
.map(|c| WMRetainColor(c))
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMRedComponentOfColor(color: NonNull<WMColor>) -> c_ushort {
|
||||
unsafe { (*color.as_ptr()).red() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMGreenComponentOfColor(color: NonNull<WMColor>) -> c_ushort {
|
||||
unsafe { (*color.as_ptr()).green() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMBlueComponentOfColor(color: NonNull<WMColor>) -> c_ushort {
|
||||
unsafe { (*color.as_ptr()).blue() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMGetColorAlpha(color: NonNull<WMColor>) -> c_ushort {
|
||||
unsafe { (*color.as_ptr()).alpha() }
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn WMGetColorRGBDescription(color: NonNull<WMColor>) -> *const c_char {
|
||||
unsafe {
|
||||
wutil_rs::string::wstrdup(
|
||||
CString::new((*color.as_ptr()).hex_triplet())
|
||||
.unwrap()
|
||||
.as_ptr(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
2
WINGs/wings-rs/src/ffi.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub use crate::color::ffi::*;
|
||||
pub use crate::font::ffi::*;
|
||||
@@ -210,7 +210,12 @@ pub mod ffi {
|
||||
|
||||
use std::ffi::CStr;
|
||||
|
||||
use crate::{WINGsP, configuration::Configuration, pango_extras};
|
||||
use crate::{
|
||||
WINGsP,
|
||||
configuration::Configuration,
|
||||
color::ffi::WMColor,
|
||||
pango_extras,
|
||||
};
|
||||
|
||||
use std::{
|
||||
ffi::{c_char, c_int, c_uint},
|
||||
@@ -452,7 +457,7 @@ pub mod ffi {
|
||||
pub unsafe extern "C" fn WMDrawString(
|
||||
screen: *mut WINGsP::W_Screen,
|
||||
d: x11::xlib::Drawable,
|
||||
color: *mut WINGsP::W_Color,
|
||||
color: *mut WMColor,
|
||||
font: *mut WMFont,
|
||||
x: c_int,
|
||||
y: c_int,
|
||||
@@ -466,15 +471,7 @@ pub mod ffi {
|
||||
let screen = unsafe { &*screen };
|
||||
let color = unsafe { &*color };
|
||||
let layout = unsafe { &mut *(**font).layout.as_ptr() };
|
||||
let mut xftcolor = x11::xft::XftColor {
|
||||
color: x11::xrender::XRenderColor {
|
||||
red: color.color.red,
|
||||
green: color.color.green,
|
||||
blue: color.color.blue,
|
||||
alpha: color.alpha,
|
||||
},
|
||||
pixel: color.color.pixel,
|
||||
};
|
||||
let mut xftcolor = color.to_xft_color();
|
||||
|
||||
let previous_text = unsafe { pango_sys::pango_layout_get_text(layout) };
|
||||
if previous_text.is_null() {
|
||||
@@ -507,8 +504,8 @@ pub mod ffi {
|
||||
pub unsafe extern "C" fn WMDrawImageString(
|
||||
screen: *mut WINGsP::W_Screen,
|
||||
d: x11::xlib::Drawable,
|
||||
color: *mut WINGsP::W_Color,
|
||||
background: *mut WINGsP::W_Color,
|
||||
color: *mut WMColor,
|
||||
background: *mut WMColor,
|
||||
font: *mut WMFont,
|
||||
x: c_int,
|
||||
y: c_int,
|
||||
@@ -523,24 +520,8 @@ pub mod ffi {
|
||||
let color = unsafe { &*color };
|
||||
let background = unsafe { &*background };
|
||||
let layout = unsafe { &mut *(**font).layout.as_ptr() };
|
||||
let mut text_color = x11::xft::XftColor {
|
||||
color: x11::xrender::XRenderColor {
|
||||
red: color.color.red,
|
||||
green: color.color.green,
|
||||
blue: color.color.blue,
|
||||
alpha: color.alpha,
|
||||
},
|
||||
pixel: color.color.pixel,
|
||||
};
|
||||
let background = x11::xft::XftColor {
|
||||
color: x11::xrender::XRenderColor {
|
||||
red: background.color.red,
|
||||
green: background.color.green,
|
||||
blue: background.color.blue,
|
||||
alpha: background.alpha,
|
||||
},
|
||||
pixel: color.color.pixel,
|
||||
};
|
||||
let mut text_color = color.to_xft_color();
|
||||
let background = background.to_xft_color();
|
||||
|
||||
unsafe {
|
||||
let Ok(width) = u32::try_from(WMWidthOfString(font, text, length)) else {
|
||||
|
||||
@@ -741,10 +741,10 @@ impl FontPanel {
|
||||
return;
|
||||
}
|
||||
WMSetTextFieldText(self.size_text.as_ptr(), (*item).text);
|
||||
let Ok(len) = CStr::from_ptr((*item).text).count_bytes().try_into() else {
|
||||
let Ok(len) = TryInto::<c_int>::try_into(CStr::from_ptr((*item).text).count_bytes()) else {
|
||||
return;
|
||||
};
|
||||
WMSelectTextFieldRange(self.size_text.as_ptr(), wmkrange(0, len));
|
||||
WMSelectTextFieldRange(self.size_text.as_ptr(), wutil_rs::range::Range::from(0..len));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub mod WINGsP;
|
||||
pub mod button;
|
||||
pub mod color;
|
||||
pub mod configuration;
|
||||
pub mod ffi;
|
||||
pub mod font;
|
||||
pub mod font_panel;
|
||||
pub mod list;
|
||||
|
||||
@@ -165,7 +165,7 @@ int W_GetTextHeight(WMFont * font, const char *text, int width, int wrap)
|
||||
|
||||
void
|
||||
W_PaintText(W_View * view, Drawable d, WMFont * font, int x, int y,
|
||||
int width, WMAlignment alignment, WMColor * color, int wrap,
|
||||
int width, WMAlignment alignment, WMColor *color, int wrap,
|
||||
const char *text, int length)
|
||||
{
|
||||
const char *ptr = text;
|
||||
|
||||
@@ -2989,8 +2989,8 @@ WMText *WMCreateTextForDocumentType(WMWidget * parent, WMAction * parser, WMActi
|
||||
W_SetViewBackgroundColor(tPtr->view, tPtr->bgColor);
|
||||
|
||||
gcv.graphics_exposures = False;
|
||||
gcv.foreground = W_PIXEL(scr->gray);
|
||||
gcv.background = W_PIXEL(scr->darkGray);
|
||||
gcv.foreground = WMColorPixel(scr->gray);
|
||||
gcv.background = WMColorPixel(scr->darkGray);
|
||||
gcv.fill_style = FillStippled;
|
||||
/* why not use scr->stipple here? */
|
||||
gcv.stipple = XCreateBitmapFromData(dpy, W_DRAWABLE(scr), STIPPLE_BITS, STIPPLE_WIDTH, STIPPLE_HEIGHT);
|
||||
|
||||
@@ -102,8 +102,8 @@ static W_View *createView(W_Screen * screen, W_View * parent)
|
||||
|
||||
view->attribFlags |= CWBackPixel | CWColormap | CWBorderPixel | CWBackPixmap;
|
||||
view->attribs.background_pixmap = None;
|
||||
view->attribs.background_pixel = W_PIXEL(screen->gray);
|
||||
view->attribs.border_pixel = W_PIXEL(screen->black);
|
||||
view->attribs.background_pixel = WMColorPixel(screen->gray);
|
||||
view->attribs.border_pixel = WMColorPixel(screen->black);
|
||||
view->attribs.colormap = screen->colormap;
|
||||
|
||||
view->backColor = WMRetainColor(screen->gray);
|
||||
@@ -483,7 +483,7 @@ void W_RedisplayView(W_View * view)
|
||||
WMHandleEvent(&ev);
|
||||
}
|
||||
|
||||
void W_SetViewBackgroundColor(W_View * view, WMColor * color)
|
||||
void W_SetViewBackgroundColor(W_View * view, WMColor *color)
|
||||
{
|
||||
if (view->backColor)
|
||||
WMReleaseColor(view->backColor);
|
||||
@@ -491,9 +491,9 @@ void W_SetViewBackgroundColor(W_View * view, WMColor * color)
|
||||
|
||||
view->attribFlags |= CWBackPixel;
|
||||
view->attribFlags &= ~CWBackPixmap;
|
||||
view->attribs.background_pixel = W_PIXEL(color);
|
||||
view->attribs.background_pixel = WMColorPixel(color);
|
||||
if (view->flags.realized) {
|
||||
XSetWindowBackground(view->screen->display, view->window, W_PIXEL(color));
|
||||
XSetWindowBackground(view->screen->display, view->window, WMColorPixel(color));
|
||||
XClearWindow(view->screen->display, view->window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -928,6 +928,7 @@ AC_CONFIG_FILES(
|
||||
dnl WRaster Library
|
||||
wrlib/Makefile wrlib/po/Makefile
|
||||
wrlib/tests/Makefile
|
||||
wrlib-rs/Makefile
|
||||
|
||||
dnl Rust implementation of WINGs utilities
|
||||
wutil-rs/Makefile
|
||||
|
||||
@@ -109,6 +109,7 @@ wmsetbg_LDADD = \
|
||||
$(top_builddir)/wrlib/libwraster.la \
|
||||
-lwings_rs \
|
||||
-lwutil_rs \
|
||||
$(top_builddir)/WINGs/libWINGs.la \
|
||||
@XLFLAGS@ @LIBXINERAMA@ @XLIBS@ @INTLIBS@ @FCLIBS@ @PANGO_LIBS@
|
||||
|
||||
wmgenmenu_LDFLAGS = \
|
||||
|
||||
32
wrlib-rs/Cargo.lock
generated
Normal file
@@ -0,0 +1,32 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.184"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e"
|
||||
|
||||
[[package]]
|
||||
name = "wrlib-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"x11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "x11"
|
||||
version = "2.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "502da5464ccd04011667b11c435cb992822c2c0dbde1770c988480d312a0db2e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
10
wrlib-rs/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "wrlib-rs"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
x11 = "2.21.0"
|
||||
31
wrlib-rs/Makefile.am
Normal file
@@ -0,0 +1,31 @@
|
||||
AUTOMAKE_OPTIONS =
|
||||
|
||||
RUST_SRC = \
|
||||
src/ffi.rs \
|
||||
src/lib.rs
|
||||
|
||||
RUST_EXTRA = Cargo.toml
|
||||
|
||||
src/ffi.rs: ../wrlib/wraster.h patch_ffi.sed Makefile
|
||||
$(BINDGEN) ../wrlib/wraster.h \
|
||||
--no-recursive-allowlist \
|
||||
--allowlist-type "Bool" \
|
||||
--allowlist-type "R(Context|ContextAttributes|Image|RenderingMode|ScalingFilter|StdColormapMode|ImageFormat|Color)" \
|
||||
--allowlist-function "RGetClosestXColor" \
|
||||
--allowlist-function "RLoadImage|RReleaseImage" \
|
||||
-o src/ffi.rs \
|
||||
-- \
|
||||
-I../../wrlib \
|
||||
&& sed -i -r -f patch_ffi.sed src/ffi.rs
|
||||
|
||||
target/debug/wrlib_rs.a: $(RUST_SRC) $(RUST_EXTRA)
|
||||
$(CARGO) build
|
||||
|
||||
check-local:
|
||||
$(CARGO) test
|
||||
|
||||
clean-local:
|
||||
$(CARGO) clean
|
||||
rm -f src/ffi.rs
|
||||
|
||||
all: target/debug/wrlib_rs.a
|
||||
4
wrlib-rs/patch_ffi.sed
Executable file
@@ -0,0 +1,4 @@
|
||||
# This file provides ad-hoc fixups to the wrlib-rs bindings provided by bindgen:
|
||||
# - Import Xlib symbols so that everything compiles.
|
||||
|
||||
1s/^/use x11::xlib::*;\n\n/
|
||||
4
wrlib-rs/src/lib.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(non_snake_case)]
|
||||
#[allow(non_upper_case_globals)]
|
||||
pub mod ffi;
|
||||
@@ -13,6 +13,7 @@ RUST_SOURCES = \
|
||||
src/memory.rs \
|
||||
src/notification.rs \
|
||||
src/prop_list.rs \
|
||||
src/range.rs \
|
||||
src/sendable.rs \
|
||||
src/string.rs \
|
||||
src/tree.rs
|
||||
|
||||
@@ -8,6 +8,7 @@ pub mod hash_table;
|
||||
pub mod memory;
|
||||
pub mod notification;
|
||||
pub mod prop_list;
|
||||
pub mod range;
|
||||
pub mod sendable;
|
||||
pub mod string;
|
||||
pub mod tree;
|
||||
|
||||
58
wutil-rs/src/range.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::ffi::c_int;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||
#[repr(C)]
|
||||
pub struct Range {
|
||||
pub start: c_int,
|
||||
pub count: c_int,
|
||||
}
|
||||
|
||||
impl Into<std::ops::Range<c_int>> for Range {
|
||||
fn into(self) -> std::ops::Range<c_int> {
|
||||
self.start..(self.start + self.count)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::ops::Range<c_int>> for Range {
|
||||
fn from(other: std::ops::Range<c_int>) -> Range {
|
||||
Range {
|
||||
start: other.start,
|
||||
count: other.end - other.start
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::ffi::c_int;
|
||||
use super::Range;
|
||||
|
||||
#[test]
|
||||
fn from_std_range() {
|
||||
assert_eq!(Range { start: 0, count: 10 }, Range::from(0..10));
|
||||
assert_eq!(Range { start: 1, count: 9 }, Range::from(1..10));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn into_std_range() {
|
||||
assert_eq!(0..10, Into::<std::ops::Range<c_int>>::into(Range {
|
||||
start: 0,
|
||||
count: 10
|
||||
}));
|
||||
assert_eq!(1..10, Into::<std::ops::Range<c_int>>::into(Range {
|
||||
start: 1,
|
||||
count: 9
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
pub mod ffi {
|
||||
use std::ffi::c_int;
|
||||
|
||||
pub type WMRange = super::Range;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn wmkrange(start: c_int, count: c_int) -> WMRange {
|
||||
WMRange { start, count }
|
||||
}
|
||||
}
|
||||