Skip to content

Commit f492efe

Browse files
committed
winit and webrender decouple
webrender: Fix missing wr-frame-edges winit and webrender decouple relocate crates out dir wip fix decouple winit/webrender set surfman size fmt decouple input_processor decouple window from output cleanup wr_render_init move scale_factor to display_info move color bits to display info new canvas from frame directly some clean up window id usin raw handle wr output decouput font wip wip wr output decouput font build: use rust --cfg Fixed Cargo nonsense rust-lang/cargo#7463 rework winit_term configuration build pgtk with webrender configure pgtk with webrender
1 parent d678d4e commit f492efe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3888
-2941
lines changed

.cargo/config.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
rustflags = [@RUSTFLAGS_CFG@]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,4 @@ lib-src/seccomp-filter-exec.pfc
347347
# GDB history
348348
.gdb_history
349349
_gdb_history
350+
/.cargo/config.toml

Cargo.in

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ lsp_json = { version = "0.1.0", path = "rust_src/crates/lsp_json" }
3636
git = { version = "0.1.0", path = "rust_src/crates/git", optional = true }
3737
ng_module = { version = "0.1.0", path = "rust_src/crates/ng_module", optional = true }
3838
js = { version = "0.1.0", path = "rust_src/crates/js", optional = true }
39-
wrterm = { version = "0.1.0", path = "rust_src/crates/webrender", optional = true }
39+
winit_term = { version = "0.1.0", path = "rust_src/crates/winit-term", optional = true }
40+
webrender_bindings = { version = "0.1.0", path = "rust_src/crates/webrender", optional = true }
4041
clippy = { version = "*", optional = true }
4142
log = "0.4.17"
4243
tracing = "0.1"
@@ -57,19 +58,11 @@ default = [
5758

5859
# Compile with C xml2 library support.
5960
use-xml2 = []
60-
# Use a window system
61-
window-system = ["emacs/window-system"]
62-
# Use the x11 window system
63-
window-system-x11 = []
64-
# Use the nextstep window system
65-
window-system-nextstep = []
66-
# Use the w32 window system
67-
window-system-w32 = []
6861
# Build with git2rs support
6962
libgit = ["git", "ng-bindgen/libgit"]
70-
# Use the webrender window system
71-
webrender = ["dep:wrterm"]
72-
window-system-webrender = ["ng-bindgen/window-system-webrender", "webrender"]
63+
# Use the webrender renderer
64+
webrender = ["dep:webrender_bindings"]
65+
window-system-winit = ["dep:winit_term", "webrender"]
7366
# Treat warnings as a build error on Travis.
7467
strict = []
7568
# Use JavaScript and Deno
@@ -95,7 +88,7 @@ git = "https://github.com/RazrFalcon/fontdb.git"
9588

9689
[patch.crates-io.surfman]
9790
git ="https://github.com/declantsien/surfman.git"
98-
rev = "ad2bf7faacb5b240a47ce280f72e914d1590712f"
91+
rev = "caddee293e1f6ec8b33caec6170585a89c2674b8"
9992

10093
[patch.crates-io.surfman-chains]
10194
git = "https://github.com/declantsien/surfman-chains.git"

TODO

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* init output inner when create pgtk frame
2+
wr_canvas_init raw_window_handle
3+
http://www.manpagez.com/html/gdk/gdk-3.12.1/gdk3-Wayland-Interaction.php#gdk-wayland-window-get-wl-surface
4+
gtk_widget_get_window
5+
pgtk_output.widget

configure.ac

Lines changed: 70 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,13 @@ otherwise for the first of 'inotify', 'kqueue' or 'gfile' that is usable.])
536536
OPTION_DEFAULT_OFF([xwidgets],
537537
[enable use of xwidgets in Emacs buffers (requires gtk3 or macOS Cocoa)])
538538

539-
OPTION_DEFAULT_OFF([webrender],
540-
[enable use of webrender(written in Rust) as GUI backend on
539+
OPTION_DEFAULT_OFF([winit],
540+
[enable use of winit(written in Rust) as GUI backend on
541541
multiple platforms(Linux, Windows and MacOS) (experimental)])
542542

543+
OPTION_DEFAULT_OFF([webrender],
544+
[enable use of webrender(written in Rust) as rendering engine])
545+
543546
## Based on Deno 1.9.1
544547
## Update the above when upgrading Deno
545548
OPTION_DEFAULT_OFF([javascript],
@@ -1315,8 +1318,8 @@ AC_ARG_ENABLE(rust-debug,
13151318
Useful for debugging rust component of emacs-ng.])],
13161319
[ac_enable_rust_debug="${enableval}"],[])
13171320

