Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 11:04 AM, zeljko wrote: > I would try with it before reinventing wheel, because it works on all X11 > platforms (even on OS/2 and BeOS) and I'm pretty sure that it's installed by > default. Interresting, but I don't think it will be necessary ... in rev 34359 I commited su

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 11:50, Henry Vermaak wrote: > > Perhaps you should try powertop. Thanks for this. I never knew about powertop. I just ran it for a few minutes. A fpGUI base app in idle rates 6th in the "top causes for wakeups" on my system - rated at 4% of total processes running. I have no

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Jonas Maebe
On 22 Dec 2011, at 10:39, Graeme Geldenhuys wrote: On 21 December 2011 18:26, Felipe Monteiro de Carvalho <...> wrote: I tested with top and it doesn't even show my application in the top 20 users of CPU. I was just about to mention that, and would have been very surprised if it did show CPU

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread zeljko
On Thursday 22 of December 2011 09:43:28 Felipe Monteiro de Carvalho wrote: > On Thu, Dec 22, 2011 at 9:15 AM, wrote: > > As I understand it, Delphi and Lazarus implement the former, and don't > > need a timeout for it. > > Ops, you are correct, it is a one shot event: > > http://docs.embarcade

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Henry Vermaak
On 22/12/11 09:15, Felipe Monteiro de Carvalho wrote: It is not about select working or not, it is about how many file descriptors X uses to communicate: http://fixunix.com/xwindows/91558-xconnectionnumber-select.html#post301681 I don't have time in the foreseeable future to find in which wier

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 21 December 2011 18:26, Felipe Monteiro de Carvalho <...> wrote: >> just spinning around a loop, so even if your app isn't active, it's still >> waking up every 50ms.  I don't consider this very good programming practice. > > I tested with top and it doesn't even show my application in the top >

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 9:51 AM, wrote: > Strange statement. > > If select() didn't do its job correctly, neither Qt or Gtk could do their > job, or any network related program, for that matter. It is not about select working or not, it is about how many file descriptors X uses to communicate:

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt
On Thu, 22 Dec 2011, Graeme Geldenhuys wrote: On 22 December 2011 10:15, wrote: I think it depends on what you mean with 'OnIdle'. - An event which occurs once when an application falls Idle. - An event which is triggered repeatedly when the application is idle. fpGUI's OnIdle event used

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 21 December 2011 16:53, Felipe Monteiro de Carvalho wrote: > not alone here using FPC, so I shamelessly stole code from fpgui, The joys of open-source software. :-) -- Regards,   - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit htt

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt
On Thu, 22 Dec 2011, Felipe Monteiro de Carvalho wrote: On Thu, Dec 22, 2011 at 9:15 AM, wrote: As I understand it, Delphi and Lazarus implement the former, and don't need a timeout for it. Ops, you are correct, it is a one shot event: http://docs.embarcadero.com/products/rad_studio/delp

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Graeme Geldenhuys
On 22 December 2011 10:15, wrote: > > I think it depends on what you mean with 'OnIdle'. > - An event which occurs once when an application falls Idle. > - An event which is triggered repeatedly when the application is idle. fpGUI's OnIdle event used to fired only once, when the application goes

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread Felipe Monteiro de Carvalho
On Thu, Dec 22, 2011 at 9:15 AM, wrote: > As I understand it, Delphi and Lazarus implement the former, and don't need > a timeout for it. Ops, you are correct, it is a one shot event: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TAppl

Re: [fpc-pascal] Timer in X11

