aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-01-07 01:34:49 (GMT)
committerfluxgen <fluxgen>2003-01-07 01:34:49 (GMT)
commit3889975c4fbdf5724b6626930154cd1011c07b7d (patch)
tree5e4f7db9cf06b958ebd4db43a57134152b3e9181
parent06f63eec84fa37e0832fee0432cd398f55f7aeba (diff)
downloadfluxbox-3889975c4fbdf5724b6626930154cd1011c07b7d.zip
fluxbox-3889975c4fbdf5724b6626930154cd1011c07b7d.tar.bz2
fixed Windowmenu to FbTk Menu and added last know button pos and popupMenu function on last known position
-rw-r--r--src/Window.cc95
-rw-r--r--src/Window.hh24
2 files changed, 70 insertions, 49 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 2a26188..d33c460 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.108 2003/01/05 22:22:33 fluxgen Exp $ 25// $Id: Window.cc,v 1.109 2003/01/07 01:34:49 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -30,13 +30,11 @@
30#include "fluxbox.hh" 30#include "fluxbox.hh"
31#include "Iconmenu.hh" 31#include "Iconmenu.hh"
32#include "Screen.hh" 32#include "Screen.hh"
33#include "Toolbar.hh"
34#include "Windowmenu.hh"
35#include "StringUtil.hh" 33#include "StringUtil.hh"
36#include "Netizen.hh" 34#include "Netizen.hh"
37#include "ImageControl.hh" 35#include "ImageControl.hh"
38#include "FbWinFrameTheme.hh" 36#include "FbWinFrameTheme.hh"
39 37#include "MenuTheme.hh"
40 38
41#ifdef HAVE_CONFIG_H 39#ifdef HAVE_CONFIG_H
42#include "config.h" 40#include "config.h"
@@ -99,7 +97,8 @@ void grabButton(Display *display, unsigned int button,
99 97
100}; 98};
101 99
102FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, BImageControl &imgctrl, FbWinFrameTheme &tm): 100FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, BImageControl &imgctrl, FbWinFrameTheme &tm,
101 FbTk::MenuTheme &menutheme):
103 m_hintsig(*this), 102 m_hintsig(*this),
104 m_statesig(*this), 103 m_statesig(*this),
105 m_workspacesig(*this), 104 m_workspacesig(*this),
@@ -111,7 +110,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, BImageControl
111 timer(this), 110 timer(this),
112 display(0), 111 display(0),
113 lastButtonPressTime(0), 112 lastButtonPressTime(0),
114 m_windowmenu(0), 113 m_windowmenu(menutheme, screen_num, imgctrl),
115 m_layer(LAYER_NORMAL), old_decoration(DECOR_NORMAL), 114 m_layer(LAYER_NORMAL), old_decoration(DECOR_NORMAL),
116 tab(0), 115 tab(0),
117 m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100) { 116 m_frame(tm, imgctrl, screen_num, 0, 0, 100, 100) {
@@ -247,10 +246,6 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, BImageControl
247 246
248 positionWindows(); 247 positionWindows();
249 248
250 if (decorations.menu) {
251 m_windowmenu.reset(new Windowmenu(*this));
252 }
253
254 if (workspace_number < 0 || workspace_number >= screen->getCount()) 249 if (workspace_number < 0 || workspace_number >= screen->getCount())
255 screen->getCurrentWorkspace()->addWindow(this, place_window); 250 screen->getCurrentWorkspace()->addWindow(this, place_window);
256 else 251 else
@@ -279,7 +274,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num, BImageControl
279 274
280 // finaly show the frame and the client window 275 // finaly show the frame and the client window
281 m_frame.show(); 276 m_frame.show();
282 277 XSync(display, False);
283} 278}
284 279
285 280
@@ -401,7 +396,7 @@ void FluxboxWindow::grabButtons() {
401 396
402 397
403void FluxboxWindow::reconfigure() { 398void FluxboxWindow::reconfigure() {
404 399
405 upsize(); 400 upsize();
406 401
407 positionWindows(); 402 positionWindows();
@@ -412,11 +407,9 @@ void FluxboxWindow::reconfigure() {
412 407
413 grabButtons(); 408 grabButtons();
414 409
415 if (m_windowmenu.get()) { 410 m_frame.setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval());
416 m_windowmenu->move(m_windowmenu->x(), m_frame.y() + m_frame.titleHeight()); 411
417 m_windowmenu->reconfigure(); 412 m_windowmenu.reconfigure();
418 }
419
420 413
421} 414}
422 415
@@ -926,8 +919,7 @@ void FluxboxWindow::iconify() {
926 if (iconic) // no need to iconify if we're already 919 if (iconic) // no need to iconify if we're already
927 return; 920 return;
928 921
929 if (m_windowmenu.get()) 922 m_windowmenu.hide();
930 m_windowmenu->hide();
931 923
932 setState(IconicState); 924 setState(IconicState);
933 925
@@ -1040,8 +1032,7 @@ void FluxboxWindow::withdraw() {
1040 1032
1041 m_frame.hide(); 1033 m_frame.hide();
1042 1034
1043 if (m_windowmenu.get()) 1035 m_windowmenu.hide();
1044 m_windowmenu->hide();
1045 1036
1046 if (tab) 1037 if (tab)
1047 tab->withdraw(); 1038 tab->withdraw();
@@ -1422,15 +1413,28 @@ void FluxboxWindow::restoreAttributes() {
1422 Show the window menu at pos mx, my 1413 Show the window menu at pos mx, my
1423*/ 1414*/
1424void FluxboxWindow::showMenu(int mx, int my) { 1415void FluxboxWindow::showMenu(int mx, int my) {
1425 if (m_windowmenu.get() == 0) 1416 m_windowmenu.move(mx, my);
1417 m_windowmenu.show();
1418 m_windowmenu.raise();
1419 // m_windowmenu.getSendToMenu().raise();
1420 // m_windowmenu.getSendGroupToMenu().raise();
1421}
1422
1423/**
1424 Moves the menu to last button press position and shows it,
1425 if it's already visible it'll be hidden
1426 */
1427void FluxboxWindow::popupMenu() {
1428 if (m_windowmenu.isVisible()) {
1429 m_windowmenu.hide();
1426 return; 1430 return;
1427 m_windowmenu->move(mx, my); 1431 }
1428 m_windowmenu->show(); 1432
1429 m_windowmenu->raise(); 1433 m_windowmenu.move(m_last_button_x, m_frame.y() + m_frame.titlebar().height() + m_frame.titlebar().borderWidth()*2);
1430 m_windowmenu->getSendToMenu().raise(); 1434 m_windowmenu.show();
1431 m_windowmenu->getSendGroupToMenu().raise(); 1435 m_windowmenu.raise();
1432} 1436}
1433 1437
1434void FluxboxWindow::restoreGravity() { 1438void FluxboxWindow::restoreGravity() {
1435 // restore x coordinate 1439 // restore x coordinate
1436 switch (client.win_gravity) { 1440 switch (client.win_gravity) {
@@ -1779,6 +1783,11 @@ void FluxboxWindow::configureRequestEvent(XConfigureRequestEvent &cr) {
1779 1783
1780 1784
1781void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { 1785void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
1786 m_last_button_x = be.x_root;
1787 m_last_button_y = be.y_root;
1788
1789 // check frame events first
1790 m_frame.buttonPressEvent(be);
1782 1791
1783 if (be.button == 1 || (be.button == 3 && be.state == Mod1Mask)) { 1792 if (be.button == 1 || (be.button == 3 && be.state == Mod1Mask)) {
1784 if ((! focused) && (! screen->isSloppyFocus())) { //check focus 1793 if ((! focused) && (! screen->isSloppyFocus())) { //check focus
@@ -1787,30 +1796,29 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) {
1787 1796
1788 if (m_frame.clientArea() == be.window) { 1797 if (m_frame.clientArea() == be.window) {
1789 1798
1790 if (m_windowmenu.get() && m_windowmenu->isVisible()) //hide menu if its visible 1799 if (m_windowmenu.isVisible()) //hide menu if its visible
1791 m_windowmenu->hide(); 1800 m_windowmenu.hide();
1792 1801
1793 raise(); 1802 raise();
1794 1803
1795 XAllowEvents(display, ReplayPointer, be.time); 1804 XAllowEvents(display, ReplayPointer, be.time);
1796 1805
1797 } else { 1806 } else {
1798 1807
1799 button_grab_x = be.x_root - m_frame.x() - screen->getBorderWidth(); 1808 button_grab_x = be.x_root - m_frame.x() - screen->getBorderWidth();
1800 button_grab_y = be.y_root - m_frame.y() - screen->getBorderWidth(); 1809 button_grab_y = be.y_root - m_frame.y() - screen->getBorderWidth();
1801 1810 if (m_windowmenu.isVisible())
1802 if (m_windowmenu.get() && m_windowmenu->isVisible()) 1811 m_windowmenu.hide();
1803 m_windowmenu->hide();
1804
1805 raise();
1806 } 1812 }
1807 } else if (be.button == 2 && be.window == m_frame.label()) {
1808 lower();
1809 } 1813 }
1814
1810} 1815}
1811 1816
1817void FluxboxWindow::shapeEvent(XShapeEvent *) { }
1812 1818
1813void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { 1819void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
1820 m_frame.buttonReleaseEvent(re); // let the frame handle the event first
1821
1814 if (isMoving()) 1822 if (isMoving())
1815 stopMoving(); 1823 stopMoving();
1816 else if (isResizing()) 1824 else if (isResizing())
@@ -1819,6 +1827,8 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) {
1819 if (re.button == 2 && re.state == Mod1Mask) 1827 if (re.button == 2 && re.state == Mod1Mask)
1820 XUngrabPointer(display, CurrentTime); 1828 XUngrabPointer(display, CurrentTime);
1821 } 1829 }
1830
1831
1822} 1832}
1823 1833
1824 1834
@@ -1948,7 +1958,7 @@ void FluxboxWindow::setDecoration(Decoration decoration) {
1948 // functions.iconify = functions.maximize = true; 1958 // functions.iconify = functions.maximize = true;
1949 // functions.move = true; // We need to move even without decor 1959 // functions.move = true; // We need to move even without decor
1950 // functions.resize = true; // We need to resize even without decor 1960 // functions.resize = true; // We need to resize even without decor
1951 1961 frame().hideAllDecorations();
1952 break; 1962 break;
1953 1963
1954 default: 1964 default:
@@ -1958,8 +1968,9 @@ void FluxboxWindow::setDecoration(Decoration decoration) {
1958 decorations.menu = true; 1968 decorations.menu = true;
1959 functions.resize = functions.move = functions.iconify = 1969 functions.resize = functions.move = functions.iconify =
1960 functions.maximize = true; 1970 functions.maximize = true;
1971 m_frame.showAllDecorations();
1961 m_frame.show(); 1972 m_frame.show();
1962 1973
1963 break; 1974 break;
1964 1975
1965 case DECOR_TINY: 1976 case DECOR_TINY:
@@ -2022,8 +2033,8 @@ void FluxboxWindow::startMoving(Window win) {
2022 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 2033 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
2023 None, fluxbox->getMoveCursor(), CurrentTime); 2034 None, fluxbox->getMoveCursor(), CurrentTime);
2024 2035
2025 if (m_windowmenu.get() && m_windowmenu->isVisible()) 2036 if (m_windowmenu.isVisible())
2026 m_windowmenu->hide(); 2037 m_windowmenu.hide();
2027 2038
2028 fluxbox->maskWindowEvents(client.window, this); 2039 fluxbox->maskWindowEvents(client.window, this);
2029 /* TODO: opaque moving 2040 /* TODO: opaque moving
diff --git a/src/Window.hh b/src/Window.hh
index 65cc2e6..65a02ce 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -22,14 +22,14 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.hh,v 1.40 2003/01/05 22:20:46 fluxgen Exp $ 25// $Id: Window.hh,v 1.41 2003/01/07 01:33:18 fluxgen Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
29 29
30#include "BaseDisplay.hh" 30#include "BaseDisplay.hh"
31#include "Timer.hh" 31#include "Timer.hh"
32#include "Windowmenu.hh" 32#include "Menu.hh"
33#include "Subject.hh" 33#include "Subject.hh"
34#include "FbWinFrame.hh" 34#include "FbWinFrame.hh"
35#include "EventHandler.hh" 35#include "EventHandler.hh"
@@ -49,7 +49,11 @@
49 49
50class Tab; 50class Tab;
51class FbWinFrameTheme; 51class FbWinFrameTheme;
52class BScreen;
52 53
54namespace FbTk {
55class MenuTheme;
56};
53 57
54/// Creates the window frame and handles any window event for it 58/// Creates the window frame and handles any window event for it
55class FluxboxWindow : public TimeoutHandler, public FbTk::EventHandler { 59class FluxboxWindow : public TimeoutHandler, public FbTk::EventHandler {
@@ -98,7 +102,8 @@ public:
98 }; 102 };
99 103
100 /// create fluxbox window with parent win and screen connection 104 /// create fluxbox window with parent win and screen connection
101 FluxboxWindow(Window win, BScreen *scr, int screen_num, BImageControl &imgctrl, FbWinFrameTheme &tm); 105 FluxboxWindow(Window win, BScreen *scr, int screen_num, BImageControl &imgctrl, FbWinFrameTheme &tm,
106 FbTk::MenuTheme &menutheme);
102 virtual ~FluxboxWindow(); 107 virtual ~FluxboxWindow();
103 108
104 109
@@ -140,7 +145,10 @@ public:
140 void setWorkspace(int n); 145 void setWorkspace(int n);
141 void changeBlackboxHints(const BaseDisplay::BlackboxHints &bh); 146 void changeBlackboxHints(const BaseDisplay::BlackboxHints &bh);
142 void restoreAttributes(); 147 void restoreAttributes();
143 void showMenu(int mx, int my); 148 void showMenu(int mx, int my);
149 // popup menu on last button press position
150 void popupMenu();
151
144 void pauseMoving(); 152 void pauseMoving();
145 void resumeMoving(); 153 void resumeMoving();
146 /** 154 /**
@@ -207,8 +215,8 @@ public:
207 Window getFrameWindow() const { return m_frame.window().window(); } 215 Window getFrameWindow() const { return m_frame.window().window(); }
208 Window getClientWindow() const { return client.window; } 216 Window getClientWindow() const { return client.window; }
209 217
210 Windowmenu *getWindowmenu() { return m_windowmenu.get(); } 218 FbTk::Menu &getWindowmenu() { return m_windowmenu; }
211 const Windowmenu *getWindowmenu() const { return m_windowmenu.get(); } 219 const FbTk::Menu &getWindowmenu() const { return m_windowmenu; }
212 220
213 const std::string &getTitle() const { return client.title; } 221 const std::string &getTitle() const { return client.title; }
214 const std::string &getIconTitle() const { return client.icon_title; } 222 const std::string &getIconTitle() const { return client.icon_title; }
@@ -320,7 +328,7 @@ private:
320 BaseDisplay::BlackboxAttributes blackbox_attrib; 328 BaseDisplay::BlackboxAttributes blackbox_attrib;
321 329
322 Time lastButtonPressTime; 330 Time lastButtonPressTime;
323 std::auto_ptr<Windowmenu> m_windowmenu; 331 FbTk::Menu m_windowmenu;
324 332
325 timeval lastFocusTime; 333 timeval lastFocusTime;
326 334
@@ -370,6 +378,8 @@ private:
370 int frame_resize_y, frame_resize_h; 378 int frame_resize_y, frame_resize_h;
371 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized 379 int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized
372 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state 380 unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state
381 int m_last_button_x, ///< last known x position of the mouse button
382 m_last_button_y; ///< last known y position of the mouse button
373 FbWinFrame m_frame; 383 FbWinFrame m_frame;
374 384
375 enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE }; 385 enum { F_NOINPUT = 0, F_PASSIVE, F_LOCALLYACTIVE, F_GLOBALLYACTIVE };