├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── cbalz.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── libraries │ ├── Leiningen__org_clojure_clojure_1_5_1.xml │ ├── Leiningen__clojure_complete_0_2_3.xml │ └── Leiningen__org_clojure_tools_nrepl_0_2_3.xml ├── compiler.xml ├── misc.xml └── workspace.xml ├── bin ├── serve.bash └── run.bash ├── favicon.ico ├── resources ├── .DS_Store └── public │ ├── images │ ├── favicon.ico │ ├── favicon.pnm │ ├── remote-control.png │ └── remote-control_16x16.png │ └── index.html ├── .gitignore ├── test └── x_server_web │ └── core_test.clj ├── package.json ├── Makefile ├── src └── x_server_web │ └── cljs │ └── core.cljs ├── LICENSE.txt ├── project.clj ├── x_server_web.iml └── README.md /.idea/.name: -------------------------------------------------------------------------------- 1 | x-server-web -------------------------------------------------------------------------------- /bin/serve.bash: -------------------------------------------------------------------------------- 1 | node node_modules/.bin/http-server -p $1 2 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/favicon.ico -------------------------------------------------------------------------------- /resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/resources/.DS_Store -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/cbalz.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /resources/public/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/resources/public/images/favicon.ico -------------------------------------------------------------------------------- /resources/public/images/favicon.pnm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/resources/public/images/favicon.pnm -------------------------------------------------------------------------------- /resources/public/images/remote-control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/resources/public/images/remote-control.png -------------------------------------------------------------------------------- /resources/public/images/remote-control_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nottoseethesun/x-server-web/HEAD/resources/public/images/remote-control_16x16.png -------------------------------------------------------------------------------- /resources/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | X Server for Web 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *jar 4 | /lib/ 5 | /classes/ 6 | /target/ 7 | /checkouts/ 8 | .lein-deps-sum 9 | .lein-repl-history 10 | .lein-plugins/ 11 | .lein-failures 12 | build 13 | node_modules 14 | -------------------------------------------------------------------------------- /test/x_server_web/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns x-server-web.core-test 2 | (:require [clojure.test :refer :all] 3 | [x-server-web.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/libraries/Leiningen__org_clojure_clojure_1_5_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Leiningen__clojure_complete_0_2_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/libraries/Leiningen__org_clojure_tools_nrepl_0_2_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /bin/run.bash: -------------------------------------------------------------------------------- 1 | UNTIL_WEB_SERVER_STARTS_S=2 2 | 3 | indexHtml=http://localhost:$1/resources/public/index.html 4 | 5 | openIs="$(which open)" # Works on Mac. 6 | xdgOpenIs="$(which xdg-open)" # Works on Linux, and on Mac with MacPorts, etc. 7 | 8 | sleep $UNTIL_WEB_SERVER_STARTS_S 9 | 10 | if [ -n "${openIs}" ] 11 | then 12 | open $indexHtml 13 | elif [ -n "${xdgOpenIs}" ] 14 | then 15 | xdg-open $indexHtml 16 | else 17 | echo "Install open or xdg-open on your system, or manually open" $indexHtml "in your web browser." 18 | fi 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "x-server-web", 3 | "version": "0.0.1", 4 | "description": "Project to create an X Server, written in ClojureScript, that runs on a web browser.", 5 | "author": "Chris M. Balz ", 6 | "contributors": [], 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/christopherbalz/x-server-web" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/christopherbalz/x-server-web/issues" 13 | }, 14 | "keywords": [ 15 | "X Window System", 16 | "web browser" 17 | ], 18 | "dependencies": { 19 | }, 20 | "devDependencies": { 21 | "http-server": "*" 22 | }, 23 | "license": "MIT" 24 | } 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PORT=6200 # X Servers typically run on port 6000, but for web browser use across firewalls (as would be the case 2 | # if this were to move to production today), this would need to be changed to 80 or 8080. 3 | # For development work, and to keep out of the way of other servers (X Window System and other servers), 4 | # we choose a higher range than regular X servers. 5 | 6 | install: 7 | npm i 8 | lein deps 9 | 10 | build: 11 | lein cljsbuild once 12 | 13 | build-auto: 14 | lein cljsbuild auto 15 | 16 | serve: 17 | bin/serve.bash $(PORT) 18 | 19 | run: 20 | bin/run.bash $(PORT) 21 | 22 | clean: 23 | rm -rf build node_modules 24 | 25 | uninstall: 26 | lein clean 27 | 28 | PHONY: install build build-auto run clean uninstall 29 | -------------------------------------------------------------------------------- /src/x_server_web/cljs/core.cljs: -------------------------------------------------------------------------------- 1 | (ns x-server-web.core 2 | (:require [shodan.console :as console :include-macros true] 3 | [shodan.inspection :refer [inspect]] 4 | ) 5 | ) 6 | 7 | (enable-console-print!) 8 | 9 | 10 | (defn create-server [ listen-port options ] 11 | { 12 | :listen-port listen-port 13 | :options options 14 | :displays { 15 | :display1 {:screens '({:id 0})} ; Child windows and iframes could serve to create a multiple screen arrangement. 16 | } 17 | :clients {} 18 | :extensions {} 19 | } 20 | ) 21 | 22 | 23 | (defn init-server [] 24 | (inspect (create-server 8888 {})) ;; @to-do: Read these inputs from an external file. 25 | ) 26 | 27 | (init-server) 28 | (console/info "Initialized the X Server for Web.") 29 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Christopher M Balz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject x-server-web "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [ 7 | [org.clojure/clojure "RELEASE"] ;; "1.5.1" 8 | [org.clojure/tools.logging "RELEASE"] ;; "0.3.1" 9 | [org.clojure/clojurescript "0.0-2511"] ;; "RELEASE" not supported. 10 | [shodan "RELEASE"] ;; https://github.com/noprompt/shodan 11 | [cljs-websockets-async "0.1.0-SNAPSHOT"] ;; https://github.com/loganlinn/cljs-websockets-async ;; "RELEASE" not supported. 12 | ] 13 | :source-paths ["src/clj"] 14 | ;; :main x-server-web.core/init-server 15 | :plugins [[lein-cljsbuild "RELEASE"]] ;; 1.0.3 16 | :cljsbuild {:builds 17 | [{:source-paths ["src/x_server_web/cljs"], 18 | :compiler 19 | {:optimizations :whitespace, 20 | :output-to "build/resources/public/index.js", 21 | :pretty-print true}}]} 22 | ) 23 | -------------------------------------------------------------------------------- /x_server_web.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction to `x-server-web` 2 | 3 | 4 | ## What 5 | 6 | `x-server-web` aims to be an X Window System server that runs on the web browser with no plug-ins or extensions, using websockets spawned from http, regular javascript, html, and css. This project is currently in an outline state only. 7 | 8 | 9 | ## Getting Started 10 | 11 | Follow the Install, Build, and Run steps below, in that order. 12 | Optionally, check the JavaScript console on the web browser for output, after `make run`. 13 | 14 | 15 | ## Install 16 | 17 | ### Pre-requisites 18 | 19 | 1. Java 8 SE ("Standard Edition"), [available from Oracle](http://www.oracle.com/technetwork/java/javase/downloads/index.html). It is suggested to install Java 8 in the standard place for your system, such as on Mac, in `/Library/Java/JavaVirtualMachines`. 20 | 1. Check that your `$JAVA_HOME` environment variable points to your new Java 8 installation, and if not, set it so that it does. On Mac, if you put Java 8 in the location suggested, it will do so automatically on system restart (meantime, you can set JAVA_HOME manually, if desired). For example: 21 | ``` 22 | $ echo $JAVA_HOME 23 | /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home 24 | ``` 25 | 3. `lein`, from [Leiningen.org](http://leiningen.org/#install). Follow the instructions at that link if you don't have `lein`. 26 | 4. `lein` is on your system path. For example: 27 | ``` 28 | $ lein --version 29 | Leiningen 2.5.0 on Java 1.8.0_25 Java HotSpot(TM) 64-Bit Server VM 30 | ``` 31 | 5. [`make`](http://www.gnu.org/software/make/) 32 | 6. `make` is in your system path. 33 | 7. `npm` and `node`, available from [http://nodejs.org](http://nodejs.org), or your favorite package manager. 34 | 8. `npm` and `node` are on your system path. 35 | 9. Optional (for `make run`): Ensure that `open` (as it works on Mac OS X for example) or `xdg-open` is available on your system. 36 | 10. Port 6200 is available: No other programs should be using logical network port 6200. 37 | 11. `make install` 38 | 39 | 40 | ## Build 41 | 42 | `make build` 43 | 44 | 45 | ## Run 46 | ``` 47 | make serve 48 | ``` 49 | and then in a different tab: 50 | ``` 51 | make run 52 | ``` 53 | 54 | 55 | ## Why 56 | 57 | With good performance in terms of responsiveness, frames per second, and graphical fidelity in remote windowing (remote desktop, remote application windows) on the web browser, similar to that seen today in online (over the public Internet), high-spec gaming, users could conveniently access a new universe of remote resources, such as entire desktops, mobile-device user interfaces, and applications. 58 | 59 | Offering this on the web browser enables users to conveniently experience the power of using a single, full-stack operating system across multiple, independent pieces of hardware (desktop, phone, tablet, car dash computer, etc). Ultimately, with the geographical spread of network connectivity, there is less reason to use a different instance of a full-stack operating system for each specific piece of hardware, and more reason to instead use a single cloud-based one. 60 | 61 | 62 | ## How 63 | 64 | This X server aims for compliance with NeatX or similar X Windows clients that have been optimized for higher network latency such as found on the public Internet. More detail will be announced later. 65 | 66 | This X server is written in clojurescript. For execution, it is compiled to javascript and delivered to a web browser with accompanying html and css. 67 | 68 | 69 | ### Choice of Clojurescript 70 | 71 | Clojurescript has been chosen for this project because: 72 | 73 | * It supports performant functional-programming on the web client (requiring only regular javascript). 74 | * Although not natively strongly typed, it offers a generation-scale upgrade from javascript in terms of power, regularity, and consistency. 75 | * It is likely to be widely adopted: 76 | * Much Clojure code can be run simply as clojurescript, and vice-versa, and since Clojure runs on the JVM, it is likely to be widely adopted among similar languages because software compatibility, security, and hardware portability issues are known factors and considered acceptable. 77 | * It supports isomorphic web applications: Since much clojurescript code can be run as Clojure, modules can be run on either the web client or the web server. This enables server-side rendering of web apps that can also update themselves locally on the web browser client, without re-writing code. Web-server-side rendering is performant because on first visit to a web page, such as a web page with today's world news content, delivery to the reader is faster if the initial page render is done on the web server. 78 | 79 | 80 | # Caveats 81 | 82 | * X Server extensions needed: To be performant and comparable to current X server/X client set-ups, `x-server-web` would need compatible (meaning, implemented in something that compiles to javascript) implementations of the extensions "Composite", "GLX", "RENDER", "RANDR", "SECURITY", "SYNC", "XVideo". 83 | * A compatible display manager (for graphical authentication) will be needed for secure access. 84 | 85 | 86 | # Other Approaches Considered 87 | 88 | * SPICE, with its html5 client, represents the closest thing to this project but it runs on top of the X system, adding an additional layer of overhead and complexity. This enables it to work with the Windows operating system as well as with the X Windows System. For better performance however, and also for simplicity, less software layers are desirable. Hence, simply using a display server that is native to X will provide a better foundation in terms of performance and maintainability. 89 | * The Wayland window system looks very promising, but this project requires a finished window system so that it can be completed on a more predictable and more economical (in terms of engineering effort) schedule. 90 | 91 | 92 | # Roadmap 93 | 94 | 1. Turn on source-maps 95 | 1. Develop basic X Server outline (support displays, screens, input, color translation to web format, and so forth). 96 | 1. Implement the networking infrastructure (websockets) that will transport the X protocol messages. 97 | 1. Connect to a real X Client (may require developing new features). 98 | 1. Implement extensions as listed above. 99 | 1. Implement a display manager. 100 | 101 | ## Roadmap: Events 102 | 1. Support the `Expose` event by checking window (`window` in the X sense: includes windows that are buttons, and so forth) expose condition on each refresh 103 | 1. Support `KeyPress` and `KeyRelease`. 104 | 1. Support error events. 105 | 1. Support authentication. 106 | 1. Check if support for "grab" is needed. 107 | 108 | ## Roadmap: Protocol 109 | 1. Build client-side adaptor that turns the message into EDN and sends it over websocket to the server. 110 | 1. Set up utility to take the last significant 16 bits of each request number, for the protocol request number slot. 111 | 112 | ## Roadmap: Color 113 | 1. Color depth can be ignored, since that is already pre-set on the browser. 114 | 1. Support `colormap`: Build a lookup facility for this table, and a place to put them. 115 | 1. Not sure yet what to do to support visual type. 116 | 117 | ## Roadmap: State 118 | 1. Support `Window`, `Font`, `Colormap`, `Pixmap`, and `GraphicContext`. 119 | 1. Don't support server-side fonts, since they are deprecated. 120 | 1. Support atoms. 121 | 122 | ## Roadmap: Extensions 123 | 1. Find out what will be needed to support X Server extensions. 124 | 125 | # References 126 | 127 | * "[X Power Tools](http://shop.oreilly.com/product/9780596101954.do)", by O'Reilly Publishing 128 | * "[The X New Developers Guide](http://www.x.org/wiki/guide/)", by X.org 129 | 130 | 131 | # Contributing 132 | 133 | If you are not already familiar with the basic architecture of X Windows, first read "[The X New Developer’s Guide](http://www.x.org/wiki/guide/)". 134 | 135 | This project has files to facilitate editing from Cursive, the IntelliJ set-up for Clojure. 136 | 137 | Code style: Everything standard, and especially, whitespace instead of tabs. 138 | 139 | Send your clojurescript pull request, and if interested, request to be a committer. 140 | 141 | # License 142 | 143 | See the `LICENSE.txt` file in the top-level of the project directory. 144 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 75 | 76 | 83 | 84 | 85 | 96 | 97 | 98 | 99 | 117 | 124 | 125 | 126 | 139 | 140 | 141 | 142 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | localhost 163 | 5050 164 | 165 | 166 | 167 | 169 | 170 | 173 | 174 | 175 | 176 | 177 | 178 | 1.8 179 | 180 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 196 | 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 71 | 72 | 73 | 76 | 77 | 80 | 81 | 82 | 83 | 86 | 87 | 90 | 91 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 125 | 126 | 133 | 134 | 135 | 136 | 154 | 161 | 162 | 163 | 174 | 175 | 176 | 189 | 190 | 191 | 192 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | localhost 213 | 5050 214 | 215 | 216 | 217 | 218 | 219 | 220 | 1419347622131 221 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 259 | 262 | 263 | 264 | 266 | 267 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | --------------------------------------------------------------------------------