Merge lp:~brandontschaefer/mir/pointer-confinement-demo into lp:mir
- pointer-confinement-demo
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Daniel van Vugt |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3624 |
Proposed branch: | lp:~brandontschaefer/mir/pointer-confinement-demo |
Merge into: | lp:mir |
Diff against target: |
304 lines (+289/-0) 2 files modified
examples/CMakeLists.txt (+6/-0) examples/pointer_confinement.c (+283/-0) |
To merge this branch: | bzr merge lp:~brandontschaefer/mir/pointer-confinement-demo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Approve | |
Daniel van Vugt | Approve | ||
Alan Griffiths | Approve | ||
Review via email: mp+300141@code.launchpad.net |
Commit message
A demo to show off pointer confinement and a way to test it out. Need to look at fullscreen and other possible issues.
Description of the change
A demo to show off pointer confinement and a way to test it out. Need to look at fullscreen and other possible issues.
Mir CI Bot (mir-ci-bot) wrote : | # |
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3593
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3594
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3596
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3596
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3597
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3598
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3599
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Alan Griffiths (alan-griffiths) wrote : | # |
I'm not sure what the expected behaviour is, or whether the pointer confinement implementation or demo is broken but...
Scenario #1:
$ sudo bin/mir_demo_server --vt 4 --launch bin/mir_
1. Initially you see two "cursors" - the server's arrow and the client's box
2. Drag Alt+Middle down and right to resize the client to a smaller rectangle and release
Result: the server's arrow disappears and the client resizes
3. Move the mouse
Result: the server's arrow reappears next to the client
... the server's arrow is confined to the original client area
... when the server's arrow is over the client it disappears and the red box moves erratically
Scenario #1:
$ sudo bin/mir_demo_server --vt 4 --launch bin/mir_
1. Initially you see two "cursors" - the server's arrow and the client's box
2. Drag Alt+Primary down and right to move the client and release
Result: the server's arrow disappears and the client moves
3. Move the mouse
Result: the server's arrow reappears in the original client area
... the server's arrow is confined to the original client area
... when the server's arrow is over the client it disappears and the red box moves erratically
Brandon Schaefer (brandontschaefer) wrote : | # |
Pointer confinement is whats broken. This demo just hides the cursor (when confined) and moves the red square based on the dx/dy (though it can be quite jump if you move a lot). Any suggestions are welcome to making it more appealing. I dont think anything is *broken* in the demo, just need to fix pointer confinement.
Alan Griffiths (alan-griffiths) wrote : | # |
> Pointer confinement is whats broken. This demo just hides the cursor (when
> confined) and moves the red square based on the dx/dy (though it can be quite
> jump if you move a lot). Any suggestions are welcome to making it more
> appealing. I dont think anything is *broken* in the demo, just need to fix
> pointer confinement.
OK
Alan Griffiths (alan-griffiths) wrote : | # |
OTOH the movement of the red square is so erratic it doesn't "feel" like a cursor. (And if you resize the window the speed is wrong - e.g. after Alt+F11 to fullscreen I need hardly move the mouse to cross the whole display.)
Brandon Schaefer (brandontschaefer) wrote : | # |
I suppose i can divide the dx/dy by 2 to slow the raw dx/dy down. The main issue is that im keeping it at 400x400 soo it fits on krillin. Though I should just get the width/height and set it to half so theres more room to move around.
The issue with fullscreen is it seems to stretch the window over the fullscreen? Im not really sure how fullscreen is working under the hood but all im doing is setting the window state. Ill try to make to a bit smoother though!
Daniel van Vugt (vanvugt) wrote : | # |
Nice. I needed an example, thanks. Just a few issues...
(1) Mouse is a bit erratic/
(2) It's C++ that's very close to being plain C. Consider renaming .cpp to .c and just replacing std::atomics with float/sig_atomic_t. You won't need locking primitives for the mouse_x/y stuff because it's technically equally racy either way :)
(3) I can Alt+drag the window while it has the cursor grabbed, and it will stop when the invisible cursor hits the screen edge. Seems like we're missing something to tell the shell to not be able to Alt+drag the window while it has the cursor grabbed.
Daniel van Vugt (vanvugt) wrote : | # |
(4) Need more comments explaining what this is (?)
251 +
252 + /*|-----------|
253 + *| 3 4-0 |
254 + *| / |
255 + *| 5-1 2 |
256 + *|-----------|
257 + **/
On that note, you could just upload the same vertices each time without recalculating them and set a uniform 2f to the vertex shader to translate each time (like examples/target.c). But with so few vertices it's probably not worth it and less code as is.
Daniel van Vugt (vanvugt) wrote : | # |
(5) Window resizing is not being handled (square and its motion get squashed/amplified in one dimensions). See other demo clients for how to handle that.
Daniel van Vugt (vanvugt) wrote : | # |
(6) There's no need for v_color if it's constant. Just make the colour a uniform instead of an attribute and use it in the fragment shader (not the vertex shader). Or even better, get rid of all the "_color" code and just have a trivial fragment shader:
gl_FragColor = vec4(1.
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3601
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3602
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3603
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
Thanks for that. I was only blocking on (1) getting fixed. I'd still like to see the rest cleaned up some time in future.
More observations:
(7) It's strange clients can get relative motion events at all when they don't have the pointer confined, because the motion of course suddenly stops if the unconfined cursor leaves the surface.
(8) Consider this :) ... I realized only recently "confinement" is not sufficient to solve the menus problem. For that we need an unconfined pointer with fully grabbed events -> bug 1506713
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
Unapproved changes made after approval.
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
SUCCESS: https:/
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Daniel van Vugt (vanvugt) wrote : | # |
The change from fmod to abs in r3604 needs re-testing/review as mir-ci-bot points out
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3604
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3605
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3606
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3606
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3607
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Brandon Schaefer (brandontschaefer) wrote : | # |
Failure is fixed in this branch:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3607
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
Just re-tested and found that if you move the mouse left enough times, the red square goes missing off-screen and is hard to get back.
Brandon Schaefer (brandontschaefer) wrote : | # |
Fixed now
Daniel van Vugt (vanvugt) wrote : | # |
Works now, thanks.
For those playing at home, the performance issues were:
1. Use of int coordinates that should be float (thanks to libinput for that requirement).
2. Drawing your own cursor in a triple-buffered client is naturally laggy (two frames behind). But we understand that problem fully and you can avoid the lag by switching to swap interval zero with: mir_demo_
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Daniel van Vugt (vanvugt) wrote : | # |
Failure is unrelated to this branch. Weird these always appear together:
06:29:23 9: [ FAILED ] 5 tests, listed below:
06:29:23 9: [ FAILED ] ServerDisconnec
06:29:23 9: [ FAILED ] ServerDisconnec
06:29:23 9: [ FAILED ] ServerStartup.
06:29:23 9: [ FAILED ] ServerStartup.
06:29:23 9: [ FAILED ] UnresponsiveCli
Mir CI Bot (mir-ci-bot) : | # |
Preview Diff
1 | === modified file 'examples/CMakeLists.txt' |
2 | --- examples/CMakeLists.txt 2016-06-02 05:33:50 +0000 |
3 | +++ examples/CMakeLists.txt 2016-08-02 18:38:20 +0000 |
4 | @@ -70,6 +70,12 @@ |
5 | target_link_libraries(mir_demo_client_target |
6 | eglapp |
7 | ) |
8 | +mir_add_wrapped_executable(mir_demo_client_pointer_confinement |
9 | + pointer_confinement.c |
10 | +) |
11 | +target_link_libraries(mir_demo_client_pointer_confinement |
12 | + eglapp |
13 | +) |
14 | mir_add_wrapped_executable(mir_demo_client_camera |
15 | camera.c |
16 | ) |
17 | |
18 | === added file 'examples/pointer_confinement.c' |
19 | --- examples/pointer_confinement.c 1970-01-01 00:00:00 +0000 |
20 | +++ examples/pointer_confinement.c 2016-08-02 18:38:20 +0000 |
21 | @@ -0,0 +1,283 @@ |
22 | +/* |
23 | + * Copyright © 2016 Canonical Ltd. |
24 | + * |
25 | + * This program is free software: you can redistribute it and/or modify |
26 | + * it under the terms of the GNU General Public License version 3 as |
27 | + * published by the Free Software Foundation. |
28 | + * |
29 | + * This program is distributed in the hope that it will be useful, |
30 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
32 | + * GNU General Public License for more details. |
33 | + * |
34 | + * You should have received a copy of the GNU General Public License |
35 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
36 | + * |
37 | + * Author: Brandon Schaefer <brandon.schaefer@canonical.com> |
38 | + */ |
39 | + |
40 | +#include "eglapp.h" |
41 | +#include "mir_toolkit/mir_client_library.h" |
42 | + |
43 | +#include <GLES2/gl2.h> |
44 | +#include <assert.h> |
45 | +#include <stdio.h> |
46 | +#include <signal.h> |
47 | +#include <math.h> |
48 | + |
49 | +float mouse_x = 0.0f; |
50 | +float mouse_y = 0.0f; |
51 | +sig_atomic_t done = false; |
52 | + |
53 | +static void shutdown(int signum) |
54 | +{ |
55 | + if (!done) |
56 | + { |
57 | + done = true; |
58 | + printf("Signal %d received. Good night.\n", signum); |
59 | + } |
60 | +} |
61 | + |
62 | +static float normalize(float xy, float wh, float size) { return (xy - wh/2.0f + size) / (wh/2.0f); } |
63 | + |
64 | +static GLuint load_shader(const char* src, GLenum type) |
65 | +{ |
66 | + GLuint shader = glCreateShader(type); |
67 | + if (shader) |
68 | + { |
69 | + GLint compiled; |
70 | + glShaderSource(shader, 1, &src, NULL); |
71 | + glCompileShader(shader); |
72 | + glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); |
73 | + if (!compiled) |
74 | + { |
75 | + GLchar log[1024]; |
76 | + glGetShaderInfoLog(shader, sizeof log - 1, NULL, log); |
77 | + log[sizeof log - 1] = '\0'; |
78 | + printf("load_shader compile failed: %s\n", log); |
79 | + glDeleteShader(shader); |
80 | + shader = 0; |
81 | + } |
82 | + } |
83 | + return shader; |
84 | +} |
85 | + |
86 | +static void handle_input_event(MirInputEvent const* event, MirSurface* surface) |
87 | +{ |
88 | + if (mir_input_event_get_type(event) == mir_input_event_type_pointer) |
89 | + { |
90 | + MirPointerEvent const* pev = mir_input_event_get_pointer_event(event); |
91 | + float dx = mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_x); |
92 | + float dy = mir_pointer_event_axis_value(pev, mir_pointer_axis_relative_y); |
93 | + |
94 | + mouse_x += dx; |
95 | + // - because opengl coords |
96 | + mouse_y += -dy; |
97 | + } |
98 | + else if (mir_input_event_get_type(event) == mir_input_event_type_key) |
99 | + { |
100 | + MirKeyboardEvent const* kev = mir_input_event_get_keyboard_event(event); |
101 | + int key_code = mir_keyboard_event_key_code(kev); |
102 | + |
103 | + if (mir_keyboard_event_action(kev) != mir_keyboard_action_up) |
104 | + return; |
105 | + |
106 | + if (key_code == XKB_KEY_q) |
107 | + { |
108 | + done = true; |
109 | + } |
110 | + else if (key_code == XKB_KEY_p) |
111 | + { |
112 | + // We start out grabbed |
113 | + static bool grabbed = true; |
114 | + |
115 | + MirSurfaceSpec* spec = mir_connection_create_spec_for_changes(mir_eglapp_native_connection()); |
116 | + MirPointerConfinementState state = mir_pointer_unconfined; |
117 | + MirCursorConfiguration* conf = NULL; |
118 | + |
119 | + if (!grabbed) |
120 | + { |
121 | + state = mir_pointer_confined_to_surface; |
122 | + } |
123 | + else |
124 | + { |
125 | + conf = mir_cursor_configuration_from_name(mir_default_cursor_name); |
126 | + } |
127 | + |
128 | + grabbed = !grabbed; |
129 | + |
130 | + mir_surface_spec_set_pointer_confinement(spec, state); |
131 | + |
132 | + mir_surface_apply_spec(surface, spec); |
133 | + mir_surface_spec_release(spec); |
134 | + |
135 | + // If we are grabbing we'll make it NULL which will hide the cursor |
136 | + mir_surface_configure_cursor(surface, conf); |
137 | + mir_cursor_configuration_destroy(conf); |
138 | + } |
139 | + else if (key_code == XKB_KEY_f) |
140 | + { |
141 | + static bool fullscreen = false; |
142 | + MirSurfaceSpec* spec = mir_connection_create_spec_for_changes(mir_eglapp_native_connection()); |
143 | + MirSurfaceState state = mir_surface_state_restored; |
144 | + |
145 | + if (!fullscreen) |
146 | + { |
147 | + state = mir_surface_state_fullscreen; |
148 | + } |
149 | + |
150 | + fullscreen = !fullscreen; |
151 | + |
152 | + mir_surface_spec_set_state(spec, state); |
153 | + mir_surface_apply_spec(surface, spec); |
154 | + mir_surface_spec_release(spec); |
155 | + } |
156 | + } |
157 | +} |
158 | + |
159 | +static void handle_event(MirSurface* surface, MirEvent const* event, void* context) |
160 | +{ |
161 | + (void) context; |
162 | + switch (mir_event_get_type(event)) |
163 | + { |
164 | + case mir_event_type_input: |
165 | + handle_input_event(mir_event_get_input_event(event), surface); |
166 | + break; |
167 | + default: |
168 | + break; |
169 | + } |
170 | +} |
171 | + |
172 | +static float fmodulus(float x, float y) |
173 | +{ |
174 | + float mod = fmod(x, y); |
175 | + if (mod < 0.0f) |
176 | + { |
177 | + mod += y; |
178 | + } |
179 | + |
180 | + return mod; |
181 | +} |
182 | + |
183 | +int main(int argc, char* argv[]) |
184 | +{ |
185 | + char const v_shader_src[] = |
186 | + "attribute vec4 v_position; \n" |
187 | + " \n" |
188 | + "void main() \n" |
189 | + "{ \n" |
190 | + " gl_Position = v_position; \n" |
191 | + "} \n"; |
192 | + |
193 | + char const f_shader_src[] = |
194 | + "#ifdef GL_ES \n" |
195 | + "precision mediump float; \n" |
196 | + "#endif \n" |
197 | + " \n" |
198 | + "void main() \n" |
199 | + "{ \n" |
200 | + " gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); \n" |
201 | + "} \n"; |
202 | + |
203 | + int sqaure_size = 10; |
204 | + unsigned int width = 0, height = 0; |
205 | + if (!mir_eglapp_init(argc, argv, &width, &height)) |
206 | + return 1; |
207 | + |
208 | + width /= 2; |
209 | + height /= 2; |
210 | + |
211 | + MirSurfaceSpec* spec = mir_connection_create_spec_for_changes(mir_eglapp_native_connection()); |
212 | + mir_surface_spec_set_width (spec, width); |
213 | + mir_surface_spec_set_height(spec, height); |
214 | + |
215 | + mir_surface_apply_spec(mir_eglapp_native_surface(), spec); |
216 | + mir_surface_spec_release(spec); |
217 | + |
218 | + mouse_x = width / 2.0; |
219 | + mouse_y = height / 2.0; |
220 | + |
221 | + GLuint vshader = load_shader(v_shader_src, GL_VERTEX_SHADER); |
222 | + assert(vshader); |
223 | + GLuint fshader = load_shader(f_shader_src, GL_FRAGMENT_SHADER); |
224 | + assert(fshader); |
225 | + GLuint prog = glCreateProgram(); |
226 | + assert(prog); |
227 | + glAttachShader(prog, vshader); |
228 | + glAttachShader(prog, fshader); |
229 | + glLinkProgram(prog); |
230 | + |
231 | + GLint linked; |
232 | + glGetProgramiv(prog, GL_LINK_STATUS, &linked); |
233 | + if (!linked) |
234 | + { |
235 | + GLchar log[1024]; |
236 | + glGetProgramInfoLog(prog, sizeof log - 1, NULL, log); |
237 | + log[sizeof log - 1] = '\0'; |
238 | + printf("Link failed: %s\n", log); |
239 | + return 2; |
240 | + } |
241 | + |
242 | + glUseProgram(prog); |
243 | + |
244 | + MirSurface* surface = mir_eglapp_native_surface(); |
245 | + mir_surface_set_event_handler(surface, handle_event, NULL); |
246 | + |
247 | + spec = mir_connection_create_spec_for_changes(mir_eglapp_native_connection()); |
248 | + mir_surface_spec_set_pointer_confinement(spec, mir_pointer_confined_to_surface); |
249 | + |
250 | + mir_surface_apply_spec(surface, spec); |
251 | + mir_surface_spec_release(spec); |
252 | + |
253 | + // Hide cursor |
254 | + mir_surface_configure_cursor(surface, NULL); |
255 | + |
256 | + glClearColor(0.3f, 0.3f, 0.3f, 1.0f); |
257 | + |
258 | + signal(SIGINT, shutdown); |
259 | + signal(SIGTERM, shutdown); |
260 | + signal(SIGHUP, shutdown); |
261 | + |
262 | + while (!done) |
263 | + { |
264 | + glClear(GL_COLOR_BUFFER_BIT); |
265 | + glEnable(GL_BLEND); |
266 | + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
267 | + |
268 | + /*|-----------| |
269 | + *| 3 4-0 | |
270 | + *| / | |
271 | + *| 5-1 2 | |
272 | + *|-----------| |
273 | + **/ |
274 | + float mod_x = fmodulus(mouse_x, width); |
275 | + float mod_y = fmodulus(mouse_y, height); |
276 | + |
277 | + float four_zero_x = normalize(mod_x, width, sqaure_size); |
278 | + float four_zero_y = normalize(mod_y, height, sqaure_size); |
279 | + |
280 | + float five_one_x = normalize(mod_x, width, 0.0f); |
281 | + float five_one_y = normalize(mod_y, height, 0.0f); |
282 | + |
283 | + float two_x = normalize(mod_x, width, sqaure_size); |
284 | + float two_y = normalize(mod_y, height, 0.0f); |
285 | + |
286 | + float three_x = normalize(mod_x, width, 0.0f); |
287 | + float three_y = normalize(mod_y, height, sqaure_size); |
288 | + |
289 | + GLfloat square_vert[] = { five_one_x , five_one_y , 0.0f, |
290 | + two_x , two_y , 0.0f, |
291 | + three_x , three_y , 0.0f, |
292 | + four_zero_x, four_zero_y, 0.0f }; |
293 | + |
294 | + glEnableVertexAttribArray(0); |
295 | + |
296 | + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, square_vert); |
297 | + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
298 | + |
299 | + mir_eglapp_swap_buffers(); |
300 | + } |
301 | + |
302 | + mir_eglapp_shutdown(); |
303 | + return 0; |
304 | +} |
FAILED: Continuous integration, rev:3591 /mir-jenkins. ubuntu. com/job/ mir-ci/ 1289/ /mir-jenkins. ubuntu. com/job/ build-mir/ 1508/console /mir-jenkins. ubuntu. com/job/ build-0- fetch/1561 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 1552 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 1552 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= yakkety/ 1552 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= vivid+overlay/ 1523/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 1523/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 1523/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 1523/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 1523 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 1523/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 1523/console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 1289/rebuild
https:/