1318-
AC_ARG_ENABLE(webrender-self-contained,
1319-
[AS_HELP_STRING([--disable-webrender-self-contained],
1321+
AC_ARG_ENABLE(winit-self-contained,
1322+
[AS_HELP_STRING([--disable-winit-self-contained],
13201323
[disable self contained Webrender build under NeXTstep])],
13211324
EN_NS_SELF_CONTAINED=$enableval,
13221325
EN_NS_SELF_CONTAINED=yes)
@@ -1326,10 +1329,10 @@ AC_ARG_ENABLE(webrender-capture,
13261329
[enable WebRender capture infrastructure.])],
13271330
[ac_enable_webrender_capture="${enableval}"],[])
13281331

1329-
AC_ARG_ENABLE(webrender-x11,
1330-
[AS_HELP_STRING([--disable-webrender-x11],
1331-
[disable WebRender X11 support.])],
1332-
[ac_enable_webrender_x11="${enableval}"],[])
1332+
AC_ARG_ENABLE(winit-x11,
1333+
[AS_HELP_STRING([--enable-winit-x11],
1334+
[enable Winit X11 support.])],
1335+
[ac_enable_winit_x11="${enableval}"],[])
13331336

13341337
AC_SUBST([AM_DEFAULT_VERBOSITY])
13351338
AC_CONFIG_FILES([src/verbose.mk])
@@ -2012,10 +2015,15 @@ AC_SUBST([AUTO_DEPEND])
20122015

20132016
window_system=none
20142017

2015-
if test "${with_webrender}" = "yes"; then
2018+
if test "${with_winit}" = "yes"; then
20162019
no_x=yes
20172020
with_ns=no
2018-
window_system=webrender
2021+
window_system=winit
2022+
with_webrender=yes
2023+
fi
2024+
2025+
if test "${with_webrender}" = "yes"; then
2026+
with_cairo=no
20192027
fi
20202028

20212029
if test "${with_pgtk}" = "yes"; then
@@ -2506,7 +2514,7 @@ dnl use the toolkit if we have gtk, or X11R5 or newer.
25062514
w32 )
25072515
term_header=w32term.h
25082516
;;
2509-
webrender )
2517+
winit )
25102518
term_header=wrterm.h
25112519
;;
25122520
pgtk )
@@ -6282,39 +6290,30 @@ AC_SUBST([XMENU_OBJ])
62826290
AC_SUBST([XOBJ])
62836291
AC_SUBST([FONT_OBJ])
62846292

6285-
WEBRENDER_LIBS=
6286-
WEBRENDER_IMPL_COCOA=no
6287-
if test "${window_system}" = "webrender" ; then
6293+
WINIT_LIBS=
6294+
WINIT_IMPL_COCOA=no
6295+
if test "${window_system}" = "winit" ; then
62886296

6289-
AC_DEFINE(USE_WEBRENDER, 1,
6290-
[Define to 1 if you want to use the webrender.])
6291-
6292-
AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
6293-
NATIVE_IMAGE_API="yes (webrender)"
6297+
AC_DEFINE(HAVE_WINIT, 1,
6298+
[Define to 1 if you want to use the Winit.])
62946299

62956300
if test "${opsys}" = gnu-linux; then
6296-
EMACS_CHECK_MODULES([FREETYPE], [freetype2])
6297-
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(webrender requires libfreetype)
6298-
6299-
EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
6300-
test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(webrender requires libfontconfig)
6301-
63026301
EMACS_CHECK_MODULES([XCB], [xcb >= 1.0.0])
6303-
test "$HAVE_XCB" = "no" && AC_MSG_ERROR(WebRender Unix build requires libxcb)
6302+
test "$HAVE_XCB" = "no" && AC_MSG_ERROR(Winit Unix build requires libxcb)
63046303

6305-
WEBRENDER_LIBS="$WEBRENDER_LIBS -lxcb -lxcb-xfixes -lxcb-shape -lxcb-render"
6304+
WINIT_LIBS="$WINIT_LIBS -lxcb -lxcb-xfixes -lxcb-shape -lxcb-render"
63066305

63076306
if test X$ac_enable_webrender_x11 != Xno; then
6308-
WEBRENDER_LIBS="-lX11 -lX11-xcb $WEBRENDER_LIBS"
6307+
WINIT_LIBS="-lX11 -lX11-xcb $WINIT_LIBS"
63096308
fi
63106309
fi
63116310

63126311
if test "${opsys}" = darwin; then
6313-
WEBRENDER_IMPL_COCOA=yes
6312+
WINIT_IMPL_COCOA=yes
63146313
fi
63156314

