mirror of
https://github.com/servo/servo.git
synced 2025-08-27 08:08:19 +01:00
Move windowing code out of the compositor
This is mainly just moving code around, in preparation for further changes to the "windowing" API.
This commit is contained in:
parent
bfb81a5d10
commit
77d32ee447
23 changed files with 828 additions and 206 deletions
|
@ -1,9 +1,11 @@
|
|||
CARGO_OPTS ?=
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
all: glut_app
|
||||
NDK_DEBUG=1 $(ANDROID_NDK)/ndk-build -B
|
||||
find ../../target ! \( -type d -name dist -prune \) -name libmozjs.so | \
|
||||
find glut_app/target ! \( -type d -name dist -prune \) -name libmozjs.so | \
|
||||
xargs -I {} cp -f {} libs/armeabi
|
||||
find ../../target ! \( -type d -name dist -prune \) -name 'libservo-*.so' | \
|
||||
find glut_app/target ! \( -type d -name dist -prune \) -name 'libglut_app-*.so' | \
|
||||
xargs -I {} cp -f {} libs/armeabi/libservo.so
|
||||
find ../../rust/lib/rustlib/arm-linux-androideabi/lib \
|
||||
-name '*.so' -type f -size +1c | \
|
||||
|
@ -14,6 +16,11 @@ all:
|
|||
--path .
|
||||
ant debug
|
||||
|
||||
.PHONY: glut_app
|
||||
glut_app:
|
||||
cd glut_app; \
|
||||
../../../mach cargo build --target=arm-linux-androideabi $(CARGO_OPTS)
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
$(ANDROID_SDK)/platform-tools/adb install -r bin/ServoAndroid-debug.apk
|
||||
|
|
519
ports/android/glut_app/Cargo.lock
generated
Normal file
519
ports/android/glut_app/Cargo.lock
generated
Normal file
|
@ -0,0 +1,519 @@
|
|||
[root]
|
||||
name = "glut_app"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"alert 0.1.0 (git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e)",
|
||||
"compositing 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"msg 0.0.1",
|
||||
"servo 0.0.1",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alert"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e"
|
||||
dependencies = [
|
||||
"cocoa 0.1.0 (git+https://github.com/servo/rust-cocoa#acb9b4efc70c3f285057c2aee774f38f81a1b98d)",
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "azure"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104)",
|
||||
"core_text 0.1.0 (git+https://github.com/servo/rust-core-text#1ad11072b31657eeccaf4879c6e98723d488bd3d)",
|
||||
"egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)",
|
||||
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
"skia-sys 0.0.20130412 (git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92)",
|
||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "canvas"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-cocoa#acb9b4efc70c3f285057c2aee774f38f81a1b98d"
|
||||
|
||||
[[package]]
|
||||
name = "compositing"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"alert 0.1.0 (git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e)",
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104)",
|
||||
"core_text 0.1.0 (git+https://github.com/servo/rust-core-text#1ad11072b31657eeccaf4879c6e98723d488bd3d)",
|
||||
"devtools 0.0.1",
|
||||
"devtools_traits 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"gfx 0.0.1",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"layout_traits 0.0.1",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79)",
|
||||
"script_traits 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core_foundation"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a"
|
||||
|
||||
[[package]]
|
||||
name = "core_graphics"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core_text"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-core-text#1ad11072b31657eeccaf4879c6e98723d488bd3d"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cssparser"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-cssparser#22146ce095cb62df39d459c3a79d1486041f96f6"
|
||||
dependencies = [
|
||||
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "devtools"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"devtools_traits 0.0.1",
|
||||
"msg 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "devtools_traits"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"msg 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "egl"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220"
|
||||
|
||||
[[package]]
|
||||
name = "encoding"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265"
|
||||
|
||||
[[package]]
|
||||
name = "expat-sys"
|
||||
version = "2.1.0"
|
||||
source = "git+https://github.com/servo/libexpat#da2ddaf78cbef836b8790807bb76b357c58df3a1"
|
||||
|
||||
[[package]]
|
||||
name = "fontconfig"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-fontconfig#b16c1e12ecb74b1e4e9a9b23c2b98580a34cf201"
|
||||
dependencies = [
|
||||
"fontconfig-sys 2.11.1 (git+https://github.com/servo/libfontconfig#fcc324d2c8175d2e8e8c0aab032c03a404809f6d)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontconfig-sys"
|
||||
version = "2.11.1"
|
||||
source = "git+https://github.com/servo/libfontconfig#fcc324d2c8175d2e8e8c0aab032c03a404809f6d"
|
||||
dependencies = [
|
||||
"expat-sys 2.1.0 (git+https://github.com/servo/libexpat#da2ddaf78cbef836b8790807bb76b357c58df3a1)",
|
||||
"freetype-sys 2.4.11 (git+https://github.com/servo/libfreetype2#5b6499164106f094937565595c7b96d07de55521)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "freetype"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70"
|
||||
|
||||
[[package]]
|
||||
name = "freetype-sys"
|
||||
version = "2.4.11"
|
||||
source = "git+https://github.com/servo/libfreetype2#5b6499164106f094937565595c7b96d07de55521"
|
||||
|
||||
[[package]]
|
||||
name = "geom"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d"
|
||||
|
||||
[[package]]
|
||||
name = "gfx"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)",
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104)",
|
||||
"core_text 0.1.0 (git+https://github.com/servo/rust-core-text#1ad11072b31657eeccaf4879c6e98723d488bd3d)",
|
||||
"fontconfig 0.1.0 (git+https://github.com/servo/rust-fontconfig#b16c1e12ecb74b1e4e9a9b23c2b98580a34cf201)",
|
||||
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"harfbuzz 0.1.0 (git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image#f5022de4ad6bb474a03493d1f274dde9b0f1af0c)",
|
||||
"style 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glfw"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b"
|
||||
dependencies = [
|
||||
"glfw-sys 3.0.4 (git+https://github.com/servo/glfw?ref=cargo-3.0.4#65a2b4721276589d9de24f6a9999a2db37286cae)",
|
||||
"semver 0.0.1 (git+https://github.com/rust-lang/semver#d04583a173395b76c1eaa15cc630a5f6f8f0ae10)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glfw-sys"
|
||||
version = "3.0.4"
|
||||
source = "git+https://github.com/servo/glfw?ref=cargo-3.0.4#65a2b4721276589d9de24f6a9999a2db37286cae"
|
||||
|
||||
[[package]]
|
||||
name = "glut"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949"
|
||||
dependencies = [
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "harfbuzz"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6"
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.1.0-pre"
|
||||
source = "git+https://github.com/servo/rust-http?ref=servo#92019011b0cdf1bffc8c584830de1bf330d79d0d"
|
||||
dependencies = [
|
||||
"openssl 0.0.0 (git+https://github.com/sfackler/rust-openssl.git#a495465b75ffb18ff2303c5a11a103e00a15a13d)",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hubbub"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-hubbub#c7f868e688de6e9cbdc26aa09292ed072bc2648b"
|
||||
dependencies = [
|
||||
"hubbub-sys 0.1.2 (git+https://github.com/servo/libhubbub#6d09893991dedc616b264058442a304c03842213)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hubbub-sys"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/servo/libhubbub#6d09893991dedc616b264058442a304c03842213"
|
||||
dependencies = [
|
||||
"parserutils-sys 0.1.1 (git+https://github.com/servo/libparserutils#651b636ba1214bceeb0907adb1eab60efe0d4598)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io_surface"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04"
|
||||
dependencies = [
|
||||
"mozjs-sys 0.0.0 (git+https://github.com/servo/mozjs#47cd6a4e60c75642ba182f0df9a42b71ec7c2c88)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "layers"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8"
|
||||
dependencies = [
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47)",
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
"xlib 0.1.0 (git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "layout"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"gfx 0.0.1",
|
||||
"layout_traits 0.0.1",
|
||||
"net 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"script 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"style 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "layout_traits"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"gfx 0.0.1",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360"
|
||||
|
||||
[[package]]
|
||||
name = "mozjs-sys"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/mozjs#47cd6a4e60c75642ba182f0df9a42b71ec7c2c88"
|
||||
|
||||
[[package]]
|
||||
name = "msg"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)",
|
||||
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation#166a601ff3e0fc3a64ca1a9090d02c8d4f22b61a)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"io_surface 0.1.0 (git+https://github.com/servo/rust-io-surface#7038341220bd7e86e21118fac2cbc6bd50890e47)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "net"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"http 0.1.0-pre (git+https://github.com/servo/rust-http?ref=servo#92019011b0cdf1bffc8c584830de1bf330d79d0d)",
|
||||
"png 0.1.0 (git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image#f5022de4ad6bb474a03493d1f274dde9b0f1af0c)",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opengles"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/sfackler/rust-openssl.git#a495465b75ffb18ff2303c5a11a103e00a15a13d"
|
||||
|
||||
[[package]]
|
||||
name = "parserutils-sys"
|
||||
version = "0.1.1"
|
||||
source = "git+https://github.com/servo/libparserutils#651b636ba1214bceeb0907adb1eab60efe0d4598"
|
||||
|
||||
[[package]]
|
||||
name = "phf"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0"
|
||||
|
||||
[[package]]
|
||||
name = "phf_mac"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0"
|
||||
|
||||
[[package]]
|
||||
name = "plugins"
|
||||
version = "0.0.1"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79"
|
||||
dependencies = [
|
||||
"png-sys 1.6.3 (git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc02b574f902e21a98)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png-sys"
|
||||
version = "1.6.3"
|
||||
source = "git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc02b574f902e21a98"
|
||||
|
||||
[[package]]
|
||||
name = "script"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"canvas 0.0.1",
|
||||
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser#22146ce095cb62df39d459c3a79d1486041f96f6)",
|
||||
"devtools_traits 0.0.1",
|
||||
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"gfx 0.0.1",
|
||||
"http 0.1.0-pre (git+https://github.com/servo/rust-http?ref=servo#92019011b0cdf1bffc8c584830de1bf330d79d0d)",
|
||||
"hubbub 0.1.0 (git+https://github.com/servo/rust-hubbub#c7f868e688de6e9cbdc26aa09292ed072bc2648b)",
|
||||
"js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"script_traits 0.0.1",
|
||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"style 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
"uuid 0.0.1 (git+https://github.com/rust-lang/uuid#c3041068f413a5e46d795d21a346072794593839)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "script_traits"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"devtools_traits 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/rust-lang/semver#d04583a173395b76c1eaa15cc630a5f6f8f0ae10"
|
||||
|
||||
[[package]]
|
||||
name = "servo"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"compositing 0.0.1",
|
||||
"gfx 0.0.1",
|
||||
"layout 0.0.1",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"script 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "skia-sys"
|
||||
version = "0.0.20130412"
|
||||
source = "git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92"
|
||||
dependencies = [
|
||||
"expat-sys 2.1.0 (git+https://github.com/servo/libexpat#da2ddaf78cbef836b8790807bb76b357c58df3a1)",
|
||||
"freetype-sys 2.4.11 (git+https://github.com/servo/libfreetype2#5b6499164106f094937565595c7b96d07de55521)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stb_image"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-stb-image#f5022de4ad6bb474a03493d1f274dde9b0f1af0c"
|
||||
|
||||
[[package]]
|
||||
name = "string_cache"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98"
|
||||
dependencies = [
|
||||
"phf 0.0.0 (git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0)",
|
||||
"phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "string_cache_macros"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98"
|
||||
dependencies = [
|
||||
"lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "style"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser#22146ce095cb62df39d459c3a79d1486041f96f6)",
|
||||
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360)",
|
||||
"plugins 0.0.1",
|
||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "task_info"
|
||||
version = "0.0.1"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243"
|
||||
dependencies = [
|
||||
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "util"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"azure 0.1.0 (git+https://github.com/servo/rust-azure#b357751c04a89a87e6ef1f0cebe5f20957dd112d)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache#97754929f38d93f6728d1f0acce8107648420e98)",
|
||||
"task_info 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/rust-lang/uuid#c3041068f413a5e46d795d21a346072794593839"
|
||||
|
||||
[[package]]
|
||||
name = "xlib"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c"
|
||||
|
34
ports/android/glut_app/Cargo.toml
Normal file
34
ports/android/glut_app/Cargo.toml
Normal file
|
@ -0,0 +1,34 @@
|
|||
[package]
|
||||
name = "glut_app"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
|
||||
[lib]
|
||||
name = "glut_app"
|
||||
path = "lib.rs"
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies.alert]
|
||||
git = "https://github.com/servo/rust-alert"
|
||||
|
||||
[dependencies.compositing]
|
||||
path = "../../../components/compositing"
|
||||
|
||||
[dependencies.geom]
|
||||
git = "https://github.com/servo/rust-geom"
|
||||
|
||||
[dependencies.glut]
|
||||
git = "https://github.com/servo/rust-glut"
|
||||
|
||||
[dependencies.layers]
|
||||
git = "https://github.com/servo/rust-layers"
|
||||
|
||||
[dependencies.msg]
|
||||
path = "../../../components/msg"
|
||||
|
||||
[dependencies.servo]
|
||||
path = "../../.."
|
||||
default-features = false
|
||||
|
||||
[dependencies.util]
|
||||
path = "../../../components/util"
|
64
ports/android/glut_app/lib.rs
Normal file
64
ports/android/glut_app/lib.rs
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A simple application that uses GLUT to open a window for Servo to display in.
|
||||
|
||||
#![license = "MPL"]
|
||||
#![feature(macro_rules, phase)]
|
||||
#![deny(unused_imports, unused_variable)]
|
||||
|
||||
extern crate alert;
|
||||
extern crate compositing;
|
||||
extern crate geom;
|
||||
extern crate glut;
|
||||
extern crate layers;
|
||||
extern crate libc;
|
||||
#[phase(plugin, link)] extern crate log;
|
||||
extern crate msg;
|
||||
extern crate native;
|
||||
extern crate servo;
|
||||
#[phase(plugin, link)] extern crate util;
|
||||
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use std::rc::Rc;
|
||||
use std::string;
|
||||
use util::opts;
|
||||
use window::Window;
|
||||
|
||||
use glut::glut::{init, init_display_mode, DOUBLE};
|
||||
|
||||
mod window;
|
||||
|
||||
pub fn create_window(opts: &opts::Opts) -> Rc<Window> {
|
||||
// Initialize GLUT.
|
||||
init();
|
||||
init_display_mode(DOUBLE);
|
||||
|
||||
// Read command-line options.
|
||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
||||
|
||||
// Open a window.
|
||||
Window::new(size.as_uint())
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[allow(dead_code)]
|
||||
pub extern "C" fn android_start(argc: int, argv: *const *const u8) -> int {
|
||||
native::start(argc, argv, proc() {
|
||||
let mut args: Vec<String> = vec!();
|
||||
for i in range(0u, argc as uint) {
|
||||
unsafe {
|
||||
args.push(string::raw::from_buf(*argv.offset(i as int) as *const u8));
|
||||
}
|
||||
}
|
||||
|
||||
opts::from_cmdline_args(args.as_slice()).map(|mut opts| {
|
||||
// Always use CPU rendering on android.
|
||||
opts.cpu_painting = true;
|
||||
let window = Some(create_window(&opts));
|
||||
servo::run(opts, window);
|
||||
});
|
||||
})
|
||||
}
|
295
ports/android/glut_app/window.rs
Normal file
295
ports/android/glut_app/window.rs
Normal file
|
@ -0,0 +1,295 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A windowing implementation using GLUT.
|
||||
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent, LoadUrlWindowEvent, MouseWindowEventClass};
|
||||
use compositing::windowing::{ScrollWindowEvent, ZoomWindowEvent, NavigationWindowEvent, FinishedWindowEvent};
|
||||
use compositing::windowing::{MouseWindowClickEvent, MouseWindowMouseDownEvent, MouseWindowMouseUpEvent};
|
||||
use compositing::windowing::{Forward, Back};
|
||||
|
||||
use alert::{Alert, AlertMethods};
|
||||
use libc::{c_int, c_uchar};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use layers::geometry::DevicePixel;
|
||||
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
|
||||
use msg::compositor_msg::{FinishedLoading, Blank, ReadyState};
|
||||
use util::geometry::ScreenPx;
|
||||
|
||||
use glut::glut::{ACTIVE_SHIFT, WindowHeight};
|
||||
use glut::glut::WindowWidth;
|
||||
use glut::glut;
|
||||
|
||||
// static THROBBER: [char, ..8] = [ '⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷' ];
|
||||
|
||||
/// The type of a window.
|
||||
pub struct Window {
|
||||
pub glut_window: glut::Window,
|
||||
|
||||
pub event_queue: RefCell<Vec<WindowEvent>>,
|
||||
|
||||
pub drag_origin: Point2D<c_int>,
|
||||
|
||||
pub mouse_down_button: Cell<c_int>,
|
||||
pub mouse_down_point: Cell<Point2D<c_int>>,
|
||||
|
||||
pub ready_state: Cell<ReadyState>,
|
||||
pub render_state: Cell<RenderState>,
|
||||
pub throbber_frame: Cell<u8>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
/// Creates a new window.
|
||||
pub fn new(size: TypedSize2D<DevicePixel, uint>) -> Rc<Window> {
|
||||
// Create the GLUT window.
|
||||
let window_size = size.to_untyped();
|
||||
glut::init_window_size(window_size.width, window_size.height);
|
||||
let glut_window = glut::create_window("Servo".to_string());
|
||||
|
||||
// Create our window object.
|
||||
let window = Window {
|
||||
glut_window: glut_window,
|
||||
|
||||
event_queue: RefCell::new(vec!()),
|
||||
|
||||
drag_origin: Point2D(0 as c_int, 0),
|
||||
|
||||
mouse_down_button: Cell::new(0),
|
||||
mouse_down_point: Cell::new(Point2D(0 as c_int, 0)),
|
||||
|
||||
ready_state: Cell::new(Blank),
|
||||
render_state: Cell::new(IdleRenderState),
|
||||
throbber_frame: Cell::new(0),
|
||||
};
|
||||
|
||||
// Register event handlers.
|
||||
|
||||
//Added dummy display callback to freeglut. According to freeglut ref, we should register some kind of display callback after freeglut 3.0.
|
||||
|
||||
struct DisplayCallbackState;
|
||||
impl glut::DisplayCallback for DisplayCallbackState {
|
||||
fn call(&self) {
|
||||
debug!("GLUT display func registgered");
|
||||
}
|
||||
}
|
||||
glut::display_func(box DisplayCallbackState);
|
||||
struct ReshapeCallbackState;
|
||||
impl glut::ReshapeCallback for ReshapeCallbackState {
|
||||
fn call(&self, width: c_int, height: c_int) {
|
||||
let tmp = local_window();
|
||||
tmp.event_queue.borrow_mut().push(ResizeWindowEvent(TypedSize2D(width as uint, height as uint)))
|
||||
}
|
||||
}
|
||||
glut::reshape_func(glut_window, box ReshapeCallbackState);
|
||||
struct KeyboardCallbackState;
|
||||
impl glut::KeyboardCallback for KeyboardCallbackState {
|
||||
fn call(&self, key: c_uchar, _x: c_int, _y: c_int) {
|
||||
let tmp = local_window();
|
||||
tmp.handle_key(key)
|
||||
}
|
||||
}
|
||||
glut::keyboard_func(box KeyboardCallbackState);
|
||||
struct MouseCallbackState;
|
||||
impl glut::MouseCallback for MouseCallbackState {
|
||||
fn call(&self, button: c_int, state: c_int, x: c_int, y: c_int) {
|
||||
if button < 3 {
|
||||
let tmp = local_window();
|
||||
tmp.handle_mouse(button, state, x, y);
|
||||
} else {
|
||||
match button {
|
||||
3 => {
|
||||
let tmp = local_window();
|
||||
tmp.event_queue.borrow_mut().push(ScrollWindowEvent(
|
||||
TypedPoint2D(0.0f32, 5.0f32),
|
||||
TypedPoint2D(0i32, 5i32)));
|
||||
},
|
||||
4 => {
|
||||
let tmp = local_window();
|
||||
tmp.event_queue.borrow_mut().push(ScrollWindowEvent(
|
||||
TypedPoint2D(0.0f32, -5.0f32),
|
||||
TypedPoint2D(0i32, -5i32)));
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
glut::mouse_func(box MouseCallbackState);
|
||||
|
||||
let wrapped_window = Rc::new(window);
|
||||
|
||||
install_local_window(wrapped_window.clone());
|
||||
|
||||
wrapped_window
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
fn drop(&mut self) {
|
||||
drop_local_window();
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowMethods for Window {
|
||||
/// Returns the size of the window in hardware pixels.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint> {
|
||||
TypedSize2D(glut::get(WindowWidth) as uint, glut::get(WindowHeight) as uint)
|
||||
}
|
||||
|
||||
/// Returns the size of the window in density-independent "px" units.
|
||||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
self.framebuffer_size().as_f32() / self.hidpi_factor()
|
||||
}
|
||||
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self) {
|
||||
glut::swap_buffers();
|
||||
}
|
||||
|
||||
fn recv(&self) -> WindowEvent {
|
||||
if !self.event_queue.borrow_mut().is_empty() {
|
||||
return self.event_queue.borrow_mut().remove(0).unwrap();
|
||||
}
|
||||
|
||||
glut::check_loop();
|
||||
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
|
||||
}
|
||||
|
||||
/// Sets the ready state.
|
||||
fn set_ready_state(&self, ready_state: ReadyState) {
|
||||
self.ready_state.set(ready_state);
|
||||
//FIXME: set_window_title causes crash with Android version of freeGLUT. Temporarily blocked.
|
||||
//self.update_window_title()
|
||||
}
|
||||
|
||||
/// Sets the render state.
|
||||
fn set_render_state(&self, render_state: RenderState) {
|
||||
if self.ready_state.get() == FinishedLoading &&
|
||||
self.render_state.get() == RenderingRenderState &&
|
||||
render_state == IdleRenderState {
|
||||
// page loaded
|
||||
self.event_queue.borrow_mut().push(FinishedWindowEvent);
|
||||
}
|
||||
|
||||
self.render_state.set(render_state);
|
||||
//FIXME: set_window_title causes crash with Android version of freeGLUT. Temporarily blocked.
|
||||
//self.update_window_title()
|
||||
}
|
||||
|
||||
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
||||
//FIXME: Do nothing in GLUT now.
|
||||
ScaleFactor(1.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
/// Helper function to set the window title in accordance with the ready state.
|
||||
// fn update_window_title(&self) {
|
||||
// let throbber = THROBBER[self.throbber_frame];
|
||||
// match self.ready_state {
|
||||
// Blank => {
|
||||
// glut::set_window_title(self.glut_window, "Blank")
|
||||
// }
|
||||
// Loading => {
|
||||
// glut::set_window_title(self.glut_window, format!("{:c} Loading . Servo", throbber))
|
||||
// }
|
||||
// PerformingLayout => {
|
||||
// glut::set_window_title(self.glut_window, format!("{:c} Performing Layout . Servo", throbber))
|
||||
// }
|
||||
// FinishedLoading => {
|
||||
// match self.render_state {
|
||||
// RenderingRenderState => {
|
||||
// glut::set_window_title(self.glut_window, format!("{:c} Rendering . Servo", throbber))
|
||||
// }
|
||||
// IdleRenderState => glut::set_window_title(self.glut_window, "Servo"),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// Helper function to handle keyboard events.
|
||||
fn handle_key(&self, key: u8) {
|
||||
debug!("got key: {}", key);
|
||||
let modifiers = glut::get_modifiers();
|
||||
match key {
|
||||
42 => self.load_url(),
|
||||
43 => self.event_queue.borrow_mut().push(ZoomWindowEvent(1.1)),
|
||||
45 => self.event_queue.borrow_mut().push(ZoomWindowEvent(0.909090909)),
|
||||
56 => self.event_queue.borrow_mut().push(ScrollWindowEvent(TypedPoint2D(0.0f32, 5.0f32),
|
||||
TypedPoint2D(0i32, 5i32))),
|
||||
50 => self.event_queue.borrow_mut().push(ScrollWindowEvent(TypedPoint2D(0.0f32, -5.0f32),
|
||||
TypedPoint2D(0i32, -5i32))),
|
||||
127 => {
|
||||
if (modifiers & ACTIVE_SHIFT) != 0 {
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Forward));
|
||||
}
|
||||
else {
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Back));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to handle a click
|
||||
fn handle_mouse(&self, button: c_int, state: c_int, x: c_int, y: c_int) {
|
||||
// FIXME(tkuehn): max pixel dist should be based on pixel density
|
||||
let max_pixel_dist = 10f32;
|
||||
let event = match state {
|
||||
glut::MOUSE_DOWN => {
|
||||
self.mouse_down_point.set(Point2D(x, y));
|
||||
self.mouse_down_button.set(button);
|
||||
MouseWindowMouseDownEvent(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||
}
|
||||
glut::MOUSE_UP => {
|
||||
if self.mouse_down_button.get() == button {
|
||||
let pixel_dist = self.mouse_down_point.get() - Point2D(x, y);
|
||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||
pixel_dist.y * pixel_dist.y) as f32).sqrt();
|
||||
if pixel_dist < max_pixel_dist {
|
||||
let click_event = MouseWindowClickEvent(button as uint,
|
||||
TypedPoint2D(x as f32, y as f32));
|
||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
||||
}
|
||||
}
|
||||
MouseWindowMouseUpEvent(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||
}
|
||||
_ => fail!("I cannot recognize the type of mouse action that occured. :-(")
|
||||
};
|
||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(event));
|
||||
}
|
||||
|
||||
/// Helper function to pop up an alert box prompting the user to load a URL.
|
||||
fn load_url(&self) {
|
||||
let mut alert: Alert = AlertMethods::new("Navigate to:");
|
||||
alert.add_prompt();
|
||||
alert.run();
|
||||
let value = alert.prompt_value();
|
||||
if "" == value.as_slice() { // To avoid crashing on Linux.
|
||||
self.event_queue.borrow_mut().push(LoadUrlWindowEvent("http://purple.com/".to_string()))
|
||||
} else {
|
||||
self.event_queue.borrow_mut().push(LoadUrlWindowEvent(value.clone()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local_data_key!(TLS_KEY: Rc<Window>)
|
||||
|
||||
fn install_local_window(window: Rc<Window>) {
|
||||
TLS_KEY.replace(Some(window));
|
||||
}
|
||||
|
||||
fn drop_local_window() {
|
||||
TLS_KEY.replace(None);
|
||||
}
|
||||
|
||||
fn local_window() -> Rc<Window> {
|
||||
TLS_KEY.get().unwrap().clone()
|
||||
}
|
23
ports/cef/Cargo.lock
generated
23
ports/cef/Cargo.lock
generated
|
@ -8,8 +8,8 @@ dependencies = [
|
|||
"devtools 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"gfx 0.0.1",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)",
|
||||
"glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b)",
|
||||
"glfw_app 0.0.1",
|
||||
"js 0.1.0 (git+https://github.com/servo/rust-mozjs#41fb0d80a5ed5614ca13a120cdb3281e599d4e04)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"msg 0.0.1",
|
||||
|
@ -44,7 +44,7 @@ dependencies = [
|
|||
"egl 0.1.0 (git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c31b3e220)",
|
||||
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70)",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
"skia-sys 0.0.20130412 (git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92)",
|
||||
|
@ -76,8 +76,6 @@ dependencies = [
|
|||
"devtools_traits 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"gfx 0.0.1",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e)",
|
||||
"glut 0.0.1 (git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"layout_traits 0.0.1",
|
||||
"msg 0.0.1",
|
||||
|
@ -207,7 +205,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "glfw"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/glfw-rs?ref=servo#955dbe919870b0536f79123232d87c0efe3c552e"
|
||||
source = "git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b"
|
||||
dependencies = [
|
||||
"glfw-sys 3.0.4 (git+https://github.com/servo/glfw?ref=cargo-3.0.4#65a2b4721276589d9de24f6a9999a2db37286cae)",
|
||||
"semver 0.0.1 (git+https://github.com/rust-lang/semver#d04583a173395b76c1eaa15cc630a5f6f8f0ae10)",
|
||||
|
@ -219,11 +217,16 @@ version = "3.0.4"
|
|||
source = "git+https://github.com/servo/glfw?ref=cargo-3.0.4#65a2b4721276589d9de24f6a9999a2db37286cae"
|
||||
|
||||
[[package]]
|
||||
name = "glut"
|
||||
name = "glfw_app"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/servo/rust-glut#01af0162ea0322ad1a40d6adb023a39813605949"
|
||||
dependencies = [
|
||||
"opengles 0.1.0 (git+https://github.com/servo/rust-opengles#6776e9c07feb149d34b087039ecf6b2c143e3afc)",
|
||||
"alert 0.1.0 (git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e)",
|
||||
"compositing 0.0.1",
|
||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom#90add8d65273c8a46aa16d73959e29a51d0c282d)",
|
||||
"glfw 0.0.1 (git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b)",
|
||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers#180d3ff2f28d239e32d01982c76be5c97d5763a8)",
|
||||
"msg 0.0.1",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -428,6 +431,7 @@ dependencies = [
|
|||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
"url 0.1.0 (git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243)",
|
||||
"util 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -441,6 +445,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"compositing 0.0.1",
|
||||
"gfx 0.0.1",
|
||||
"glfw_app 0.0.1",
|
||||
"layout 0.0.1",
|
||||
"msg 0.0.1",
|
||||
"net 0.0.1",
|
||||
|
|
|
@ -11,6 +11,9 @@ crate-type = ["dylib"]
|
|||
[dependencies.servo]
|
||||
path = "../.."
|
||||
|
||||
[dependencies.glfw_app]
|
||||
path = "../glfw"
|
||||
|
||||
[dependencies.plugins]
|
||||
path = "../../components/plugins"
|
||||
|
||||
|
@ -45,9 +48,6 @@ git = "https://github.com/servo/rust-geom"
|
|||
git = "https://github.com/servo/glfw-rs"
|
||||
branch = "servo"
|
||||
|
||||
[dependencies.glut]
|
||||
git = "https://github.com/servo/rust-glut"
|
||||
|
||||
[dependencies.js]
|
||||
git = "https://github.com/servo/rust-mozjs"
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use azure;
|
|||
use command_line::command_line_init;
|
||||
use eutil::fptr_is_null;
|
||||
use geom::size::TypedSize2D;
|
||||
use glfw_app;
|
||||
use libc::{c_int, c_void};
|
||||
use native;
|
||||
use servo;
|
||||
|
@ -74,7 +75,8 @@ pub extern "C" fn cef_run_message_loop() {
|
|||
dump_flow_tree: false,
|
||||
};
|
||||
native::start(0, 0 as *const *const u8, proc() {
|
||||
servo::run(opts);
|
||||
let window = Some(glfw_app::create_window(&opts));
|
||||
servo::run(opts, window);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,8 @@ extern crate servo;
|
|||
extern crate azure;
|
||||
extern crate geom;
|
||||
extern crate gfx;
|
||||
#[cfg(not(target_os="android"))]
|
||||
extern crate glfw;
|
||||
#[cfg(target_os="android")]
|
||||
extern crate glut;
|
||||
extern crate glfw_app;
|
||||
extern crate js;
|
||||
extern crate layers;
|
||||
extern crate opengles;
|
||||
|
|
30
ports/glfw/Cargo.toml
Normal file
30
ports/glfw/Cargo.toml
Normal file
|
@ -0,0 +1,30 @@
|
|||
[package]
|
||||
name = "glfw_app"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
|
||||
[lib]
|
||||
name = "glfw_app"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies.alert]
|
||||
git = "https://github.com/servo/rust-alert"
|
||||
|
||||
[dependencies.compositing]
|
||||
path = "../../components/compositing"
|
||||
|
||||
[dependencies.geom]
|
||||
git = "https://github.com/servo/rust-geom"
|
||||
|
||||
[dependencies.glfw]
|
||||
git = "https://github.com/servo/glfw-rs"
|
||||
branch = "servo"
|
||||
|
||||
[dependencies.layers]
|
||||
git = "https://github.com/servo/rust-layers"
|
||||
|
||||
[dependencies.msg]
|
||||
path = "../../components/msg"
|
||||
|
||||
[dependencies.util]
|
||||
path = "../../components/util"
|
43
ports/glfw/lib.rs
Normal file
43
ports/glfw/lib.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A simple application that uses GLFW to open a window for Servo to display in.
|
||||
|
||||
#![license = "MPL"]
|
||||
#![feature(macro_rules)]
|
||||
#![deny(unused_imports, unused_variable)]
|
||||
|
||||
extern crate alert;
|
||||
extern crate compositing;
|
||||
extern crate geom;
|
||||
extern crate glfw;
|
||||
extern crate layers;
|
||||
extern crate libc;
|
||||
extern crate msg;
|
||||
extern crate time;
|
||||
extern crate util;
|
||||
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use std::rc::Rc;
|
||||
use window::Window;
|
||||
|
||||
mod window;
|
||||
|
||||
pub fn create_window(opts: &util::opts::Opts) -> Rc<Window> {
|
||||
// Initialize GLFW.
|
||||
let glfw = glfw::init(glfw::LOG_ERRORS).unwrap_or_else(|_| {
|
||||
// handles things like inability to connect to X
|
||||
// cannot simply fail, since the runtime isn't up yet (causes a nasty abort)
|
||||
println!("GLFW initialization failed");
|
||||
unsafe { libc::exit(1); }
|
||||
});
|
||||
|
||||
// Read command-line options.
|
||||
let foreground = opts.output_file.is_none();
|
||||
let scale_factor = opts.device_pixels_per_px.unwrap_or(ScaleFactor(1.0));
|
||||
let size = opts.initial_window_size.as_f32() * scale_factor;
|
||||
|
||||
// Open a window.
|
||||
Window::new(glfw, foreground, size.as_uint())
|
||||
}
|
365
ports/glfw/window.rs
Normal file
365
ports/glfw/window.rs
Normal file
|
@ -0,0 +1,365 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! A windowing implementation using GLFW.
|
||||
|
||||
use compositing::windowing::{WindowEvent, WindowMethods};
|
||||
use compositing::windowing::{IdleWindowEvent, ResizeWindowEvent, LoadUrlWindowEvent, MouseWindowEventClass, MouseWindowMoveEventClass};
|
||||
use compositing::windowing::{ScrollWindowEvent, ZoomWindowEvent, PinchZoomWindowEvent, NavigationWindowEvent, FinishedWindowEvent};
|
||||
use compositing::windowing::{QuitWindowEvent, MouseWindowClickEvent, MouseWindowMouseDownEvent, MouseWindowMouseUpEvent};
|
||||
use compositing::windowing::RefreshWindowEvent;
|
||||
use compositing::windowing::{Forward, Back};
|
||||
|
||||
use alert::{Alert, AlertMethods};
|
||||
use libc::c_int;
|
||||
use time;
|
||||
use time::Timespec;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::comm::Receiver;
|
||||
use std::rc::Rc;
|
||||
|
||||
use geom::point::{Point2D, TypedPoint2D};
|
||||
use geom::scale_factor::ScaleFactor;
|
||||
use geom::size::TypedSize2D;
|
||||
use layers::geometry::DevicePixel;
|
||||
use msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
|
||||
use msg::compositor_msg::{FinishedLoading, Blank, Loading, PerformingLayout, ReadyState};
|
||||
use util::geometry::ScreenPx;
|
||||
|
||||
use glfw;
|
||||
use glfw::Context;
|
||||
|
||||
/// A structure responsible for setting up and tearing down the entire windowing system.
|
||||
macro_rules! glfw_callback(
|
||||
(
|
||||
$callback:path ($($arg:ident: $arg_ty:ty),*) $block:expr
|
||||
) => ({
|
||||
struct GlfwCallback;
|
||||
impl $callback for GlfwCallback {
|
||||
fn call(&self $(, $arg: $arg_ty)*) {
|
||||
$block
|
||||
}
|
||||
}
|
||||
~GlfwCallback
|
||||
});
|
||||
|
||||
(
|
||||
[$($state:ident: $state_ty:ty),*],
|
||||
$callback:path ($($arg:ident: $arg_ty:ty),*) $block:expr
|
||||
) => ({
|
||||
struct GlfwCallback {
|
||||
$($state: $state_ty,)*
|
||||
}
|
||||
impl $callback for GlfwCallback {
|
||||
fn call(&self $(, $arg: $arg_ty)*) {
|
||||
$block
|
||||
}
|
||||
}
|
||||
~GlfwCallback {
|
||||
$($state: $state,)*
|
||||
}
|
||||
});
|
||||
)
|
||||
|
||||
|
||||
/// The type of a window.
|
||||
pub struct Window {
|
||||
glfw: glfw::Glfw,
|
||||
|
||||
glfw_window: glfw::Window,
|
||||
events: Receiver<(f64, glfw::WindowEvent)>,
|
||||
|
||||
event_queue: RefCell<Vec<WindowEvent>>,
|
||||
|
||||
mouse_down_button: Cell<Option<glfw::MouseButton>>,
|
||||
mouse_down_point: Cell<Point2D<c_int>>,
|
||||
|
||||
ready_state: Cell<ReadyState>,
|
||||
render_state: Cell<RenderState>,
|
||||
|
||||
last_title_set_time: Cell<Timespec>,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
/// Creates a new window.
|
||||
pub fn new(glfw: glfw::Glfw, is_foreground: bool, size: TypedSize2D<DevicePixel, uint>)
|
||||
-> Rc<Window> {
|
||||
// Create the GLFW window.
|
||||
let window_size = size.to_untyped();
|
||||
glfw.window_hint(glfw::Visible(is_foreground));
|
||||
let (glfw_window, events) = glfw.create_window(window_size.width as u32,
|
||||
window_size.height as u32,
|
||||
"Servo", glfw::Windowed)
|
||||
.expect("Failed to create GLFW window");
|
||||
glfw_window.make_current();
|
||||
|
||||
// Create our window object.
|
||||
let window = Window {
|
||||
glfw: glfw,
|
||||
|
||||
glfw_window: glfw_window,
|
||||
events: events,
|
||||
|
||||
event_queue: RefCell::new(vec!()),
|
||||
|
||||
mouse_down_button: Cell::new(None),
|
||||
mouse_down_point: Cell::new(Point2D(0 as c_int, 0)),
|
||||
|
||||
ready_state: Cell::new(Blank),
|
||||
render_state: Cell::new(IdleRenderState),
|
||||
|
||||
last_title_set_time: Cell::new(Timespec::new(0, 0)),
|
||||
};
|
||||
|
||||
// Register event handlers.
|
||||
window.glfw_window.set_framebuffer_size_polling(true);
|
||||
window.glfw_window.set_refresh_polling(true);
|
||||
window.glfw_window.set_key_polling(true);
|
||||
window.glfw_window.set_mouse_button_polling(true);
|
||||
window.glfw_window.set_cursor_pos_polling(true);
|
||||
window.glfw_window.set_scroll_polling(true);
|
||||
|
||||
let wrapped_window = Rc::new(window);
|
||||
|
||||
wrapped_window
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowMethods for Window {
|
||||
/// Returns the size of the window in hardware pixels.
|
||||
fn framebuffer_size(&self) -> TypedSize2D<DevicePixel, uint> {
|
||||
let (width, height) = self.glfw_window.get_framebuffer_size();
|
||||
TypedSize2D(width as uint, height as uint)
|
||||
}
|
||||
|
||||
/// Returns the size of the window in density-independent "px" units.
|
||||
fn size(&self) -> TypedSize2D<ScreenPx, f32> {
|
||||
let (width, height) = self.glfw_window.get_size();
|
||||
TypedSize2D(width as f32, height as f32)
|
||||
}
|
||||
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self) {
|
||||
self.glfw_window.swap_buffers();
|
||||
}
|
||||
|
||||
fn recv(&self) -> WindowEvent {
|
||||
{
|
||||
let mut event_queue = self.event_queue.borrow_mut();
|
||||
if !event_queue.is_empty() {
|
||||
return event_queue.remove(0).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
self.glfw.poll_events();
|
||||
for (_, event) in glfw::flush_messages(&self.events) {
|
||||
self.handle_window_event(&self.glfw_window, event);
|
||||
}
|
||||
|
||||
if self.glfw_window.should_close() {
|
||||
QuitWindowEvent
|
||||
} else {
|
||||
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the ready state.
|
||||
fn set_ready_state(&self, ready_state: ReadyState) {
|
||||
self.ready_state.set(ready_state);
|
||||
self.update_window_title()
|
||||
}
|
||||
|
||||
/// Sets the render state.
|
||||
fn set_render_state(&self, render_state: RenderState) {
|
||||
if self.ready_state.get() == FinishedLoading &&
|
||||
self.render_state.get() == RenderingRenderState &&
|
||||
render_state == IdleRenderState {
|
||||
// page loaded
|
||||
self.event_queue.borrow_mut().push(FinishedWindowEvent);
|
||||
}
|
||||
|
||||
self.render_state.set(render_state);
|
||||
self.update_window_title()
|
||||
}
|
||||
|
||||
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32> {
|
||||
let backing_size = self.framebuffer_size().width.get();
|
||||
let window_size = self.size().width.get();
|
||||
ScaleFactor((backing_size as f32) / window_size)
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
fn handle_window_event(&self, window: &glfw::Window, event: glfw::WindowEvent) {
|
||||
match event {
|
||||
glfw::KeyEvent(key, _, action, mods) => {
|
||||
if action == glfw::Press {
|
||||
self.handle_key(key, mods)
|
||||
}
|
||||
},
|
||||
glfw::FramebufferSizeEvent(width, height) => {
|
||||
self.event_queue.borrow_mut().push(
|
||||
ResizeWindowEvent(TypedSize2D(width as uint, height as uint)));
|
||||
},
|
||||
glfw::RefreshEvent => {
|
||||
self.event_queue.borrow_mut().push(RefreshWindowEvent);
|
||||
},
|
||||
glfw::MouseButtonEvent(button, action, _mods) => {
|
||||
let (x, y) = window.get_cursor_pos();
|
||||
//handle hidpi displays, since GLFW returns non-hi-def coordinates.
|
||||
let (backing_size, _) = window.get_framebuffer_size();
|
||||
let (window_size, _) = window.get_size();
|
||||
let hidpi = (backing_size as f32) / (window_size as f32);
|
||||
let x = x as f32 * hidpi;
|
||||
let y = y as f32 * hidpi;
|
||||
if button == glfw::MouseButtonLeft || button == glfw::MouseButtonRight {
|
||||
self.handle_mouse(button, action, x as i32, y as i32);
|
||||
}
|
||||
},
|
||||
glfw::CursorPosEvent(xpos, ypos) => {
|
||||
self.event_queue.borrow_mut().push(
|
||||
MouseWindowMoveEventClass(TypedPoint2D(xpos as f32, ypos as f32)));
|
||||
},
|
||||
glfw::ScrollEvent(xpos, ypos) => {
|
||||
match (window.get_key(glfw::KeyLeftControl),
|
||||
window.get_key(glfw::KeyRightControl)) {
|
||||
(glfw::Press, _) | (_, glfw::Press) => {
|
||||
// Ctrl-Scrollwheel simulates a "pinch zoom" gesture.
|
||||
if ypos < 0.0 {
|
||||
self.event_queue.borrow_mut().push(PinchZoomWindowEvent(1.0/1.1));
|
||||
} else if ypos > 0.0 {
|
||||
self.event_queue.borrow_mut().push(PinchZoomWindowEvent(1.1));
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
let dx = (xpos as f32) * 30.0;
|
||||
let dy = (ypos as f32) * 30.0;
|
||||
self.scroll_window(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to send a scroll event.
|
||||
fn scroll_window(&self, dx: f32, dy: f32) {
|
||||
let (x, y) = self.glfw_window.get_cursor_pos();
|
||||
//handle hidpi displays, since GLFW returns non-hi-def coordinates.
|
||||
let (backing_size, _) = self.glfw_window.get_framebuffer_size();
|
||||
let (window_size, _) = self.glfw_window.get_size();
|
||||
let hidpi = (backing_size as f32) / (window_size as f32);
|
||||
let x = x as f32 * hidpi;
|
||||
let y = y as f32 * hidpi;
|
||||
|
||||
self.event_queue.borrow_mut().push(ScrollWindowEvent(TypedPoint2D(dx, dy),
|
||||
TypedPoint2D(x as i32, y as i32)));
|
||||
}
|
||||
|
||||
/// Helper function to set the window title in accordance with the ready state.
|
||||
fn update_window_title(&self) {
|
||||
let now = time::get_time();
|
||||
if now.sec == self.last_title_set_time.get().sec {
|
||||
return
|
||||
}
|
||||
self.last_title_set_time.set(now);
|
||||
|
||||
match self.ready_state.get() {
|
||||
Blank => {
|
||||
self.glfw_window.set_title("blank — Servo")
|
||||
}
|
||||
Loading => {
|
||||
self.glfw_window.set_title("Loading — Servo")
|
||||
}
|
||||
PerformingLayout => {
|
||||
self.glfw_window.set_title("Performing Layout — Servo")
|
||||
}
|
||||
FinishedLoading => {
|
||||
match self.render_state.get() {
|
||||
RenderingRenderState => {
|
||||
self.glfw_window.set_title("Rendering — Servo")
|
||||
}
|
||||
IdleRenderState => {
|
||||
self.glfw_window.set_title("Servo")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to handle keyboard events.
|
||||
fn handle_key(&self, key: glfw::Key, mods: glfw::Modifiers) {
|
||||
match key {
|
||||
glfw::KeyEscape => self.glfw_window.set_should_close(true),
|
||||
glfw::KeyL if mods.contains(glfw::Control) => self.load_url(), // Ctrl+L
|
||||
glfw::KeyEqual if mods.contains(glfw::Control) => { // Ctrl-+
|
||||
self.event_queue.borrow_mut().push(ZoomWindowEvent(1.1));
|
||||
}
|
||||
glfw::KeyMinus if mods.contains(glfw::Control) => { // Ctrl--
|
||||
self.event_queue.borrow_mut().push(ZoomWindowEvent(1.0/1.1));
|
||||
}
|
||||
glfw::KeyBackspace if mods.contains(glfw::Shift) => { // Shift-Backspace
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Forward));
|
||||
}
|
||||
glfw::KeyBackspace => { // Backspace
|
||||
self.event_queue.borrow_mut().push(NavigationWindowEvent(Back));
|
||||
}
|
||||
glfw::KeyPageDown => {
|
||||
let (_, height) = self.glfw_window.get_size();
|
||||
self.scroll_window(0.0, -height as f32);
|
||||
}
|
||||
glfw::KeyPageUp => {
|
||||
let (_, height) = self.glfw_window.get_size();
|
||||
self.scroll_window(0.0, height as f32);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper function to handle a click
|
||||
fn handle_mouse(&self, button: glfw::MouseButton, action: glfw::Action, x: c_int, y: c_int) {
|
||||
// FIXME(tkuehn): max pixel dist should be based on pixel density
|
||||
let max_pixel_dist = 10f64;
|
||||
let event = match action {
|
||||
glfw::Press => {
|
||||
self.mouse_down_point.set(Point2D(x, y));
|
||||
self.mouse_down_button.set(Some(button));
|
||||
MouseWindowMouseDownEvent(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||
}
|
||||
glfw::Release => {
|
||||
match self.mouse_down_button.get() {
|
||||
None => (),
|
||||
Some(but) if button == but => {
|
||||
let pixel_dist = self.mouse_down_point.get() - Point2D(x, y);
|
||||
let pixel_dist = ((pixel_dist.x * pixel_dist.x +
|
||||
pixel_dist.y * pixel_dist.y) as f64).sqrt();
|
||||
if pixel_dist < max_pixel_dist {
|
||||
let click_event = MouseWindowClickEvent(button as uint,
|
||||
TypedPoint2D(x as f32, y as f32));
|
||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(click_event));
|
||||
}
|
||||
}
|
||||
Some(_) => (),
|
||||
}
|
||||
MouseWindowMouseUpEvent(button as uint, TypedPoint2D(x as f32, y as f32))
|
||||
}
|
||||
_ => fail!("I cannot recognize the type of mouse action that occured. :-(")
|
||||
};
|
||||
self.event_queue.borrow_mut().push(MouseWindowEventClass(event));
|
||||
}
|
||||
|
||||
/// Helper function to pop up an alert box prompting the user to load a URL.
|
||||
fn load_url(&self) {
|
||||
let mut alert: Alert = AlertMethods::new("Navigate to:");
|
||||
alert.add_prompt();
|
||||
alert.run();
|
||||
let value = alert.prompt_value();
|
||||
if "" == value.as_slice() { // To avoid crashing on Linux.
|
||||
self.event_queue.borrow_mut().push(LoadUrlWindowEvent("http://purple.com/".to_string()))
|
||||
} else {
|
||||
self.event_queue.borrow_mut().push(LoadUrlWindowEvent(value.clone()))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue