Merge lp:~saviq/unity-2d/titlebar-dblclick into lp:unity-2d

Proposed by Michał Sawicz
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 740
Merged at revision: 739
Proposed branch: lp:~saviq/unity-2d/titlebar-dblclick
Merge into: lp:unity-2d
Diff against target: 151 lines (+80/-0)
4 files modified
panel/applets/appname/appnameapplet.cpp (+41/-0)
panel/applets/appname/appnameapplet.h (+7/-0)
panel/applets/appname/windowhelper.cpp (+29/-0)
panel/applets/appname/windowhelper.h (+3/-0)
To merge this branch: bzr merge lp:~saviq/unity-2d/titlebar-dblclick
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Approve
Łukasz Zemczak Approve
Gerry Boland (community) Approve
Ugo Riboni Pending
Review via email: mp+76759@code.launchpad.net

Commit message

[panel] double click or drag titleBar to unmaximize

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote :

Great work, Michał!
The double click part seems to work quite reliably; however, I noticed a very strange behaviour with the dragging: if you drag the mouse cursor over the indicators (be it the applets, or the application menus) and then continue dragging down and immediately stop as soon as the window gets unmaximized, the mouse cursor remains in its "dragging" form, and all keyboard input seems to be disabled (for instance, you cannot switch desktop with Ctrl+Alt+Right) except for the ESC key, which brings the window back to the maximized mode.

Also, please adjust the coding style to put "*" and "&" next to the type name, and not next to the variable name.

review: Needs Fixing
Revision history for this message
Alberto Mardegan (mardy) wrote :

Sorry, the description of the way to trigger the bug is wrong: it has actually nothing to do on whether the cursor hovers the indicators, and can happen even if you simply drag it down just vertically.
It's rather hard to reproduce, actually.

Revision history for this message
Michał Sawicz (saviq) wrote :

I've just put this in a ppa (ppa:saviq/junk) but LP is slow to pick it up... so when you guys find the time to check it out, check in the PPA, and if it's not there just build it yourselves ;P

Revision history for this message
Michał Sawicz (saviq) wrote :

Make that ppa:saviq/stuff...

Revision history for this message
Gerry Boland (gerboland) wrote :

Hey Michał,
it does work nicely (with multimonitors too). I could not reproduce Alberto's bug.

Only little thing that bothered me:
- maximise window, then grab very top of titlebar and drag down. When it un-maximises, mouse is grabbing very bottom of the titlebar.
But really that's just me being pedantic.

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

Bug: Double right-click on maximised titlebar makes it un-maximise.

Question: should a right-click on maximised titlebar open the usual window-tools dropdown menu (Maximise, Minimise, Move...)?

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Works nicely here as well. I did some stress-tests and it still maximized/un-maximized correctly. Could not reproduce the bug mentioned by Alberto on my laptop as (Ubuntu 11.10) - both with a mouse and a touchpad. As for me - everything seems nice as it is.

review: Approve
Revision history for this message
Alberto Mardegan (mardy) wrote :

It may be that I have something wrong with my laptop touchpad; in a while I'll try with an external mouse, and see if it still happens.

Meanwhile, I found another issue: if you start gnome-terminal, when restoring the window via a doubleclick the window is restored to a geometry which is not the same used when restoring it via the titlebar restore button or by dragging the window out of the titlebar: the hight becomes much higher.

Curiously, this does not happen in gedit or firefox, so it's all rather suspicious.

Revision history for this message
Gerry Boland (gerboland) wrote :

I managed to reproduce Alberto's Terminal bug now too.

When I opened a Terminal window, maximised and unmaximised it 4 times, the 4th time the window geometry changes.

I could not reproduce this with the current unity-2d trunk (using max/unmax buttons).

gnome-terminal height has always behaved strangely for me. I tried other apps but they all work fine.

Revision history for this message
Michał Sawicz (saviq) wrote :

Dnia 2011-09-26, pon o godzinie 10:14 +0000, Gerry Boland pisze:
> When I opened a Terminal window, maximised and unmaximised it 4 times,
> the 4th time the window geometry changes.

I can't reproduce... I wonder how related is it to bug #822897 - I've
had the terminal behave that way, too.

@gerboland re: cursor position - that's not something we can control,
AFAIK. The WM receives an x/y coordinate of where the dragging started
and does its magic. It's probably related to decorations not being part
of the window or something.

Thanks for all the reviews!
--
Michał Sawicz <email address hidden>

lp:~saviq/unity-2d/titlebar-dblclick updated
738. By Michał Sawicz

[panel] follow style guidelines

739. By Michał Sawicz

[panel] missing indent

Revision history for this message
Alberto Mardegan (mardy) wrote :

Thanks Michał! I tried it now, and it works great.
Just one style issue again: check the indentation of line 126 in appnameapplet.h: it should be aligned with the first character after "(".

lp:~saviq/unity-2d/titlebar-dblclick updated
740. By Michał Sawicz

[panel] another style fix

Revision history for this message
Alberto Mardegan (mardy) wrote :