63166315
if test "${EN_NS_SELF_CONTAINED}" = yes && test "${opsys}" = darwin; then
6317-
AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an Webrender NS bundled app])
6316+
AC_DEFINE(NS_SELF_CONTAINED, 1, [Build an Winit NS bundled app])
63186317
ns_self_contained=yes
63196318
ns_appdir=`pwd`/nextstep/Emacs.app
63206319
ns_appbindir=${ns_appdir}/Contents/MacOS
@@ -6341,8 +6340,28 @@ if test "${window_system}" = "webrender" ; then
63416340
fi
63426341

63436342
fi
6343+
AC_SUBST(WINIT_OBJ)
6344+
AC_SUBST(WINIT_LIBS)
6345+
AC_SUBST(WINIT_IMPL_COCOA)
6346+
6347+
WEBRENDER_LIBS=
6348+
if test "${with_webrender}" = "yes" ; then
6349+
RUSTFLAGS_CFG="\"--cfg=use_webrender\", ${RUSTFLAGS_CFG}"
6350+
AC_DEFINE(USE_WEBRENDER, 1,
6351+
[Define to 1 if you want to use the webrender.])
6352+
6353+
AC_DEFINE(HAVE_NATIVE_IMAGE_API, 1, [Define to use native OS APIs for images.])
6354+
NATIVE_IMAGE_API="yes (webrender)"
6355+
6356+
if test "${opsys}" = gnu-linux; then
6357+
EMACS_CHECK_MODULES([FREETYPE], [freetype2])
6358+
test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(webrender requires libfreetype)
6359+
6360+
EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
6361+
test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(webrender requires libfontconfig)
6362+
fi
6363+
fi
63446364
AC_SUBST(WEBRENDER_LIBS)
6345-
AC_SUBST(WEBRENDER_IMPL_COCOA)
63466365

63476366
WIDGET_OBJ=
63486367
MOTIF_LIBW=
@@ -7017,33 +7036,29 @@ fi || AC_MSG_ERROR(['src/epaths.h' could not be made.])
70177036
window_system="$window_system" EN_NS_SELF_CONTAINED="$EN_NS_SELF_CONTAINED"])
70187037

70197038
CARGO_DEFAULT_FEATURES=""
7039+
WINIT_DEFAULT_FEATURES=""
70207040
WEBRENDER_DEFAULT_FEATURES=""
70217041
if test "$HAVE_LIBXML2" = "yes"; then
70227042
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"use-xml2\", "
70237043
fi
7024-
if test "$window_system" != "none"; then
7025-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system\", "
7026-
fi
7044+
dnl if test "$window_system" != "none"; then
7045+
RUSTFLAGS_CFG="\"--cfg=have_window_system\", ${RUSTFLAGS_CFG}"
7046+
dnl fi
7047+
RUSTFLAGS_CFG="\"--cfg=window_system=\\\"$window_system\\\"\", ${RUSTFLAGS_CFG}"
70277048
case "$window_system" in
7028-
x11)
7029-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-x11\", "
7030-
;;
7031-
nextstep)
7032-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-nextstep\", "
7033-
;;
7034-
w32)
7035-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-w32\", "
7036-
;;
7037-
webrender)
7038-
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-webrender\", "
7039-
if test x$ac_enable_webrender_capture != x ; then
7040-
WEBRENDER_DEFAULT_FEATURES="\"capture\", ${WEBRENDER_DEFAULT_FEATURES}"
7041-
fi
7049+
winit)
7050+
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"window-system-winit\", "
70427051
if test X$ac_enable_webrender_x11 != Xno ; then
7043-
WEBRENDER_DEFAULT_FEATURES="\"x11\", ${WEBRENDER_DEFAULT_FEATURES}"
7052+
WINIT_DEFAULT_FEATURES="\"x11\", ${WINIT_DEFAULT_FEATURES}"
70447053
fi
70457054
;;
70467055
esac
7056+
if test "${with_webrender}" = "yes" ; then
7057+
if test x$ac_enable_webrender_capture != x ; then
7058+
WEBRENDER_DEFAULT_FEATURES="\"wr_capture\", ${WINIT_DEFAULT_FEATURES}"
7059+
fi
7060+
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"webrender\", "
7061+
fi
70477062
if test "$HAVE_LIBGIT" = "yes"; then
70487063
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"libgit\", "
70497064
fi
@@ -7054,11 +7069,17 @@ fi
70547069
if test "${HAVE_MODULES}" = "yes"; then
70557070
CARGO_DEFAULT_FEATURES="${CARGO_DEFAULT_FEATURES}\"ng-module\", "
70567071
fi
7072+
7073+
AC_SUBST(RUSTFLAGS_CFG)
70577074
AC_SUBST(CARGO_DEFAULT_FEATURES)
7075+
AC_SUBST(WINIT_DEFAULT_FEATURES)
70587076
AC_SUBST(WEBRENDER_DEFAULT_FEATURES)
70597077
AC_CONFIG_FILES([Cargo.toml:Cargo.in])
70607078
webrender_src=$srcdir/rust_src/crates/webrender
70617079
AC_CONFIG_FILES([$webrender_src/Cargo.toml:$webrender_src/Cargo.in])
7080+
winit_term_src=$srcdir/rust_src/crates/winit-term
7081+
AC_CONFIG_FILES([$winit_term_src/Cargo.toml:$winit_term_src/Cargo.in])
7082+
AC_CONFIG_FILES([$srcdir/.cargo/config.toml:$srcdir/.cargo/config.in])
70627083
AC_CONFIG_FILES([$srcdir/rust_src/crates/emacs/build.rs])
70637084

