diff options
| -rw-r--r-- | launcher/EdgeBarrierController.cpp | 12 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 65 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 4 | ||||
| -rw-r--r-- | tests/test_edge_barrier_controller.cpp | 8 |
4 files changed, 73 insertions, 16 deletions
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index 8bfa1ebac..4f549cc3d 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -155,6 +155,12 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event) { + if (owner->released) + { + BarrierRelease(owner, event->event_id); + return; + } + unsigned int monitor = owner->index; bool process = true; @@ -166,11 +172,7 @@ void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* o process = false; } - if (process && owner->released) - { - BarrierRelease(owner, event->event_id); - } - else if (process && owner->x1 > 0) + if (process && owner->x1 > 0) { decaymulator_.value = decaymulator_.value + event->velocity; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 81ce97c4b..0ec87f497 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -647,24 +647,28 @@ void UnityScreen::paintDisplay() { CompOutput *output = _last_output; + DrawTopPanelBackground(); + + auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); + nux::ObjectPtr<nux::IOpenGLTexture2D> device_texture = - nux::GetGraphicsDisplay()->GetGpuDevice()->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (), - screen->width(), screen->height(), 1, nux::BITFMT_R8G8B8A8); + gpu_device->CreateTexture2DFromID(gScreen->fbo ()->tex ()->name (), + screen->width(), screen->height(), 1, nux::BITFMT_R8G8B8A8); - nux::GetGraphicsDisplay()->GetGpuDevice()->backup_texture0_ = device_texture; + gpu_device->backup_texture0_ = device_texture; - nux::Geometry geo = nux::Geometry (0, 0, screen->width (), screen->height ()); - nux::Geometry oGeo = nux::Geometry (output->x (), output->y (), output->width (), output->height ()); + nux::Geometry geo(0, 0, screen->width (), screen->height ()); + nux::Geometry outputGeo(output->x (), output->y (), output->width (), output->height ()); BackgroundEffectHelper::monitor_rect_ = geo; GLint fboID; // Nux renders to the referenceFramebuffer when it's embedded. glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fboID); - wt->GetWindowCompositor().SetReferenceFramebuffer(fboID, oGeo); + wt->GetWindowCompositor().SetReferenceFramebuffer(fboID, outputGeo); nuxPrologue(); _in_paint = true; - wt->RenderInterfaceFromForeignCmd (&oGeo); + wt->RenderInterfaceFromForeignCmd (&outputGeo); _in_paint = false; nuxEpilogue(); @@ -724,6 +728,53 @@ void UnityScreen::paintDisplay() didShellRepaint = true; } +void UnityScreen::DrawTopPanelBackground() +{ + auto graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); + + if (!graphics_engine->UsingGLSLCodePath() || !launcher_controller_->IsOverlayOpen() || !paint_panel_) + return; + + if (TopPanelBackgroundTextureNeedsUpdate()) + UpdateTopPanelBackgroundTexture(); + + if (panel_texture_.IsValid()) + { + graphics_engine->ResetModelViewMatrixStack(); + graphics_engine->Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); + graphics_engine->ResetProjectionMatrix(); + graphics_engine->SetOrthographicProjectionMatrix(screen->width (), screen->height()); + + nux::TexCoordXForm texxform; + int panel_height = panel_style_.panel_height; + graphics_engine->QRP_GLSL_1Tex(0, 0, screen->width (), panel_height, panel_texture_, texxform, nux::color::White); + } +} + +bool UnityScreen::TopPanelBackgroundTextureNeedsUpdate() const +{ + return panel_texture_has_changed_ || !panel_texture_.IsValid(); +} + +void UnityScreen::UpdateTopPanelBackgroundTexture() +{ + auto gpu_device = nux::GetGraphicsDisplay()->GetGpuDevice(); + auto &panel_style = panel::Style::Instance(); + + panel_texture_.Release(); + + std::unique_ptr<nux::NBitmapData> bitmap(panel_style.GetBackground(screen->width(), screen->height(), 1.0f)); + nux::ObjectPtr<nux::BaseTexture> texture2D(gpu_device->CreateSystemCapableTexture()); + + if (bitmap && texture2D) + { + texture2D->Update(bitmap.get()); + panel_texture_ = texture2D->GetDeviceTexture(); + } + + panel_texture_has_changed_ = false; +} + bool UnityScreen::forcePaintOnTop () { return !allowWindowPaint || diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index fbe7e4c53..a1de06832 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -241,6 +241,10 @@ private: void InitGesturesSupport(); + void DrawTopPanelBackground(); + bool TopPanelBackgroundTextureNeedsUpdate() const; + void UpdateTopPanelBackgroundTexture(); + nux::animation::TickSource tick_source_; nux::animation::AnimationController animation_controller_; diff --git a/tests/test_edge_barrier_controller.cpp b/tests/test_edge_barrier_controller.cpp index f00ac2bf1..3ea731e30 100644 --- a/tests/test_edge_barrier_controller.cpp +++ b/tests/test_edge_barrier_controller.cpp @@ -156,9 +156,9 @@ TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrier) bc.Subscribe(&handling_subscriber, monitor); MockPointerBarrier owner(monitor, true); - auto breaking_barrier_event = MakeBarrierEvent(0, true); + auto breaking_barrier_event = MakeBarrierEvent(5, true); - EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); + EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1); bc.ProcessBarrierEvent(&owner, breaking_barrier_event); } @@ -239,7 +239,7 @@ TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHand bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false)); } -TEST_F(TestEdgeBarrierController, BreakingEdgeDontReleasesBarrierForHandledEvents) +TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEvents) { MockPointerBarrier owner; int monitor = 0; @@ -250,7 +250,7 @@ TEST_F(TestEdgeBarrierController, BreakingEdgeDontReleasesBarrierForHandledEvent ASSERT_TRUE(owner.released()); subscribers_[monitor].handles_ = true; - EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0); + EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1); bc.ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true)); } |