Damn, it's perfect! ;-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/applets/appname/appnameapplet.cpp'
2--- panel/applets/appname/appnameapplet.cpp 2011-09-15 09:56:14 +0000
3+++ panel/applets/appname/appnameapplet.cpp 2011-09-27 12:02:24 +0000
4@@ -47,6 +47,8 @@
5 #include <QPainter>
6 #include <QApplication>
7 #include <QDesktopWidget>
8+#include <QMouseEvent>
9+#include <QPoint>
10
11 static const int APPNAME_LABEL_LEFT_MARGIN = 6;
12
13@@ -125,6 +127,12 @@
14 QLabel* m_label;
15 WindowHelper* m_windowHelper;
16 MenuBarWidget* m_menuBarWidget;
17+ QPoint m_dragStartPosition;
18+ bool m_dragInProgress;
19+
20+ AppNameAppletPrivate()
21+ : m_dragInProgress(false)
22+ {}
23
24 void setupLabel()
25 {
26@@ -270,4 +278,37 @@
27 updateWidgets();
28 }
29
30+void AppNameApplet::mouseDoubleClickEvent(QMouseEvent*) {
31+ d->m_windowHelper->unmaximize();
32+}
33+
34+void AppNameApplet::mousePressEvent(QMouseEvent* event) {
35+ if (event->button() == Qt::LeftButton) {
36+ d->m_dragStartPosition = event->pos();
37+ d->m_dragInProgress = true;
38+ } else {
39+ Unity2d::PanelApplet::mousePressEvent(event);
40+ }
41+}
42+
43+void AppNameApplet::mouseReleaseEvent(QMouseEvent* event) {
44+ if (d->m_dragInProgress && event->button() == Qt::LeftButton) {
45+ d->m_dragInProgress = false;
46+ } else {
47+ Unity2d::PanelApplet::mouseReleaseEvent(event);
48+ }
49+}
50+
51+void AppNameApplet::mouseMoveEvent(QMouseEvent* event) {
52+ if (d->m_dragInProgress && (event->buttons() & Qt::LeftButton)) {
53+ if ((event->pos() - d->m_dragStartPosition).manhattanLength()
54+ >= QApplication::startDragDistance()) {
55+ d->m_dragInProgress = false;
56+ d->m_windowHelper->drag(d->m_dragStartPosition);
57+ }
58+ } else {
59+ Unity2d::PanelApplet::mouseReleaseEvent(event);
60+ }
61+}
62+
63 #include "appnameapplet.moc"
64
65=== modified file 'panel/applets/appname/appnameapplet.h'
66--- panel/applets/appname/appnameapplet.h 2011-08-22 09:17:03 +0000
67+++ panel/applets/appname/appnameapplet.h 2011-09-27 12:02:24 +0000
68@@ -40,10 +40,17 @@
69 protected:
70 void enterEvent(QEvent*);
71 void leaveEvent(QEvent*);
72+ void mouseDoubleClickEvent(QMouseEvent*);
73+ void mousePressEvent(QMouseEvent*);
74+ void mouseReleaseEvent(QMouseEvent*);
75+ void mouseMoveEvent(QMouseEvent*);
76
77 private Q_SLOTS:
78 void updateWidgets();
79
80+Q_SIGNALS:
81+ void titleBarDblClicked();
82+
83 private:
84 Q_DISABLE_COPY(AppNameApplet)
85 AppNameAppletPrivate* const d;
86
87=== modified file 'panel/applets/appname/windowhelper.cpp'
88--- panel/applets/appname/windowhelper.cpp 2011-07-13 12:47:02 +0000
89+++ panel/applets/appname/windowhelper.cpp 2011-09-27 12:02:24 +0000
90@@ -42,6 +42,12 @@
91 #include <QDateTime>
92 #include <QApplication>
93 #include <QDesktopWidget>
94+#include <QPoint>
95+
96+// X11
97+#include <X11/Xlib.h>
98+#include <X11/Xatom.h>
99+#include <QX11Info>
100
101 struct WindowHelperPrivate
102 {
103@@ -157,4 +163,27 @@
104 wnck_window_unmaximize(d->m_window);
105 }
106
107+void WindowHelper::drag(const QPoint& pos)
108+{
109+ // this code IMO should ultimately belong to wnck
110+ if (wnck_window_is_maximized(d->m_window)) {
111+ XEvent xev;
112+ QX11Info info;
113+ Atom netMoveResize = XInternAtom(QX11Info::display(), "_NET_WM_MOVERESIZE", false);
114+ xev.xclient.type = ClientMessage;
115+ xev.xclient.message_type = netMoveResize;
116+ xev.xclient.display = QX11Info::display();
117+ xev.xclient.window = wnck_window_get_xid(d->m_window);
118+ xev.xclient.format = 32;
119+ xev.xclient.data.l[0] = pos.x();
120+ xev.xclient.data.l[1] = pos.y();
121+ xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE
122+ xev.xclient.data.l[3] = Button1;
123+ xev.xclient.data.l[4] = 0;
124+ XUngrabPointer(QX11Info::display(), QX11Info::appTime());
125+ XSendEvent(QX11Info::display(), QX11Info::appRootWindow(info.screen()), false,
126+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
127+ }
128+}
129+
130 #include "windowhelper.moc"
131
132=== modified file 'panel/applets/appname/windowhelper.h'
133--- panel/applets/appname/windowhelper.h 2011-03-30 16:21:18 +0000
134+++ panel/applets/appname/windowhelper.h 2011-09-27 12:02:24 +0000
135@@ -27,6 +27,8 @@
136 // Qt
137 #include <QObject>
138
139+class QPoint;
140+
141 struct WindowHelperPrivate;
142 class WindowHelper : public QObject
143 {
144@@ -44,6 +46,7 @@
145 void close();
146 void minimize();
147 void unmaximize();
148+ void drag(const QPoint& pos);
149
150 private Q_SLOTS:
151 void update();

Subscribers

People subscribed via source and target branches