diff options
| author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-09-04 12:26:06 -0300 |
|---|---|---|
| committer | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2012-09-04 12:26:06 -0300 |
| commit | 5182a9065ab28d7c7921d34f7f25c9c5e3b29524 (patch) | |
| tree | a50330aac2f3d20b4d5c240fbbafeedf13cfca5e /plugins/unityshell/src | |
| parent | 908d88658deb4190aae5c5f3e9fef25c9f7b7825 (diff) | |
Removed all originial decoration when window is in scale mode;
Draw window decoration inside of window following the designer docs; (bzr r2650.1.11)
Diffstat (limited to 'plugins/unityshell/src')
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 140 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 11 |
2 files changed, 109 insertions, 42 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 3d40eb65c..0e79a44a4 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -423,7 +423,10 @@ UnityScreen::UnityScreen(CompScreen* screen) } panel::Style::Instance().changed.connect(sigc::mem_fun(this, &UnityScreen::OnPanelStyleChanged)); - + + WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityScreen::OnInitiateSpreed)); + WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityScreen::OnTerminateSpreed)); + minimize_speed_controller->DurationChanged.connect( sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged) ); @@ -440,6 +443,25 @@ UnityScreen::~UnityScreen() reset_glib_logging(); } +void UnityScreen::OnInitiateSpreed() +{ + for (CompWindow *w : screen->windows()) + { + UnityWindow *uw = UnityWindow::get(w); + uw->InitiateSpreed(); + } +} + +void UnityScreen::OnTerminateSpreed() +{ + for (CompWindow *w : screen->windows()) + { + UnityWindow *uw = UnityWindow::get(w); + uw->TerminateSpreed(); + } +} + + void UnityScreen::initAltTabNextWindow() { KeyboardUtil key_util(screen->dpy()); @@ -3675,18 +3697,19 @@ void UnityWindow::DrawWindowDecoration(const GLWindowPaintAttrib& attrib, const GLMatrix& transform, unsigned int mask, + bool highlighted, float x, float y, float x2, float y2) { const float width = x2 - x; + const float height = y2 - y; // Paint a fake window decoration - WindowCairoContext::Ptr context(CreateCairoContext(width, SCALE_WINDOW_TITLE_SIZE)); + WindowCairoContext::Ptr context(CreateCairoContext(width, height)); cairo_save(context->cr_); cairo_push_group(context->cr_); // Round window decoration top border - const double height = SCALE_WINDOW_TITLE_SIZE; const double aspect = 1.0; const double corner_radius = height / 10.0; const double radius = corner_radius / aspect; @@ -3703,19 +3726,22 @@ UnityWindow::DrawWindowDecoration(const GLWindowPaintAttrib& attrib, cairo_clip(context->cr_); // Draw window decoration abased on gtk style - gtk_render_background(window_header_style_, context->cr_, 0, 0, width, SCALE_WINDOW_TITLE_SIZE); - gtk_render_frame(window_header_style_, context->cr_, 0, 0, width, SCALE_WINDOW_TITLE_SIZE); + gtk_render_background(window_header_style_, context->cr_, 0, 0, width, height); + gtk_render_frame(window_header_style_, context->cr_, 0, 0, width, height); cairo_pop_group_to_source(context->cr_); cairo_paint_with_alpha(context->cr_, 1.0); cairo_restore(context->cr_); - // Draw windows title - const float xText = CLOSE_ICON_SPACE * 2 + CLOSE_ICON_SIZE; - RenderText(context.get(), - xText, 0.0, - width - xText, SCALE_WINDOW_TITLE_SIZE); + if (highlighted) + { + // Draw windows title + const float xText = CLOSE_ICON_SPACE * 2 + CLOSE_ICON_SIZE; + RenderText(context.get(), + xText, 0.0, + width - xText, height); + } mask |= PAINT_WINDOW_BLEND_MASK; int maxWidth, maxHeight; @@ -3728,20 +3754,8 @@ UnityWindow::DrawWindowDecoration(const GLWindowPaintAttrib& attrib, } void -UnityWindow::scalePaintDecoration(const GLWindowPaintAttrib& attrib, - const GLMatrix& transform, - const CompRegion& region, - unsigned int mask) +UnityWindow::PrepareHeaderStyle() { - ScaleWindow *sWindow = ScaleWindow::get(window); - if (!sWindow) - return; - - sWindow->scalePaintDecoration(attrib, transform, region, mask); - - if (!sWindow->hasSlot()) // animation not finished - return; - if (!window_header_style_) { GtkWidgetPath* widget_path = gtk_widget_path_new(); @@ -3780,41 +3794,68 @@ UnityWindow::scalePaintDecoration(const GLWindowPaintAttrib& attrib, size); } } +} + +void +UnityWindow::scalePaintDecoration(const GLWindowPaintAttrib& attrib, + const GLMatrix& transform, + const CompRegion& region, + unsigned int mask) +{ + ScaleWindow *sWindow = ScaleWindow::get(window); + if (!sWindow) + return; + + sWindow->scalePaintDecoration(attrib, transform, region, mask); - // Make the windows header opaque to override the original + if (!sWindow->hasSlot()) // animation not finished + return; + + UnityScreen* us = UnityScreen::get(screen); + const guint32 xid = window->id(); + const bool highlighted = (us->highlighted_window_ == xid); GLWindowPaintAttrib sAttrib(attrib); sAttrib.opacity = OPAQUE; + PrepareHeaderStyle(); + ScalePosition pos = sWindow->getCurrentPosition(); int maxHeight, maxWidth; // Use "1" as margin to make sure to cover all originial decoration const float width = (window->width() * pos.scale) + 2; const float x = pos.x() + window->x() - 1; float y = pos.y() + window->y(); + float decorationHeight = SCALE_WINDOW_TITLE_SIZE; // If window is decorated draw the decoration over the original - // otherwise draw inside the window - WindowManager *wm = WindowManager::Default(); - if (wm->IsWindowDecorated(window->id()) && !wm->IsWindowMaximized(window->id())) - y -= SCALE_WINDOW_TITLE_SIZE; - - const float iconX = x + CLOSE_ICON_SPACE; - const float iconY = y + ((SCALE_WINDOW_TITLE_SIZE - CLOSE_ICON_SIZE) / 2.0); + // otherwise draw a small bar over the window + if (!highlighted) + decorationHeight = SCALE_WINDOW_TITLE_SIZE * 0.30; - DrawWindowDecoration(sAttrib, transform, mask, + DrawWindowDecoration(sAttrib, transform, mask, highlighted, x, y, - x + width, y + SCALE_WINDOW_TITLE_SIZE); + x + width, y + decorationHeight); - mask |= PAINT_WINDOW_BLEND_MASK; - maxHeight = maxWidth = 0; - foreach(GLTexture *icon, close_icon_) + if (highlighted) { - DrawTexture(icon, sAttrib, transform, mask, - iconX, iconY, - maxWidth , maxHeight); - } + const float iconX = x + CLOSE_ICON_SPACE; + const float iconY = y + ((SCALE_WINDOW_TITLE_SIZE - CLOSE_ICON_SIZE) / 2.0); + maxHeight = maxWidth = 0; + mask |= PAINT_WINDOW_BLEND_MASK; + + foreach(GLTexture *icon, close_icon_) + { + DrawTexture(icon, sAttrib, transform, mask, + iconX, iconY, + maxWidth , maxHeight); + } - close_button_area_ = CompRect(iconX, iconY, maxWidth, maxHeight); + close_button_area_ = CompRect(iconX, iconY, maxWidth, maxHeight); + } + else + { + close_button_area_ = CompRect(); + } } void @@ -3844,6 +3885,23 @@ UnityWindow::scaleSelectWindow () sWindow->scaleSelectWindow(); } +void UnityWindow::InitiateSpreed() +{ + WindowManager *wm = WindowManager::Default(); + const guint32 xid = window->id(); + has_original_decoration_ = wm->IsWindowDecorated(xid) && + !wm->IsWindowMaximized(xid); + wm->Undecorate(xid); +} + +void UnityWindow::TerminateSpreed() +{ + if (has_original_decoration_) + WindowManager::Default()->Decorate(window->id()); + else + WindowManager::Default()->Undecorate(window->id()); +} + UnityWindow::~UnityWindow() { UnityScreen* us = UnityScreen::get(screen); diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 2caf745dd..7ad71ac03 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -249,7 +249,10 @@ private: void OnPanelStyleChanged(); void InitGesturesSupport(); - + + void OnInitiateSpreed(); + void OnTerminateSpreed(); + nux::animation::TickSource tick_source_; nux::animation::AnimationController animation_controller_; @@ -436,6 +439,9 @@ public: const CompRegion &, unsigned int); + void InitiateSpreed(); + void TerminateSpreed(); + private: void DoEnableFocus (); void DoDisableFocus (); @@ -470,6 +476,7 @@ private: void DrawWindowDecoration(const GLWindowPaintAttrib& attrib, const GLMatrix& transform, unsigned int mask, + bool highlighted, float x, float y, float x2, float y2); void DrawTexture(GLTexture *icon, const GLWindowPaintAttrib& attrib, @@ -480,6 +487,7 @@ private: void RenderText(WindowCairoContext *context, float x, float y, float maxWidth, float maxHeight); + void PrepareHeaderStyle(); std::shared_ptr<WindowCairoContext> CreateCairoContext(float width, float height); compiz::WindowInputRemoverLock::Weak input_remover_; @@ -488,6 +496,7 @@ private: GLTexture::List close_icon_; CompRect close_button_area_; glib::Object<GtkStyleContext> window_header_style_; + bool has_original_decoration_; }; |
