Re: Input event reduction

2017-03-30 Thread Emmanuele Bassi
On 30 March 2017 at 11:21, Gabriele Greco wrote: >> >> Thanks. While I can remember have read your explanations somewhere >> already, I really missed that g_main_context_invoke() function. > > > There is some difference/advantage on calling: > >

Re: Input event reduction

2017-03-30 Thread Gabriele Greco
> > > Thanks. While I can remember have read your explanations somewhere > already, I really missed that g_main_context_invoke() function. There is some difference/advantage on calling: g_main_context_invoke(NULL, func, data)? instead of g_idle_add(func, data); As far as I can see from the

Re: Input event reduction

2017-03-30 Thread Stefan Salewski
On Thu, 2017-03-30 at 10:21 +0100, Emmanuele Bassi wrote: > g_idle_add() or, better yet, g_main_context_invoke(). Thanks. While I can remember have read your explanations somewhere already, I really missed that g_main_context_invoke() function. ___

Re: Input event reduction

2017-03-30 Thread Stefan Salewski
On Thu, 2017-03-30 at 11:10 +0200, Nicola Fontana wrote: >  > > As said you can leverage the main loop and unroll yours, e.g.: > > gboolean my_idle_callback() > { > gint n; > for (n = 0; n < 100; ++n) { > ... > } > return FALSE; > } > > should become: > > gboolean

Re: Input event reduction

2017-03-30 Thread Emmanuele Bassi
On 30 March 2017 at 10:10, Nicola Fontana wrote: > When you are ready from (1) you can spawn the idle callback with > g_source_attach()... no needs for gdk_threads_add_idle(). In the > following StackOverflow answer I provided an example in C: A small correction: use

Re: Input event reduction

2017-03-30 Thread Nicola Fontana
Il Thu, 30 Mar 2017 09:38:41 +0200 Stefan Salewski scrisse: > On Wed, 2017-03-29 at 23:26 +0200, Nicola Fontana wrote: > >  > > > > idle functions do *not* run in the background so if you don't > > release the CPU you will experience what you described. > > > > AFAIK all the

Re: Input event reduction

2017-03-30 Thread Stefan Salewski
On Thu, 2017-03-30 at 09:38 +0200, Stefan Salewski wrote: > Currently I wonder if the call of gtk3.mainIteration() inside the > idle > function is possible and if it would help updating the display. In my > first draft of the Nim toy chess I used something like this > > while

Re: Input event reduction

2017-03-30 Thread Stefan Salewski
On Wed, 2017-03-29 at 23:26 +0200, Nicola Fontana wrote: >  > > idle functions do *not* run in the background so if you don't > release the CPU you will experience what you described. > > AFAIK all the GMainLoop code is single-threaded hence, as a > consequence, you will block the UI whenever

Re: Input event reduction

2017-03-29 Thread Nicola Fontana
Il Wed, 29 Mar 2017 21:27:48 +0200 Stefan Salewski scrisse: > ... > > Problem is the idle function added with > > https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-idle-add > > I have the strong feeling, that the provided function is not running >

Re: Input event reduction

2017-03-29 Thread Stefan Salewski
On Wed, 2017-03-29 at 16:47 +0200, Stefan Salewski wrote: > On Wed, 2017-03-29 at 09:42 +0200, Stefan Salewski wrote: > > > > It is still the old problem: > > Well, after some thinking I have the feeling that it may work with > only > an idle function, so no separate thread and message passing

Re: Input event reduction

2017-03-29 Thread Stefan Salewski
On Wed, 2017-03-29 at 09:42 +0200, Stefan Salewski wrote: > It is still the old problem: Well, after some thinking I have the feeling that it may work with only an idle function, so no separate thread and message passing is necessary: The callback set a flag indicating that there is work to do,