Nux

Merge lp:~azzar1/nux/rm-bw-loop into lp:nux

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 862
Merged at revision: 866
Proposed branch: lp:~azzar1/nux/rm-bw-loop
Merge into: lp:nux
Diff against target: 468 lines (+1/-186)
9 files modified
Nux/GeisAdapter.cpp (+0/-10)
Nux/GeisAdapter.h (+0/-2)
Nux/MainLoopGLib.cpp (+0/-5)
Nux/MainLoopGLib.h (+0/-4)
Nux/Nux.h (+0/-3)
Nux/TimerProc.cpp (+1/-10)
Nux/TimerProc.h (+0/-4)
Nux/WindowThread.cpp (+0/-134)
Nux/WindowThread.h (+0/-14)
To merge this branch: bzr merge lp:~azzar1/nux/rm-bw-loop
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Eleni Maria Stea (community) Abstain
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+266094@code.launchpad.net

Commit message

Remove alternative select mainloop.

Description of the change

Remove alternative select mainloop.

To post a comment you must log in.
Revision history for this message
Eleni Maria Stea (hikiko) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

Mmm, sorry :) after a second look I am not sure that the deleted code is never used and should be removed. When is NUX_DISABLE_GLIB_LOOP defined? Maybe the gesture code is used in some cases... I changed my review from Approved to Abstain because I am not 100% sure that these lines are never called.

