* Use SDL_WaitEvent instead of SDL_PollEvent.
* To avoid the program getting 'locked' when there is no user input (sliders, colorspray), we use a timer that queues events to make grafX2 act (and refresh the screen) TODO : * To reduce cpu usage when idle even more, start the timer only when it's needed (colorspray is drawing, or a scrollbar is scrolling) * For now everyone uses the same timer, so the same delay. This means there is no fast-scroll and slow-scroll for sliders. Starting the timer with a different speed in each case would solve that * The event handling for sliders will currently react to any mouse event. Thismeans the slider will move faster if you slightly move the mouse while keeping in the button. Not what wewant, so weshoud all a timer_expired global and the slider should wait for that (and reset it when acknowledged). git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1556 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
bce1c9d7ee
commit
5ee0b4943f
10
src/engine.c
10
src/engine.c
@ -2759,7 +2759,7 @@ short Window_get_clicked_button(void)
|
||||
Hide_cursor();
|
||||
Window_select_normal_button(temp1->Pos_X,temp1->Pos_Y,temp1->Width,temp1->Height);
|
||||
Display_cursor();
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
// Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp1->Pos_X,temp1->Pos_Y,temp1->Width,temp1->Height);
|
||||
Display_cursor();
|
||||
@ -2783,7 +2783,7 @@ short Window_get_clicked_button(void)
|
||||
}
|
||||
}
|
||||
|
||||
// Test click oin slider/scroller bars
|
||||
// Test click on slider/scroller bars
|
||||
for (temp3=Window_scroller_button_list; temp3; temp3=temp3->Next)
|
||||
{
|
||||
// Button Up arrow
|
||||
@ -2806,7 +2806,7 @@ short Window_get_clicked_button(void)
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
// Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y,11,11);
|
||||
@ -2835,7 +2835,7 @@ short Window_get_clicked_button(void)
|
||||
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
// Slider_timer((Mouse_K==1)? Config.Delay_left_click_on_slider : Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp3->Pos_X,temp3->Pos_Y+temp3->Height-11,11,11);
|
||||
@ -2941,7 +2941,7 @@ short Window_get_button_shortcut(void)
|
||||
Window_select_normal_button(temp->Pos_X,temp->Pos_Y,temp->Width,temp->Height);
|
||||
Display_cursor();
|
||||
|
||||
Slider_timer(Config.Delay_right_click_on_slider);
|
||||
// Slider_timer(Config.Delay_right_click_on_slider);
|
||||
|
||||
Hide_cursor();
|
||||
Window_unselect_normal_button(temp->Pos_X,temp->Pos_Y,temp->Width,temp->Height);
|
||||
|
||||
10
src/input.c
10
src/input.c
@ -243,8 +243,9 @@ int Move_cursor_with_constraints()
|
||||
Mouse_K=Input_new_mouse_K;
|
||||
|
||||
if (Mouse_moved > Config.Mouse_merge_movement)
|
||||
if (! Operation[Current_operation][Mouse_K_unique]
|
||||
[Operation_stack_size].Fast_mouse)
|
||||
// TODO : not sure what that was meant to do, but it prevents moving the default cursor when there is no operation.
|
||||
// if (! Operation[Current_operation][Mouse_K_unique]
|
||||
// [Operation_stack_size].Fast_mouse)
|
||||
feedback=1;
|
||||
}
|
||||
if (mouse_blocked)
|
||||
@ -681,7 +682,7 @@ int Get_input(void)
|
||||
// Process as much events as possible without redrawing the screen.
|
||||
// This mostly allows us to merge mouse events for people with an high
|
||||
// resolution mouse
|
||||
while( (!user_feedback_required) && SDL_PollEvent(&event)) // Try to cumulate for a full VBL except if there is a required feedback
|
||||
while( (!user_feedback_required) && SDL_WaitEvent(&event)) // Try to cumulate for a full VBL except if there is a required feedback
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
@ -765,6 +766,9 @@ int Get_input(void)
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
user_feedback_required = 1;
|
||||
break;
|
||||
default:
|
||||
// DEBUG("Unhandled SDL event number : ",event.type);
|
||||
break;
|
||||
|
||||
25
src/main.c
25
src/main.c
@ -409,6 +409,30 @@ int Analyze_command_line(int argc, char * argv[], char *main_filename, char *mai
|
||||
return file_in_command_line;
|
||||
}
|
||||
|
||||
|
||||
Uint32 putTimerEvent(Uint32 i, void* p)
|
||||
{
|
||||
SDL_Event event;
|
||||
SDL_UserEvent userevent;
|
||||
|
||||
/* Dans cet exemple, notre fonction de rappel pousse
|
||||
un evenement SDL_USEREVENT dans la file... */
|
||||
|
||||
userevent.type = SDL_USEREVENT;
|
||||
userevent.code = 0;
|
||||
userevent.data1 = NULL;
|
||||
userevent.data2 = NULL;
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user = userevent;
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------ Initialiser le programme -------------------------
|
||||
// Returns 0 on fail
|
||||
int Init_program(int argc,char * argv[])
|
||||
@ -521,6 +545,7 @@ int Init_program(int argc,char * argv[])
|
||||
printf("Couldn't initialize SDL.\n");
|
||||
return(0);
|
||||
}
|
||||
SDL_TimerID tid = SDL_AddTimer(10, putTimerEvent, NULL);
|
||||
|
||||
Joystick = SDL_JoystickOpen(0);
|
||||
SDL_EnableKeyRepeat(250, 32);
|
||||
|
||||
11
src/misc.c
11
src/misc.c
@ -675,17 +675,6 @@ void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buff
|
||||
}
|
||||
}
|
||||
|
||||
void Slider_timer(byte speed)
|
||||
//Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte
|
||||
{
|
||||
Uint32 end;
|
||||
byte original_mouse_k = Mouse_K;
|
||||
end = SDL_GetTicks() + speed*10;
|
||||
do
|
||||
{
|
||||
if (!Get_input()) SDL_Delay(20);
|
||||
} while (Mouse_K == original_mouse_k && SDL_GetTicks()<end);
|
||||
}
|
||||
|
||||
void Scroll_picture(byte * main_src, byte * main_dest, short x_offset,short y_offset)
|
||||
{
|
||||
|
||||
@ -42,7 +42,6 @@ void Palette_256_to_64(T_Palette palette);
|
||||
void Palette_64_to_256(T_Palette palette);
|
||||
void Clear_current_image(byte color);
|
||||
void Clear_current_image_with_stencil(byte color, byte * stencil);
|
||||
void Slider_timer(byte speed);
|
||||
dword Round_div(dword numerator,dword divisor);
|
||||
word Count_used_colors(dword * usage);
|
||||
word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user