70647085
dnl NB we have to cheat and use the ac_... version because abs_top_srcdir

lisp/cus-edit.el

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,15 +2209,15 @@ and `face'."
22092209
;;; The `custom' Widget.
22102210

22112211
(defface custom-button
2212-
'((((type x w32 ns haiku pgtk wr) (class color)) ; Like default mode line
2212+
'((((type x w32 ns haiku pgtk winit) (class color)) ; Like default mode line
22132213
:box (:line-width 2 :style released-button)
22142214
:background "lightgrey" :foreground "black"))
22152215
"Face for custom buffer buttons if `custom-raised-buttons' is non-nil."
22162216
:version "21.1"
22172217
:group 'custom-faces)
22182218

22192219
(defface custom-button-mouse
2220-
'((((type x w32 ns haiku pgtk wr) (class color))
2220+
'((((type x w32 ns haiku pgtk winit) (class color))
22212221
:box (:line-width 2 :style released-button)
22222222
:background "grey90" :foreground "black")
22232223
(t
@@ -2242,7 +2242,7 @@ and `face'."
22422242
(if custom-raised-buttons 'custom-button-mouse 'highlight))
22432243

22442244
(defface custom-button-pressed
2245-
'((((type x w32 ns haiku pgtk wr) (class color))
2245+
'((((type x w32 ns haiku pgtk winit) (class color))
22462246
:box (:line-width 2 :style pressed-button)
22472247
:background "lightgrey" :foreground "black")
22482248
(t :inverse-video t))
@@ -3534,10 +3534,10 @@ GNUstep or Macintosh OS Cocoa interface.")
35343534
:sibling-args (:help-echo "\
35353535
Pure-GTK interface.")
35363536
ns)
3537-
(const :format "WR "
3537+
(const :format "winit"
35383538
:sibling-args (:help-echo "\
35393539
WebRender interface.")
3540-
ns)
3540+
winit)
35413541
(const :format "DOS "
35423542
:sibling-args (:help-echo "\
35433543
Plain MS-DOS.")

lisp/emacs-lisp/icons.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
:group 'customize)
3434

3535
(defface icon-button
36-
'((((type x w32 ns haiku pgtk wr) (class color))
36+
'((((type x w32 ns haiku pgtk winit) (class color))
3737
:inherit icon
3838
:box (:line-width (3 . -1) :color "#404040" :style flat-button)
3939
:background "#808080"

lisp/faces.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ an integer value."
12241224
(:height
12251225
'integerp)
12261226
(:stipple
1227-
(and (memq (window-system frame) '(x ns pgtk haiku wr)) ; No stipple on w32
1227+
(and (memq (window-system frame) '(x ns pgtk haiku winit)) ; No stipple on w32
12281228
(mapcar (lambda (item)
12291229
(cons item item))
12301230
(apply #'nconc
@@ -1569,7 +1569,7 @@ If FRAME is nil, the current FRAME is used."
15691569
match (cond ((eq req 'type)
15701570
(or (memq (window-system frame) options)
15711571
(and (memq 'graphic options)
1572-
(memq (window-system frame) '(x w32 ns pgtk wr)))
1572+
(memq (window-system frame) '(x w32 ns pgtk winit)))
15731573
;; FIXME: This should be revisited to use
15741574
;; display-graphic-p, provided that the
15751575
;; color selection depends on the number
@@ -2920,7 +2920,7 @@ Note: Other faces cannot inherit from the cursor face."
29202920
(((type haiku))
29212921
:foreground "B_MENU_ITEM_TEXT_COLOR"
29222922
:background "B_MENU_BACKGROUND_COLOR")
2923-
(((type x w32 ns pgtk wr) (class color))
2923+
(((type x w32 ns pgtk winit) (class color))
29242924
:background "grey75")
29252925
(((type x) (class mono))
29262926
:background "grey"))

0 commit comments

Comments
 (0)