Skip to content

Commit

Permalink
disable mouse-over-image when no lua callback is registered
Browse files Browse the repository at this point in the history
this should improve overall responsiveness quite a bit

this is a horrible hack which is OK in master but shouldn't
be ported to master. A whole rewrite of that area should
be done to fix this for real
  • Loading branch information
boucman committed Mar 5, 2016
1 parent c3a95e5 commit d5a9b0c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lua/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ static int lua_register_event(lua_State *L)
lua_pop(L, 2);
return luaL_error(L, "unknown event type : %s\n", evt_name);
}
if(!strcmp(evt_name,"mouse-over-image-changed")) {
darktable.lua_state.mouse_event_registered = true;
}
lua_getfield(L, -1, "on_register");
lua_getfield(L, -2, "data");
for(int i = 1; i <= nparams; i++) lua_pushvalue(L, i);
Expand Down
2 changes: 2 additions & 0 deletions src/lua/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ static int lua_job_valid(lua_State *L)
}
}


static void on_mouse_over_image_changed(gpointer instance, gpointer user_data)
{
if(!darktable.lua_state.mouse_event_registered) return;
int imgid = dt_control_get_mouse_over_id();
if(imgid != -1) {
dt_lua_do_chunk_async(dt_lua_event_trigger_wrapper,
Expand Down
1 change: 1 addition & 0 deletions src/lua/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void dt_lua_init_early(lua_State *L)
}
darktable.lua_state.state = L;
darktable.lua_state.ending = false;
darktable.lua_state.mouse_event_registered = false;
darktable.lua_state.pending_threads = 0;
dt_lua_init_lock(); // lock is initialized in the locked state
luaL_openlibs(darktable.lua_state.state);
Expand Down
4 changes: 4 additions & 0 deletions src/lua/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ typedef struct
dt_pthread_mutex_t mutex;
int pending_threads ;
bool ending;
// HORRIBLE HACK, STABLE BRANCH ONLY
// allow the mouse event to be skipped very early
// if no callback for it was registered
bool mouse_event_registered;

} dt_lua_state_t;

Expand Down

0 comments on commit d5a9b0c

Please sign in to comment.