2011-12-22 Thread michael . vancanneyt
On Thu, 22 Dec 2011, Graeme Geldenhuys wrote: On 21 December 2011 18:06, Henry Vermaak wrote: embedded devices, laptops have batteries, too.  You're wasting CPU and power just spinning around a loop, so even if your app isn't active, it's still waking up every 50ms.  I don't consider this ver

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Graeme Geldenhuys
On 21 December 2011 18:06, Henry Vermaak wrote: > embedded devices, laptops have batteries, too.  You're wasting CPU and power > just spinning around a loop, so even if your app isn't active, it's still > waking up every 50ms.  I don't consider this very good programming practice. I'm always inter

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Martin Schreiber
On Wednesday 21 December 2011 20:10:49 Marco van de Voort wrote: > > I've been thinking about this myself, and if you don't want bad timers, the > most logical route would be to write a scheduler implementation where the > scheduler > > 1) in principle waits till the next registered event (events c

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Marco van de Voort
In our previous episode, Henry Vermaak said: > > Not likely with Linux-only stuff in the same msg. That's where I stopped > > reading pretty much. > > What linux only stuff? Since when does posix mean linux only? Spare > us the linux phobia, please. Googling for timer_create bsd shows that > at

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21 December 2011 18:06, Marco van de Voort wrote: > > Not likely with Linux-only stuff in the same msg. That's where I stopped > reading pretty much. What linux only stuff? Since when does posix mean linux only? Spare us the linux phobia, please. Googling for timer_create bsd shows that at

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Felipe Monteiro de Carvalho
On Wed, Dec 21, 2011 at 6:24 PM, Henry Vermaak wrote: > select() on linux will actually modify the timeout (fpc overloads select(), > but presumably this will still happen when you use ptimeval for the > timeout).  You shouldn't rely on this, though, read the man page for more > info.  This is wha

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Marco van de Voort
In our previous episode, Henry Vermaak said: > >> select() doesn't time out. So your error can be as much as 990ms per > >> iteration of the loop. So much for precision then. > > > > select() doesn't seam to return how much time has passed, so how do > > select() on linux will actually modify th

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 17:00, Felipe Monteiro de Carvalho wrote: On Wed, Dec 21, 2011 at 5:46 PM, Henry Vermaak wrote: You're still "guessing" a timer interval of 10ms to add to the timer if the select() doesn't time out. So your error can be as much as 990ms per iteration of the loop. So much for preci

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Felipe Monteiro de Carvalho
On Wed, Dec 21, 2011 at 5:46 PM, Henry Vermaak wrote: > You're still "guessing" a timer interval of 10ms to add to the timer if the > select() doesn't time out.  So your error can be as much as 990ms per > iteration of the loop.  So much for precision then. select() doesn't seam to return how muc

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 16:26, Felipe Monteiro de Carvalho wrote: I tested with top and it doesn't even show my application in the top 20 users of CPU. Anyway, I changed in this rev: http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&root=lazarus&revision=34354 It now adjusts the interval acoording to t

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 16:11, Martin Schreiber wrote: On 12/21/2011 04:53 PM, Henry Vermaak wrote: On 21/12/11 14:53, Felipe Monteiro de Carvalho wrote: wow, I started taking a look at how to do it and as always with anything related to X11 it is terribly complicated ... but luckly I am not alone here usi

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 16:25, michael.vancann...@wisa.be wrote: On Wed, 21 Dec 2011, Henry Vermaak wrote: On 21/12/11 15:56, Felipe Monteiro de Carvalho wrote: On Wed, Dec 21, 2011 at 4:53 PM, Henry Vermaak wrote: Spinning like this is bad news for efficiency and battery life of embedded devices. We

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Felipe Monteiro de Carvalho
On Wed, Dec 21, 2011 at 5:06 PM, Henry Vermaak wrote: > Better tell Maemo they've made a very bad choice, then.  It's not just > embedded devices, laptops have batteries, too.  You're wasting CPU and power > just spinning around a loop, so even if your app isn't active, it's still > waking up ever

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread michael . vancanneyt
On Wed, 21 Dec 2011, Henry Vermaak wrote: On 21/12/11 15:56, Felipe Monteiro de Carvalho wrote: On Wed, Dec 21, 2011 at 4:53 PM, Henry Vermaak wrote: Spinning like this is bad news for efficiency and battery life of embedded devices. Well, using X11 in an embedded device by itself is a ver

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Martin Schreiber
On 12/21/2011 04:53 PM, Henry Vermaak wrote: > On 21/12/11 14:53, Felipe Monteiro de Carvalho wrote: >> wow, I started taking a look at how to do it and as always with >> anything related to X11 it is terribly complicated ... but luckly I am >> not alone here using FPC, so I shamelessly stole code

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 15:56, Felipe Monteiro de Carvalho wrote: On Wed, Dec 21, 2011 at 4:53 PM, Henry Vermaak wrote: Spinning like this is bad news for efficiency and battery life of embedded devices. Well, using X11 in an embedded device by itself is a very bad choice Better tell Maemo they've made

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Felipe Monteiro de Carvalho
On Wed, Dec 21, 2011 at 4:53 PM, Henry Vermaak wrote: > Spinning like this is bad news for efficiency and battery life of embedded > devices. Well, using X11 in an embedded device by itself is a very bad choice =D And that's why it is very rare and linux-based phones don't use it. But what do you

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 14:53, Felipe Monteiro de Carvalho wrote: wow, I started taking a look at how to do it and as always with anything related to X11 it is terribly complicated ... but luckly I am not alone here using FPC, so I shamelessly stole code from fpgui, hammered it a little bit to fit TTimer and

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Felipe Monteiro de Carvalho
wow, I started taking a look at how to do it and as always with anything related to X11 it is terribly complicated ... but luckly I am not alone here using FPC, so I shamelessly stole code from fpgui, hammered it a little bit to fit TTimer and TCDTimer and already have a initial TTimer for X11. If

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 12:36, Mark Morgan Lloyd wrote: Henry Vermaak wrote: On 21/12/11 11:06, Felipe Monteiro de Carvalho wrote: Hello, Does anyone know what would be the solution for implementing timer support in a X11 toolkit? I already have TTimer support implemented for LCL-CustomDrawn-Windows, Coco

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 11:53, Henry Vermaak wrote: On 21/12/11 11:06, Felipe Monteiro de Carvalho wrote: Hello, Does anyone know what would be the solution for implementing timer support in a X11 toolkit? I already have TTimer support implemented for LCL-CustomDrawn-Windows, Cocoa and Android (but Android

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Mark Morgan Lloyd
Henry Vermaak wrote: On 21/12/11 11:06, Felipe Monteiro de Carvalho wrote: Hello, Does anyone know what would be the solution for implementing timer support in a X11 toolkit? I already have TTimer support implemented for LCL-CustomDrawn-Windows, Cocoa and Android (but Android is the best tested

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread Henry Vermaak
On 21/12/11 11:06, Felipe Monteiro de Carvalho wrote: Hello, Does anyone know what would be the solution for implementing timer support in a X11 toolkit? I already have TTimer support implemented for LCL-CustomDrawn-Windows, Cocoa and Android (but Android is the best tested of them), but it look

Re: [fpc-pascal] Timer in X11

2011-12-21 Thread michael . vancanneyt
On Wed, 21 Dec 2011, Felipe Monteiro de Carvalho wrote: Hello, Does anyone know what would be the solution for implementing timer support in a X11 toolkit? I already have TTimer support implemented for LCL-CustomDrawn-Windows, Cocoa and Android (but Android is the best tested of them), but it