aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc95
1 files changed, 53 insertions, 42 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