review: Abstain
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I think we're safe to go with this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/GeisAdapter.cpp'
2--- Nux/GeisAdapter.cpp 2012-10-28 15:59:17 +0000
3+++ Nux/GeisAdapter.cpp 2015-07-28 13:33:21 +0000
4@@ -23,10 +23,6 @@
5 #include <string.h>
6 #include "GeisAdapter.h"
7
8-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
9-#define NUX_USE_GLIB_LOOP
10-#endif
11-
12 #define GEIS_CLASS_UNREF(c) if (c) {geis_gesture_class_unref(c); c = nullptr;}
13
14 using namespace nux;
15@@ -35,7 +31,6 @@
16
17 namespace
18 {
19-#ifdef NUX_USE_GLIB_LOOP
20 struct GeisAdapterEventSource
21 {
22 GSource source;
23@@ -81,7 +76,6 @@
24 NULL,
25 NULL
26 };
27-#endif
28 }
29
30 GeisAdapter::GeisAdapter() :
31@@ -112,12 +106,9 @@
32 GEIS_CLASS_UNREF(class_touch_)
33 geis_delete(geis_);
34
35-#ifdef NUX_USE_GLIB_LOOP
36 g_source_remove_by_funcs_user_data(&geis_source_funcs, this);
37-#endif
38 }
39
40-#ifdef NUX_USE_GLIB_LOOP
41 void GeisAdapter::CreateGSource(GMainContext *context)
42 {
43 GSource *source = g_source_new(&geis_source_funcs,
44@@ -143,7 +134,6 @@
45
46 g_source_attach(source, context);
47 }
48-#endif // NUX_USE_GLIB_LOOP
49
50 void GeisAdapter::ProcessGeisEvents()
51 {
52
53=== modified file 'Nux/GeisAdapter.h'
54--- Nux/GeisAdapter.h 2015-02-16 17:11:44 +0000
55+++ Nux/GeisAdapter.h 2015-07-28 13:33:21 +0000
56@@ -45,9 +45,7 @@
57 GeisAdapter();
58 ~GeisAdapter();
59
60-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
61 void CreateGSource(GMainContext *context);
62-#endif
63
64 /*
65 Returns whether initialization is complete.
66
67=== modified file 'Nux/MainLoopGLib.cpp'
68--- Nux/MainLoopGLib.cpp 2014-07-30 00:23:32 +0000
69+++ Nux/MainLoopGLib.cpp 2015-07-28 13:33:21 +0000
70@@ -12,8 +12,6 @@
71
72 namespace nux
73 {
74- #if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
75-
76 static GMutex *gLibEventMutex = 0;
77
78 static void nux_glib_threads_lock(void)
79@@ -91,9 +89,6 @@
80 # else
81 retval = false;
82 # endif
83-#else
84-# error Not implemented.
85-#endif
86
87 nux_glib_threads_unlock();
88 return retval;
89
90=== modified file 'Nux/MainLoopGLib.h'
91--- Nux/MainLoopGLib.h 2013-02-01 09:14:07 +0000
92+++ Nux/MainLoopGLib.h 2015-07-28 13:33:21 +0000
93@@ -3,8 +3,6 @@
94
95 #include <glib.h>
96
97-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
98-
99 namespace nux
100 {
101 class ExternalGLibSources
102@@ -17,5 +15,3 @@
103 }
104
105 #endif
106-
107-#endif
108
109=== modified file 'Nux/Nux.h'
110--- Nux/Nux.h 2015-02-16 17:11:44 +0000
111+++ Nux/Nux.h 2015-07-28 13:33:21 +0000
112@@ -49,9 +49,6 @@
113
114 #include <glib.h>
115
116-#define NUX_USE_GLIB_LOOP_ON_WINDOWS
117-//#define NUX_DISABLE_GLIB_LOOP
118-
119 #if defined(NUX_OS_LINUX)
120 #include "Nux/Features.h"
121 #endif
122
123=== modified file 'Nux/TimerProc.cpp'
124--- Nux/TimerProc.cpp 2013-07-18 18:53:49 +0000
125+++ Nux/TimerProc.cpp 2015-07-28 13:33:21 +0000
126@@ -183,10 +183,7 @@
127 for (auto const& timer_object : early_timer_handlers_)
128 {
129 timer_object->ms_time = g_get_monotonic_time() / 1000;
130-
131-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
132- timer_object->glibid = GetWindowThread()->AddTimeout(timer_object->Period);
133-#endif
134+ timer_object->glibid = GetWindowThread()->AddTimeout(timer_object->Period);
135 }
136
137 early_timer_handlers_.clear();
138@@ -210,7 +207,6 @@
139
140 AddHandle(timer_object);
141
142-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
143 {
144 if (window_thread)
145 timer_object->glibid = window_thread->AddTimeout(Period);
146@@ -227,7 +223,6 @@
147
148 //nuxDebugMsg("[TimerHandler::AddOneShotTimer] Adding Timeout ID: %d", timer_object->glibid);
149 }
150-#endif
151
152 return timer_object;
153 }
154@@ -246,7 +241,6 @@
155 timer_object->state_ = TimerHandler::TIMER_STATE_RUNNING;
156 AddHandle(timer_object);
157
158-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
159 {
160 timer_object->glibid = GetWindowThread()->AddTimeout(Period);
161
162@@ -260,7 +254,6 @@
163
164 //nuxDebugMsg("[TimerHandler::AddOneShotTimer] Adding Timeout ID: %d", timer_object->glibid);
165 }
166-#endif
167
168 return timer_object;
169 }
170@@ -279,7 +272,6 @@
171 timer_object->state_ = TimerHandler::TIMER_STATE_RUNNING;
172 AddHandle(timer_object);
173
174-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
175 {
176 timer_object->glibid = GetWindowThread()->AddTimeout(Period);
177
178@@ -293,7 +285,6 @@
179
180 //nuxDebugMsg("[TimerHandler::AddOneShotTimer] Adding Timeout ID: %d", timer_object->glibid);
181 }
182-#endif
183
184 return timer_object;
185 }
186
187=== modified file 'Nux/TimerProc.h'
188--- Nux/TimerProc.h 2013-07-18 12:58:36 +0000
189+++ Nux/TimerProc.h 2015-07-28 13:33:21 +0000
190@@ -164,11 +164,7 @@
191 */
192 int DelayUntilNextTimerExpires();
193
194-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
195 int ExecTimerHandler (unsigned int timer_id);
196-#else
197- int ExecTimerHandler();
198-#endif
199
200 //! Start the timers that were sett before the system was fully initialized.
201 void StartEarlyTimerObjects();
202
203=== modified file 'Nux/WindowThread.cpp'
204--- Nux/WindowThread.cpp 2013-12-18 21:43:30 +0000
205+++ Nux/WindowThread.cpp 2015-07-28 13:33:21 +0000
206@@ -61,9 +61,7 @@
207 , embedded_window_(false)
208 , window_size_configuration_event_(false)
209 , force_rendering_(false)
210-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
211 , external_glib_sources_(new ExternalGLibSources)
212-#endif
213 #ifdef NUX_GESTURES_SUPPORT
214 , geis_adapter_(new GeisAdapter)
215 #endif
216@@ -98,10 +96,8 @@
217 #endif
218 _MasterClock = NULL;
219
220-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
221 main_loop_glib_ = 0;
222 main_loop_glib_context_ = 0;
223-#endif
224
225 #if defined(USE_X11)
226 x11display_ = NULL;
227@@ -117,10 +113,8 @@
228
229 WindowThread::~WindowThread()
230 {
231-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
232 xim_controller_.reset();
233 CleanupGlibLoop();
234-#endif
235
236 ThreadDtor();
237 #if !defined(NUX_MINIMAL)
238@@ -144,16 +138,12 @@
239
240 void WindowThread::ExitMainLoop()
241 {
242-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
243 StopGLibLoop();
244-#endif
245 }
246
247 unsigned int WindowThread::AddTimeout(unsigned int timeout_delay)
248 {
249-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
250 return AddGLibTimeout(timeout_delay);
251-#endif
252 }
253
254 TimerHandle WindowThread::SetAsyncTimerCallback(int time_ms, TimeOutSignal* timeout_signal, void *user_data)
255@@ -442,9 +432,7 @@
256 }
257 else
258 {
259-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
260 InitGlibLoop();
261-#endif
262 }
263
264 // Called the first time so we can initialize the size of the render targets
265@@ -468,11 +456,7 @@
266 {
267 if (GetThreadState() == THREADRUNNING)
268 {
269-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
270 RunGlibLoop();
271-#else
272- ExecutionLoop();
273-#endif
274
275 if (parent_)
276 {
277@@ -540,120 +524,6 @@
278 return event;
279 }
280
281-#if (!defined(NUX_OS_LINUX) && !defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) || defined(NUX_DISABLE_GLIB_LOOP)
282-#ifdef NUX_GESTURES_SUPPORT
283- Event *WindowThread::FetchNextEvent()
284- {
285- Event *event;
286-
287- if (check_geis_first_)
288- {
289- if (geis_adapter_->ProcessNextEvent(&gesture_event_))
290- {
291- event = &gesture_event_;
292- }
293- else
294- {
295- graphics_display_->GetSystemEvent(&input_event_);
296- event = &input_event;
297- }
298- }
299- else
300- {
301- if (graphics_display_->GetSystemEvent(&input_event_))
302- {
303- event = &input_event_;
304- }
305- else
306- {
307- geis_adapter_->ProcessNextEvent(&gesture_event_);
308- event = &gesture_event_;
309- }
310- }
311-
312- // If we are running in a loop and both event buffers (X and GEIS) happens
313- // to have pending events, let's take one from each alternately so that no
314- // buffer overflows.
315- check_geis_first_ = !check_geis_first_;
316-
317- return event;
318- }
319-#endif // NUX_GESTURES_SUPPORT
320-
321- unsigned int WindowThread::ExecutionLoop()
322- {
323-#ifndef NUX_GESTURES_SUPPORT
324- Event event;
325-#endif
326-
327- if (!IsEmbeddedWindow() && graphics_display_->IsPauseThreadGraphicsRendering())
328- {
329- // Do not sleep. Just return and let the GraphicsDisplay::SwapBuffer do the sleep if necessary.
330- return 0;
331- }
332-
333- while (true)
334- {
335-#ifdef NUX_GESTURES_SUPPORT
336- int result = DoProcessEvent(*FetchNextEvent());
337-#else
338- graphics_display_->GetSystemEvent(&event);
339- int result = DoProcessEvent(event);
340-#endif
341-
342-#if defined(NUX_OS_LINUX)
343- // select on all of our external fds. We can't use poll () here because
344- // ExectionLoop is designed to be a busy-wait system. In reality we should
345- // probably just drop support for this codepath.
346- //
347- // See https://bugs.launchpad.net/nux/+bug/1111216
348-
349- fd_set read_fds;
350-
351- FD_ZERO(&read_fds);
352-
353- for (std::list<ExternalFdData>::iterator it =
354- _external_fds.begin();
355- it != _external_fds.end();
356- ++it)
357- {
358- nuxAssertMsg(it->fd < FD_SETSIZE, "[nux::WindowThread::ExecutionLoop]"\
359- " file descriptor overflow, aborting");
360- FD_SET(it->fd, &read_fds);
361- }
362-
363- // Wait 10 us
364- struct timeval timeout;
365- timeout.tv_sec = 0;
366- timeout.tv_usec = 10;
367-
368- int select_result = select(_external_fds.size(), &read_fds, NULL, NULL,
369- &timeout);
370-
371- nuxAssertMsg(select_result != -1, strerror ("select()"));
372-
373- // Dispatch any active external fds
374- for (std::list<ExternalFdData>::iterator it =
375- _external_fds.begin();
376- it != _external_fds.end();
377- ++it)
378- {
379- if (FD_ISSET(it->fd, &read_fds))
380- it->cb();
381- }
382-
383- if (result != 1)
384- return result;
385- }
386-
387- return 1;
388- }
389-#else
390- nuxAssertMsg(_external_fds.empty(), "[nux::WindowThread::ExecutionLoop]"\
391- " external fd support is not implemented on Windows");
392-#endif // NUX_OS_LINUX
393-#endif // GLIB loop or not
394-
395 unsigned int WindowThread::ProcessEvent(Event &event)
396 {
397 if (!IsEmbeddedWindow() && graphics_display_->IsPauseThreadGraphicsRendering())
398@@ -1776,11 +1646,9 @@
399 data.cb = cb;
400
401 _external_fds.push_back(data);
402-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
403 AddFdToGLibLoop(fd,
404 reinterpret_cast <gpointer> (&_external_fds.back()),
405 WindowThread::ExternalSourceCallback);
406-#endif
407 }
408
409 void WindowThread::UnwatchFd(int fd)
410@@ -1793,9 +1661,7 @@
411
412 if (it != _external_fds.end())
413 {
414-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
415 RemoveFdFromGLibLoop(&(*it));
416-#endif
417 _external_fds.erase (it);
418 }
419 }
420
421=== modified file 'Nux/WindowThread.h'
422--- Nux/WindowThread.h 2013-12-18 21:43:30 +0000
423+++ Nux/WindowThread.h 2015-07-28 13:33:21 +0000
424@@ -54,12 +54,9 @@
425 class Area;
426 struct ClientAreaDraw;
427
428-
429-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
430 class ExternalGLibSources;
431 gboolean nux_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
432 gboolean nux_timeout_dispatch(gpointer user_data);
433-#endif
434
435 //! Event Inspector function prototype.
436 /*!
437@@ -490,11 +487,6 @@
438 */
439 void DisableMouseKeyboardInput();
440
441-#if (!defined(NUX_OS_LINUX) && !defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) || defined(NUX_DISABLE_GLIB_LOOP)
442- //! Calls ProcessEvent in a loop
443- unsigned int ExecutionLoop();
444-#endif
445-
446 /*!
447 It does the following:
448 * processes the input events
449@@ -690,7 +682,6 @@
450
451 static bool FindDataByFd(const WindowThread::ExternalFdData &data, int fd);
452
453-#if (defined(NUX_OS_LINUX) || defined(NUX_USE_GLIB_LOOP_ON_WINDOWS)) && (!defined(NUX_DISABLE_GLIB_LOOP))
454 GMainLoop *main_loop_glib_;
455 GMainContext *main_loop_glib_context_;
456 friend gboolean nux_event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data);
457@@ -710,11 +701,6 @@
458 static gboolean ExternalSourceCallback(gpointer user_data);
459
460 unsigned int AddGLibTimeout(unsigned int duration);
461-#else // no GLIB loop
462- Event input_event_;
463- GestureEvent gesture_event_;
464- Event *FetchNextEvent();
465-#endif
466
467 #ifdef NUX_GESTURES_SUPPORT
468 std::unique_ptr<GeisAdapter> geis_adapter_;

Subscribers

People subscribed via source and target branches