~tatokis/unity/gcc-72-errors

« back to all changes in this revision

Viewing changes to decorations/DecoratedWindow.cpp

Merging with lp:~3v1n0/unity/cmake-libs-prefixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
  bg_textures_.clear();
149
149
}
150
150
 
 
151
void Window::Impl::UpdateWindowState(unsigned old_state)
 
152
{
 
153
  Update();
 
154
 
 
155
  if (state_change_button_)
 
156
  {
 
157
    if (win_->state() & (CompWindowStateMaximizedVertMask|CompWindowStateMaximizedHorzMask))
 
158
    {
 
159
      state_change_button_->type = WindowButtonType::UNMAXIMIZE;
 
160
    }
 
161
    else
 
162
    {
 
163
      state_change_button_->type = WindowButtonType::MAXIMIZE;
 
164
    }
 
165
  }
 
166
}
 
167
 
151
168
void Window::Impl::UnsetExtents()
152
169
{
153
170
  if (win_->hasUnmapReference())
410
427
    top_layout_->Append(std::make_shared<WindowButton>(win_, WindowButtonType::MINIMIZE));
411
428
 
412
429
  if (win_->actions() & (CompWindowActionMaximizeHorzMask|CompWindowActionMaximizeVertMask))
413
 
    top_layout_->Append(std::make_shared<WindowButton>(win_, WindowButtonType::MAXIMIZE));
 
430
  {
 
431
    auto type = (win_->state() & (CompWindowStateMaximizedVertMask|CompWindowStateMaximizedHorzMask)) ?
 
432
                 WindowButtonType::UNMAXIMIZE : WindowButtonType::MAXIMIZE;
 
433
    auto state_change_button = std::make_shared<WindowButton>(win_, type);
 
434
    top_layout_->Append(state_change_button);
 
435
    state_change_button_ = state_change_button;
 
436
  }
414
437
 
415
438
  auto title = std::make_shared<Title>();
416
439
  title->text = last_title_.empty() ? WindowManager::Default().GetWindowName(win_->id()) : last_title_;
493
516
  return deco_elements_ & cu::DecorationElement::SHADOW;
494
517
}
495
518
 
 
519
bool Window::Impl::ShapedShadowDecorated() const
 
520
{
 
521
  return deco_elements_ & cu::DecorationElement::SHADOW &&
 
522
         deco_elements_ & cu::DecorationElement::SHAPED;
 
523
}
 
524
 
496
525
bool Window::Impl::FullyDecorated() const
497
526
{
498
527
  return deco_elements_ & cu::DecorationElement::BORDER;
503
532
  return (win_->frame() || win_->hasUnmapReference()) && FullyDecorated();
504
533
}
505
534
 
506
 
bool Window::Impl::IsRectangular() const
507
 
{
508
 
  return win_->region().numRects() == 1;
509
 
}
510
 
 
511
535
GLTexture* Window::Impl::ShadowTexture() const
512
536
{
513
 
  if (!IsRectangular())
 
537
  if (shaped_shadow_pixmap_)
514
538
    return shaped_shadow_pixmap_->texture();
515
539
 
 
540
  return SharedShadowTexture();
 
541
}
 
542
 
 
543
GLTexture* Window::Impl::SharedShadowTexture() const
 
544
{
516
545
  auto const& mi = manager_->impl_;
517
546
  if (active() || parent_->scaled())
518
547
    return mi->active_shadow_pixmap_->texture();
578
607
    if (!last_shadow_rect_.isEmpty())
579
608
      last_shadow_rect_.setGeometry(0, 0, 0, 0);
580
609
 
581
 
    return;
582
 
  }
 
610
    shaped_shadow_pixmap_.reset();
 
611
  }
 
612
  else if (deco_elements_ & cu::DecorationElement::SHAPED)
 
613
  {
 
614
    ComputeShapedShadowQuad();
 
615
  }
 
616
  else
 
617
  {
 
618
    shaped_shadow_pixmap_.reset();
 
619
    ComputeGenericShadowQuads();
 
620
  }
 
621
}
583
622
 
584
 
  const auto* texture = ShadowTexture();
 
623
void Window::Impl::ComputeGenericShadowQuads()
 
624
{
 
625
  const auto* texture = SharedShadowTexture();
585
626
 
586
627
  if (!texture || !texture->width() || !texture->height())
587
628
    return;
707
748
 
708
749
void Window::Impl::ComputeShapedShadowQuad()
709
750
{
710
 
  if (!(deco_elements_ & cu::DecorationElement::SHADOW))
711
 
  {
712
 
    if (!last_shadow_rect_.isEmpty())
713
 
      last_shadow_rect_.setGeometry(0, 0, 0, 0);
714
 
 
715
 
    return;
716
 
  }
717
 
 
718
751
  nux::Color color = active() ? manager_->active_shadow_color() : manager_->inactive_shadow_color();
719
752
  unsigned int radius = active() ? manager_->active_shadow_radius() : manager_->inactive_shadow_radius();
720
753
 
793
826
 
794
827
  glwin_->vertexBuffer()->begin();
795
828
 
796
 
  unsigned int num_quads = IsRectangular() ? shadow_quads_.size() : 1;
 
829
  unsigned int num_quads = ShapedShadowDecorated() ? 1 : shadow_quads_.size();
797
830
  for (unsigned int i = 0; i < num_quads; ++i)
798
831
  {
799
832
    auto& quad = shadow_quads_[Quads::Pos(i)];
993
1026
  impl_->Update();
994
1027
}
995
1028
 
 
1029
void Window::UpdateWindowState(unsigned old_state)
 
1030
{
 
1031
  impl_->UpdateWindowState(old_state);
 
1032
}
 
1033
 
996
1034
void Window::UpdateFrameRegion(CompRegion& r)
997
1035
{
998
1036
  if (impl_->frame_region_.isEmpty())
1035
1073
void Window::UpdateDecorationPosition()
1036
1074
{
1037
1075
  impl_->UpdateMonitor();
1038
 
  impl_->IsRectangular() ? impl_->ComputeShadowQuads() : impl_->ComputeShapedShadowQuad();
 
1076
  impl_->ComputeShadowQuads();
1039
1077
  impl_->UpdateWindowEdgesGeo();
1040
1078
  impl_->UpdateDecorationTextures();
1041
1079
  impl_->UpdateForceQuitDialogPosition();