Closed Bug 366337 Opened 18 years ago Closed 18 years ago

implement nsIIdleService on Windows

Categories

(Core :: Widget: Win32, enhancement)

x86
Windows XP
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Gijs, Assigned: Gijs)

References

Details

Attachments

(1 file, 2 obsolete files)

It'd be nice to have an implementation for this on Windows as well. I'll look into it myself when I can. (Hopefully Soon)
Depends on: 343416
Attached patch Patch (obsolete) — Splinter Review
I have way too much time on my hands. Anyway, implementation using GetLastInputInfo, which is available on Win2k and up, which is what trunk is catering for I believe, but it's not there on Win CE, so the makefile and interface stuff is in ifdef's to make sure we don't break builds there.
Assignee: win32 → gijskruitbosch+bugs
Status: NEW → ASSIGNED
Attachment #251058 - Flags: superreview?(emaijala)
Attachment #251058 - Flags: review?(neil)
Comment on attachment 251058 [details] [diff] [review] Patch sr(!)=me with these nits addressed. >+#include "nsIServiceManager.h" >+#include "nsDebug.h" Not used? >+nsIdleServiceWin::nsIdleServiceWin() >+{} >+ >+nsIdleServiceWin::~nsIdleServiceWin() >+{} Not sure if there's any point declaring these if they don't do anything. >+ memset(&inputInfo, 0, sizeof(inputInfo)); Unnecessary; you only need to set cbSize. >+ DWORD ticks = GetTickCount(); There's no point calling this before GetLastInputInfo. Also it's only used once so you might as well inline it. >+ PRBool rv = GetLastInputInfo(&inputInfo); Nit: module style is to use :: on globals. Also, it's declared to return BOOL, not PRBool. Or just write if (!::GetLastInputInfo(&inputInfo))
Attachment #251058 - Flags: review?(neil) → review+
Comment on attachment 251058 [details] [diff] [review] Patch Alert! Windows line endings! >+nsIdleServiceWin::GetIdleTime(PRUint32 *aTimeDiff) >+{ >+ LASTINPUTINFO inputInfo; >+ memset(&inputInfo, 0, sizeof(inputInfo)); >+ inputInfo.cbSize = sizeof(inputInfo); >+ DWORD ticks = GetTickCount(); >+ PRBool rv = GetLastInputInfo(&inputInfo); >+ if (rv == 0) >+ return NS_ERROR_FAILURE; >+ *aTimeDiff = ticks - inputInfo.dwTime; >+ return NS_OK; Nit of the day: so if I'm away for a long period of time, the idle observers will receive a 'back' notification once in 50 days? (What about Linux implementation? Perhaps the wrapping-around behavior of |attribute idleTime| should be documented in the IDL?) Also rv == 0 is equivalent to !rv.
Attachment #251058 - Flags: review+ → review?(neil)
Comment on attachment 251058 [details] [diff] [review] Patch bah, stupid bugzilla. Restoring Neil's r+.
Attachment #251058 - Flags: review?(neil) → review+
Attached patch Patch v2 (obsolete) — Splinter Review
Carrying over sr+ from Neil. This should have the nits you pointed out fixed. I've also re-saved the diff with just unix line-ends. Looks like my msys cvs diff somehow prefers those. Suggestions on how to teach it not to are welcome. There's an xxx from me wrt the 49.7 days thing.
Attachment #251058 - Attachment is obsolete: true
Attachment #251127 - Flags: superreview+
Attachment #251127 - Flags: review?
Attachment #251058 - Flags: superreview?(emaijala)
Attachment #251127 - Flags: review? → review?(emaijala)
Comment on attachment 251127 [details] [diff] [review] Patch v2 Well, in my opinion you can remove the XXX comment. For this to actually cause any problems you need to have the system idle for more than 49.7 days. GetTickCount() simply wrapping doesn't cause trouble. See for example <http://www.thetaeng.com/TimerWrap.htm> for an article on it, and it's also mentioned in MSDN GetTickCount() docs. r=emaijala
Attachment #251127 - Flags: review?(emaijala) → review+
Ugh, I forgot to remove the XXX comment the first round, so there's two checkins for this bug now. Sorry. Checking in build/nsWinWidgetFactory.cpp; new revision: 1.74; previous revision: 1.73 Checking in windows/Makefile.in; new revision: 3.46; previous revision: 3.45 Checking in windows/nsIdleServiceWin.cpp; initial revision: 3.1 Checking in windows/nsIdleServiceWin.h; initial revision: 3.1 Followed by: Checking in windows/nsIdleServiceWin.cpp; new revision: 3.2; previous revision: 3.1
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
So, this broke a bundle of tinderboxen. The Thunderbird box didn't seem to know about LASTINPUTINFO. I really don't have a clue what's up there. Robert Sayre told me he got the same error as the Fx and SeaMonkey boxen, and fixed it by adding an empty constructor. I backed out before he told me that. I'll add a patch here after I've tested it myself.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Turns out the thunderbird bustage is to blame on a flag causing it to try to build in a win95 compatible way, which breaks this patch because the API didn't exist before win2k. Marking the bug about changing that flag as blocking this one.
Depends on: 362478
Attached patch Better patchSplinter Review
Just removing the declarations from the .h file works too. At least, it compiles and runs and (manually) tests fine. The thunderbird tinderbox fixed has a patch and review, it just needs checkin and some looking after, or so I hope :-)
Attachment #251127 - Attachment is obsolete: true
Attachment #252051 - Flags: superreview?(neil)
Attachment #252051 - Flags: review?
Attachment #252051 - Flags: review? → review?(emaijala)
Comment on attachment 252051 [details] [diff] [review] Better patch >+#include "nsIServiceManager.h" Nit: I still don't see where you're using this.
Attachment #252051 - Flags: superreview?(neil) → superreview+
Comment on attachment 252051 [details] [diff] [review] Better patch Check neil's comment. r=emaijala
Attachment #252051 - Flags: review?(emaijala) → review+
Checking in src/build/nsWinWidgetFactory.cpp; /cvsroot/mozilla/widget/src/build/nsWinWidgetFactory.cpp,v <-- nsWinWidgetFactory.cpp new revision: 1.76; previous revision: 1.75 done Checking in src/windows/Makefile.in; /cvsroot/mozilla/widget/src/windows/Makefile.in,v <-- Makefile.in new revision: 3.48; previous revision: 3.47 done Checking in src/windows/nsIdleServiceWin.cpp; /cvsroot/mozilla/widget/src/windows/nsIdleServiceWin.cpp,v <-- nsIdleServiceWin.cpp new revision: 3.5; previous revision: 3.4 done Checking in src/windows/nsIdleServiceWin.h; /cvsroot/mozilla/widget/src/windows/nsIdleServiceWin.h,v <-- nsIdleServiceWin.h new revision: 3.3; previous revision: 3.2 done (I've removed the include mentioned in comment #11) Tinderboxen are still a lovely shade of green, so marking this FIXED.
Status: REOPENED → RESOLVED
Closed: 18 years ago18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: