Permalink
Browse files

Carbon code no longer eats whole CPU while waiting for user input.

  • Loading branch information...
rcgordon committed Oct 10, 2006
1 parent 1d00533 commit 4d87a6244e51b081fc1425cf654148f37aa08430
Showing with 22 additions and 17 deletions.
  1. +2 −0 CHANGES
  2. +9 −6 carbon/carbonres.c
  3. +1 −1 carbon/carbonres.h
  4. +4 −4 carbon_ui.c
  5. +2 −2 check_carbon.c
  6. +4 −4 uninstall_carbonui.c
View
@@ -1,4 +1,6 @@
Current:
Ryan C. Gordon (Running With Scissors) - Tue Oct 10 08:52:56 EDT 2006
* Carbon code no longer eats whole CPU while waiting for user input.
Ryan C. Gordon (Gunnar Games) - Wed Sep 27 00:26:41 EDT 2006
* Carbon code now completely supports Unicode.
Ryan C. Gordon (Procedural Arts) - Sun Aug 6 07:43:51 EDT 2006
View
@@ -695,8 +695,7 @@ int carbon_IterateForState(CarbonRes *Res, int *StateFlag)
// Loop until the state flag has changed by some outside code or an error occurs
while(*StateFlag == Start)
{
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// Update any thing on the window display that needs to be updated.
//QDFlushPortBuffer(GetWindowPort(Res->Window), NULL);
}
@@ -960,7 +959,7 @@ void carbon_UpdateImage(CarbonRes *Res, const char *Filename, const char *Path,
}
}
void carbon_HandlePendingEvents(CarbonRes *Res)
void carbon_HandlePendingEvents(CarbonRes *Res, int sleepIfNone)
{
EventRef theEvent;
EventTargetRef theTarget;
@@ -975,6 +974,10 @@ void carbon_HandlePendingEvents(CarbonRes *Res)
SendEventToEventTarget (theEvent, theTarget);
ReleaseEvent(theEvent);
}
else if (sleepIfNone)
{
usleep(50000);
}
// readme/eula window was opened non-blocking. Handle.
if ((PromptingWindow != NULL) && (PromptResponseValid))
@@ -1168,7 +1171,7 @@ int carbon_Prompt(CarbonRes *Res, PromptType Type, const char *Message, char *In
// Wait for the prompt window to close
// Wait for events until the prompt window has been responded to
while(!PromptResponseValid)
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// HandlePendingEvents will hide window.
@@ -1269,7 +1272,7 @@ int carbon_ReadmeOrLicense(CarbonRes *Res, int ReadmeNotLicense, char *Message,
// Wait for the prompt window to close
// Wait for events until the prompt window has been responded to
while(!PromptResponseValid)
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// HandlePendingEvents will hide the window. What a mess. --ryan.
@@ -1834,7 +1837,7 @@ int carbon_MediaPrompt(CarbonRes *Res, int *CDRomNotDir, char *Dir, int DirLengt
// Wait for the prompt window to close
// Wait for events until the prompt window has been responded to
while(!PromptResponseValid)
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// HandlePendingEvents will hide window.
View
@@ -229,7 +229,7 @@ void carbon_EnableControl(CarbonRes *, int);
void carbon_SetInstallClass(CarbonRes *, int);
int carbon_GetInstallClass(CarbonRes *);
void carbon_UpdateImage(CarbonRes *, const char *, const char *, int);
void carbon_HandlePendingEvents(CarbonRes *);
void carbon_HandlePendingEvents(CarbonRes *, int);
void carbon_SetLabelText(CarbonRes *, int, const char *);
void carbon_GetLabelText(CarbonRes *, int, char *, int);
void carbon_SetEntryText(CarbonRes *, int, const char *);
View
@@ -1138,7 +1138,7 @@ static install_state carbonui_pick_class(install_info *info)
static void carbonui_idle(install_info *info)
{
carbon_debug("***carbonui_idle()\n");
carbon_HandlePendingEvents(MyRes);
carbon_HandlePendingEvents(MyRes, 1);
}
static install_state carbonui_setup(install_info *info)
@@ -1349,7 +1349,7 @@ static int carbonui_update(install_info *info, const char *path, size_t progress
}
// Handle any UI events in queue
carbon_HandlePendingEvents(MyRes);
carbon_HandlePendingEvents(MyRes, 0);
return TRUE;
/*
int textlen;
@@ -1415,7 +1415,7 @@ static int carbonui_update(install_info *info, const char *path, size_t progress
carbon_SetProgress(MyRes, COPY_TOTAL_PROGRESS_ID, info->installed_bytes, CurTotalSize);
// Handle any UI events in queue
carbon_HandlePendingEvents(MyRes);
carbon_HandlePendingEvents(MyRes, 0);
return TRUE;*/
}
@@ -1533,7 +1533,7 @@ static void carbonui_shutdown(install_info *info)
carbon_debug("***carbonui_shutdown()\n");
carbon_UnloadCarbonRes(MyRes);
carbon_HandlePendingEvents(MyRes);
carbon_HandlePendingEvents(MyRes, 0);
}
int carbonui_okay(Install_UI *UI, int *argc, char ***argv)
View
@@ -2,7 +2,7 @@
* Check and Rescue Tool for Loki Setup packages. Verifies the consistency of the files,
* and optionally restores them from the original installation medium.
*
* $Id: check_carbon.c,v 1.8 2006-08-06 11:45:04 icculus Exp $
* $Id: check_carbon.c,v 1.9 2006-10-10 13:00:55 icculus Exp $
*/
#include <stdlib.h>
@@ -389,7 +389,7 @@ int main(int argc, char *argv[])
file;
file = loki_getnext_file(file) ) {
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
switch ( loki_check_file(file) ) {
case LOKI_REMOVED:
add_message(_("%s was REMOVED"), loki_getpath_file(file));
View
@@ -261,7 +261,7 @@ void OnCommandUninstall()
//set_status_text(text);
// See if the user wants to cancel the uninstall
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// Display an optional message to the user
message = loki_getmessage_component(component->component);
@@ -294,7 +294,7 @@ void OnCommandUninstall()
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
// See if the user wants to cancel the uninstall
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
}
} while((button = GoToNextComponent(button)));
@@ -316,7 +316,7 @@ void OnCommandUninstall()
//set_status_text(text);
// See if the user wants to cancel the uninstall
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
// Display an optional message to the user
message = loki_getmessage_component(component->component);
@@ -352,7 +352,7 @@ void OnCommandUninstall()
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
// See if the user wants to cancel the uninstall
carbon_HandlePendingEvents(Res);
carbon_HandlePendingEvents(Res, 1);
break;
}

0 comments on commit 4d87a62

Please sign in to comment.