Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: third_party/go/src/golang.org/x/mobile/app/x11.go

Issue 1275153002: Remove third_party/golang.org/x/mobile as it is no longer used with Go 1.5. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove golang.org/x/mobile Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // +build linux,!android
6
7 package app
8
9 /*
10 Simple on-screen app debugging for X11. Not an officially supported
11 development target for apps, as screens with mice are very different
12 than screens with touch panels.
13
14 On Ubuntu 14.04 'Trusty', you may have to install these libraries:
15 sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev libx11-dev
16 */
17
18 /*
19 #cgo LDFLAGS: -lEGL -lGLESv2 -lX11
20
21 void runApp(void);
22 */
23 import "C"
24 import (
25 "runtime"
26 "sync"
27
28 "golang.org/x/mobile/event"
29 "golang.org/x/mobile/geom"
30 )
31
32 var cb Callbacks
33
34 func run(callbacks Callbacks) {
35 runtime.LockOSThread()
36 cb = callbacks
37 C.runApp()
38 }
39
40 //export onResize
41 func onResize(w, h int) {
42 // TODO(nigeltao): don't assume 72 DPI. DisplayWidth / DisplayWidthMM
43 // is probably the best place to start looking.
44 geom.PixelsPerPt = 1
45 geom.Width = geom.Pt(w)
46 geom.Height = geom.Pt(h)
47 }
48
49 var events struct {
50 sync.Mutex
51 pending []event.Touch
52 }
53
54 func sendTouch(ty event.TouchType, x, y float32) {
55 events.Lock()
56 events.pending = append(events.pending, event.Touch{
57 Type: ty,
58 Loc: geom.Point{
59 X: geom.Pt(x),
60 Y: geom.Pt(y),
61 },
62 })
63 events.Unlock()
64 }
65
66 //export onTouchStart
67 func onTouchStart(x, y float32) { sendTouch(event.TouchStart, x, y) }
68
69 //export onTouchMove
70 func onTouchMove(x, y float32) { sendTouch(event.TouchMove, x, y) }
71
72 //export onTouchEnd
73 func onTouchEnd(x, y float32) { sendTouch(event.TouchEnd, x, y) }
74
75 //export onDraw
76 func onDraw() {
77 events.Lock()
78 pending := events.pending
79 events.pending = nil
80 events.Unlock()
81
82 for _, e := range pending {
83 if cb.Touch != nil {
84 cb.Touch(e)
85 }
86 }
87 if cb.Draw != nil {
88 cb.Draw()
89 }
90 }
OLDNEW
« no previous file with comments | « third_party/go/src/golang.org/x/mobile/app/x11.c ('k') | third_party/go/src/golang.org/x/mobile/audio/al/al.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698