#57 ActivateOther doesn't changes current focus

closed-fixed
Emil Brink
Interface (27)
8
2011-06-14
2011-03-21
Skotlex
No

When switching panes, the newly activated pane should receive focus. Currently Gentoo only goes through the list headers to activate/deactivate them, without actually changing the focus. The result? The selection that you control with the keyboard will still be the selection of the previously active pane.

How to reproduce this problem? Well, I have "tab" linked to "ActivateOther", so if I am moving my current selection with the arrows, hitting tab should change the active pane, and then the arrows would control the selection on the NOW selected pane. As it stands, hitting tabs only changes the headers of the column, while the arrows are still operating on the old pane.

Gentoo's function where the pane switching is handled is activate_render() (dirpane.c), and as you can see there's no actual code to set the focus to the "to" pane.

As reference, another similar project (EmelFM2) uses this piece of code to switch the focus:

#ifdef USE_GTK2_18
if (gtk_widget_has_focus (other_view->treeview))
#else
if (GTK_WIDGET_HAS_FOCUS (other_view->treeview))
#endif
gtk_widget_grab_focus (curr_view->treeview);

Migrating this code to gentoo, it would end up looking like this function:

void dp_focus(DirPane *dp)
{
if(dp != NULL)
{
#if GTK_CHECK_VERSION(2, 18, 0)
if (gtk_widget_has_focus(dp->main->gui->cur_pane->view))
#else
if (GTK_WIDGET_HAS_FOCUS(dp->main->gui->cur_pane->view))
#endif
gtk_widget_grab_focus (dp->view);
}
}

Though I'll leave it up to you to decide if it might be best to always focus the new pane when activating it. I tested this function and it fixes the focus-changing behaviour in version 0.19.9

PS: As an aside, I don't recommend removing the focus from the previous pane (dp_unfocus), though I am not sure what that code is supposed to do, because it seems to not affect at all the prev pane here.

Discussion

  • Skotlex
    Skotlex
    2011-03-28

    • priority: 5 --> 8
     
  • Emil Brink
    Emil Brink
    2011-04-03

    Sounds like a "proper" bug, thanks a lot. I will look into this as soon as I get my source tracking system back online.

     
  • Emil Brink
    Emil Brink
    2011-04-03

    • labels: 1560045 --> Interface
     
  • Emil Brink
    Emil Brink
    2011-04-10

    I've implemented a fix for this, so I'll mark it as "Fixed" but keep it open until the version of gentoo that contains the fix has been released.

    Btw, the fix I ended up doing is way simpler, it's a single-line call to gtk_widget_grab_focus() in the activate_render() function. It seems to work just fine, here.

     
  • Emil Brink
    Emil Brink
    2011-04-10

    • status: open --> open-fixed
     
  • Emil Brink
    Emil Brink
    2011-06-14

    • status: open-fixed --> closed-fixed
     
  • Emil Brink
    Emil Brink
    2011-06-14

    Closed, this fix is in 0.19.10 which was recently released. Note that gentoo now *requires* GTK+ 2.24.