~azzar1/unity/fix-870143

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/ResultViewGrid.cpp

  • Committer: Andrea Azzarone
  • Date: 2012-01-07 17:09:23 UTC
  • mfrom: (1793.2.25 unity)
  • Revision ID: azzaronea@gmail.com-20120107170923-1u8ih02tjpvac3tl
Fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  , mouse_last_x_(-1)
63
63
  , mouse_last_y_(-1)
64
64
{
 
65
  SetAcceptKeyNavFocusOnMouseDown(false);
 
66
  
65
67
  auto needredraw_lambda = [&](int value)
66
68
  {
67
69
    NeedRedraw();
82
84
    last_mouse_down_y_ = y;
83
85
    uint index = GetIndexAtPosition(x, y);
84
86
    mouse_over_index_ = index;
85
 
    if (index >= 0 && index < results_.size())
86
 
    {
87
 
      // we got a click on a button so activate it
88
 
      Result result = results_[index];
89
 
      selected_index_ = index;
90
 
      focused_uri_ = result.uri;
91
 
    }
92
87
  });
93
88
 
94
89
  mouse_leave.connect([&](int x, int y, unsigned long mouse_state, unsigned long button_state)
500
495
  {
501
496
    if (selected_index_ < 0)
502
497
    {
503
 
      if (mouse_over_index_ >= 0 && mouse_over_index_ < static_cast<int>(results_.size()))
504
 
      {
505
 
        // to hack around nux, nux sends the keynavfocuschange event before
506
 
        // mouse clicks, so when mouse click happens we have already scrolled away
507
 
        // because the keynav focus changed
508
 
        focused_uri_ = results_[mouse_over_index_].uri;
509
 
        selected_index_ = mouse_over_index_;
510
 
      }
511
 
      else
512
 
      {
513
498
        focused_uri_ = results_.front().uri;
514
499
        selected_index_ = 0;
515
 
      }
516
500
    }
517
501
 
518
 
 
519
502
    int items_per_row = GetItemsPerRow();
520
503
    int focused_x = (renderer_->width + horizontal_spacing) * (selected_index_ % items_per_row);
521
504
    int focused_y = (renderer_->height + vertical_spacing) * (selected_index_ / items_per_row);
886
869
  last_mouse_down_y_ = -1;
887
870
  current_drag_uri_.clear();
888
871
  current_drag_icon_name_.clear();
 
872
  
 
873
  // We need this because the drag can start in a ResultViewGrid and can
 
874
  // end in another ResultViewGrid
 
875
  EmitMouseLeaveSignal(0, 0, 0, 0);
 
876
  
 
877
  // We need an extra mouse motion to highlight the icon under the mouse
 
878
  // as soon as dnd finish
 
879
  Display* display = nux::GetGraphicsDisplay()->GetX11Display();
 
880
  if (display)
 
881
  {
 
882
    XWarpPointer(display, None, None, 0, 0, 0, 0, 0, 0);
 
883
    XSync(display, 0);
 
884
  }
889
885
}
890
886
 
891
887
int