summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-10-19 10:56:30 (GMT)
committerfluxgen <fluxgen>2002-10-19 10:56:30 (GMT)
commit5b62ce19cb80e01bb04e0c3de80f94a600386118 (patch)
treebff4778ecc9b5927a9310bca053c8ace90157cc7 /src
parent834576a531616f6f39ad0b9d6937492916395044 (diff)
downloadfluxbox_lack-5b62ce19cb80e01bb04e0c3de80f94a600386118.zip
fluxbox_lack-5b62ce19cb80e01bb04e0c3de80f94a600386118.tar.bz2
auto_ptr for windowmenu
Diffstat (limited to 'src')
-rw-r--r--src/Window.cc87
-rw-r--r--src/Window.hh10
2 files changed, 49 insertions, 48 deletions
diff --git a/src/Window.cc b/src/Window.cc
index f4b69ee..68494e2 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.90 2002/10/15 17:37:28 fluxgen Exp $ 25// $Id: Window.cc,v 1.91 2002/10/19 10:56:30 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -68,7 +68,7 @@ screen(0),
68timer(this), 68timer(this),
69display(0), 69display(0),
70lastButtonPressTime(0), 70lastButtonPressTime(0),
71windowmenu(0), 71m_windowmenu(0),
72m_layer(LAYER_NORMAL), 72m_layer(LAYER_NORMAL),
73tab(0) { 73tab(0) {
74 74
@@ -300,7 +300,7 @@ tab(0) {
300 XMapSubwindows(display, frame.window); 300 XMapSubwindows(display, frame.window);
301 301
302 if (decorations.menu) 302 if (decorations.menu)
303 windowmenu = new Windowmenu(*this); 303 m_windowmenu = std::auto_ptr<Windowmenu>(new Windowmenu(*this));
304 304
305 if (workspace_number < 0 || workspace_number >= screen->getCount()) 305 if (workspace_number < 0 || workspace_number >= screen->getCount())
306 screen->getCurrentWorkspace()->addWindow(this, place_window); 306 screen->getCurrentWorkspace()->addWindow(this, place_window);
@@ -355,11 +355,6 @@ FluxboxWindow::~FluxboxWindow() {
355 } else //it's iconic 355 } else //it's iconic
356 screen->removeIcon(this); 356 screen->removeIcon(this);
357 357
358 if (windowmenu) {
359 delete windowmenu;
360 windowmenu = 0;
361 }
362
363 if (tab != 0) { 358 if (tab != 0) {
364 delete tab; 359 delete tab;
365 tab = 0; 360 tab = 0;
@@ -1031,9 +1026,9 @@ void FluxboxWindow::reconfigure() {
1031 1026
1032 grabButtons(); 1027 grabButtons();
1033 1028
1034 if (windowmenu) { 1029 if (m_windowmenu.get()) {
1035 windowmenu->move(windowmenu->x(), frame.y + frame.title_h); 1030 m_windowmenu->move(m_windowmenu->x(), frame.y + frame.title_h);
1036 windowmenu->reconfigure(); 1031 m_windowmenu->reconfigure();
1037 } 1032 }
1038 1033
1039 1034
@@ -1296,8 +1291,8 @@ void FluxboxWindow::getMWMHints() {
1296 } else { 1291 } else {
1297 decorations.titlebar = decorations.handle = decorations.border = 1292 decorations.titlebar = decorations.handle = decorations.border =
1298 decorations.iconify = decorations.maximize = 1293 decorations.iconify = decorations.maximize =
1299 decorations.close = decorations.menu = decorations.tab = false; 1294 decorations.close = decorations.tab = false;
1300 1295 decorations.menu = true;
1301 if (client.mwm_hint->decorations & MwmDecorBorder) 1296 if (client.mwm_hint->decorations & MwmDecorBorder)
1302 decorations.border = true; 1297 decorations.border = true;
1303 if (client.mwm_hint->decorations & MwmDecorHandle) 1298 if (client.mwm_hint->decorations & MwmDecorHandle)
@@ -1570,8 +1565,8 @@ void FluxboxWindow::iconify() {
1570 if (iconic) 1565 if (iconic)
1571 return; 1566 return;
1572 1567
1573 if (windowmenu) 1568 if (m_windowmenu.get())
1574 windowmenu->hide(); 1569 m_windowmenu->hide();
1575 1570
1576 setState(IconicState); 1571 setState(IconicState);
1577 1572
@@ -1681,8 +1676,8 @@ void FluxboxWindow::withdraw() {
1681 XSelectInput(display, client.window, 1676 XSelectInput(display, client.window,
1682 PropertyChangeMask | StructureNotifyMask | FocusChangeMask); 1677 PropertyChangeMask | StructureNotifyMask | FocusChangeMask);
1683 1678
1684 if (windowmenu) 1679 if (m_windowmenu.get())
1685 windowmenu->hide(); 1680 m_windowmenu->hide();
1686 1681
1687 if (tab) 1682 if (tab)
1688 tab->withdraw(); 1683 tab->withdraw();
@@ -2358,11 +2353,13 @@ void FluxboxWindow::restoreAttributes() {
2358} 2353}
2359 2354
2360void FluxboxWindow::showMenu(int mx, int my) { 2355void FluxboxWindow::showMenu(int mx, int my) {
2361 windowmenu->move(mx, my); 2356 if (m_windowmenu.get() == 0)
2362 windowmenu->show(); 2357 return;
2363 windowmenu->raise(); 2358 m_windowmenu->move(mx, my);
2364 windowmenu->getSendToMenu().raise(); 2359 m_windowmenu->show();
2365 windowmenu->getSendGroupToMenu().raise(); 2360 m_windowmenu->raise();
2361 m_windowmenu->getSendToMenu().raise();
2362 m_windowmenu->getSendGroupToMenu().raise();
2366} 2363}
2367 2364
2368void FluxboxWindow::restoreGravity() { 2365void FluxboxWindow::restoreGravity() {
@@ -2699,8 +2696,8 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2699 2696
2700 if (decorations.titlebar) 2697 if (decorations.titlebar)
2701 positionButtons(true); 2698 positionButtons(true);
2702 if (windowmenu) 2699 if (m_windowmenu.get())
2703 windowmenu->reconfigure(); 2700 m_windowmenu->reconfigure();
2704 } 2701 }
2705 } else { 2702 } else {
2706 2703
@@ -2808,8 +2805,8 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
2808 2805
2809 if (frame.plate == be->window) { 2806 if (frame.plate == be->window) {
2810 2807
2811 if (windowmenu && windowmenu->isVisible()) //hide menu if its visible 2808 if (m_windowmenu.get() && m_windowmenu->isVisible()) //hide menu if its visible
2812 windowmenu->hide(); 2809 m_windowmenu->hide();
2813 //raise tab first, if there is any, so the focus on windows get 2810 //raise tab first, if there is any, so the focus on windows get
2814 //right and dont "hide" the tab behind other windows 2811 //right and dont "hide" the tab behind other windows
2815 if (tab) 2812 if (tab)
@@ -2837,8 +2834,8 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
2837 frame.grab_x = be->x_root - frame.x - screen->getBorderWidth(); 2834 frame.grab_x = be->x_root - frame.x - screen->getBorderWidth();
2838 frame.grab_y = be->y_root - frame.y - screen->getBorderWidth(); 2835 frame.grab_y = be->y_root - frame.y - screen->getBorderWidth();
2839 2836
2840 if (windowmenu && windowmenu->isVisible()) 2837 if (m_windowmenu.get() && m_windowmenu->isVisible())
2841 windowmenu->hide(); 2838 m_windowmenu->hide();
2842 //raise tab first if there is any 2839 //raise tab first if there is any
2843 if (hasTab()) 2840 if (hasTab())
2844 tab->raise(); 2841 tab->raise();
@@ -2850,47 +2847,47 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent *be) {
2850 if (hasTab()) 2847 if (hasTab())
2851 getTab()->lower(); //lower the tab AND it's windows 2848 getTab()->lower(); //lower the tab AND it's windows
2852 2849
2853 } else if (windowmenu && be->button == 3 && 2850 } else if (m_windowmenu.get() && be->button == 3 &&
2854 (frame.title == be->window || frame.label == be->window || 2851 (frame.title == be->window || frame.label == be->window ||
2855 frame.handle == be->window)) { 2852 frame.handle == be->window)) {
2856 2853
2857 int mx = 0, my = 0; 2854 int mx = 0, my = 0;
2858 2855
2859 if (frame.title == be->window || frame.label == be->window) { 2856 if (frame.title == be->window || frame.label == be->window) {
2860 mx = be->x_root - (windowmenu->width() / 2); 2857 mx = be->x_root - (m_windowmenu->width() / 2);
2861 my = frame.y + frame.title_h; 2858 my = frame.y + frame.title_h;
2862 } else if (frame.handle == be->window) { 2859 } else if (frame.handle == be->window) {
2863 mx = be->x_root - (windowmenu->width() / 2); 2860 mx = be->x_root - (m_windowmenu->width() / 2);
2864 my = frame.y + frame.y_handle - windowmenu->height(); 2861 my = frame.y + frame.y_handle - m_windowmenu->height();
2865 } else { 2862 } else {
2866 bool buttonproc=false; 2863 bool buttonproc=false;
2867 2864
2868 if (buttonproc) 2865 if (buttonproc)
2869 mx = be->x_root - (windowmenu->width() / 2); 2866 mx = be->x_root - (m_windowmenu->width() / 2);
2870 2867
2871 if (be->y <= (signed) frame.bevel_w) 2868 if (be->y <= (signed) frame.bevel_w)
2872 my = frame.y + frame.y_border; 2869 my = frame.y + frame.y_border;
2873 else 2870 else
2874 my = be->y_root - (windowmenu->height() / 2); 2871 my = be->y_root - (m_windowmenu->height() / 2);
2875 } 2872 }
2876 2873
2877 if (mx > (signed) (frame.x + frame.width - windowmenu->width())) 2874 if (mx > (signed) (frame.x + frame.width - m_windowmenu->width()))
2878 mx = frame.x + frame.width - windowmenu->width(); 2875 mx = frame.x + frame.width - m_windowmenu->width();
2879 if (mx < frame.x) 2876 if (mx < frame.x)
2880 mx = frame.x; 2877 mx = frame.x;
2881 2878
2882 if (my > (signed) (frame.y + frame.y_handle - windowmenu->height())) 2879 if (my > (signed) (frame.y + frame.y_handle - m_windowmenu->height()))
2883 my = frame.y + frame.y_handle - windowmenu->height(); 2880 my = frame.y + frame.y_handle - m_windowmenu->height();
2884 if (my < (signed) (frame.y + ((decorations.titlebar) ? frame.title_h : 2881 if (my < (signed) (frame.y + ((decorations.titlebar) ? frame.title_h :
2885 frame.y_border))) 2882 frame.y_border)))
2886 my = frame.y + 2883 my = frame.y +
2887 ((decorations.titlebar) ? frame.title_h : frame.y_border); 2884 ((decorations.titlebar) ? frame.title_h : frame.y_border);
2888 2885
2889 if (windowmenu) { 2886 if (m_windowmenu.get()) {
2890 if (! windowmenu->isVisible()) { // if not window menu is visible then show it 2887 if (! m_windowmenu->isVisible()) { // if not window menu is visible then show it
2891 showMenu(mx, my); 2888 showMenu(mx, my);
2892 } else //else hide menu 2889 } else //else hide menu
2893 windowmenu->hide(); 2890 m_windowmenu->hide();
2894 } 2891 }
2895 2892
2896 } else if (be->button == 4) { //scroll to tab right 2893 } else if (be->button == 4) { //scroll to tab right
@@ -3124,10 +3121,12 @@ void FluxboxWindow::setDecoration(Decoration decoration) {
3124 case DECOR_NONE: 3121 case DECOR_NONE:
3125 decorations.titlebar = decorations.border = decorations.handle = 3122 decorations.titlebar = decorations.border = decorations.handle =
3126 decorations.iconify = decorations.maximize = 3123 decorations.iconify = decorations.maximize =
3127 decorations.menu = decorations.tab = false; //tab is also a decor 3124 decorations.tab = false; //tab is also a decor
3125 decorations.menu = true; // menu is present
3128 functions.iconify = functions.maximize = false; 3126 functions.iconify = functions.maximize = false;
3129 functions.move = true; // We need to move even without decor 3127 functions.move = true; // We need to move even without decor
3130 functions.resize = true; // We need to resize even without decor 3128 functions.resize = true; // We need to resize even without decor
3129
3131 break; 3130 break;
3132 3131
3133 default: 3132 default:
@@ -3201,8 +3200,8 @@ void FluxboxWindow::startMoving(Window win) {
3201 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 3200 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
3202 None, fluxbox->getMoveCursor(), CurrentTime); 3201 None, fluxbox->getMoveCursor(), CurrentTime);
3203 3202
3204 if (windowmenu && windowmenu->isVisible()) 3203 if (m_windowmenu.get() && m_windowmenu->isVisible())
3205 windowmenu->hide(); 3204 m_windowmenu->hide();
3206 3205
3207 fluxbox->maskWindowEvents(client.window, this); 3206 fluxbox->maskWindowEvents(client.window, this);
3208 3207
diff --git a/src/Window.hh b/src/Window.hh
index 2edb294..68281f8 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -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.hh,v 1.33 2002/10/11 10:18:43 fluxgen Exp $ 25// $Id: Window.hh,v 1.34 2002/10/19 10:53:10 fluxgen Exp $
26 26
27#ifndef WINDOW_HH 27#ifndef WINDOW_HH
28#define WINDOW_HH 28#define WINDOW_HH
@@ -41,6 +41,7 @@
41 41
42#include <vector> 42#include <vector>
43#include <string> 43#include <string>
44#include <memory>
44 45
45#define PropMwmHintsElements 3 46#define PropMwmHintsElements 3
46 47
@@ -123,8 +124,9 @@ public:
123 const Window &getFrameWindow() const { return frame.window; } 124 const Window &getFrameWindow() const { return frame.window; }
124 const Window &getClientWindow() const { return client.window; } 125 const Window &getClientWindow() const { return client.window; }
125 126
126 Windowmenu *getWindowmenu() { return windowmenu; } 127 Windowmenu *getWindowmenu() { return m_windowmenu.get(); }
127 128 const Windowmenu *getWindowmenu() const { return m_windowmenu.get(); }
129
128 const std::string &getTitle() const { return client.title; } 130 const std::string &getTitle() const { return client.title; }
129 const std::string &getIconTitle() const { return client.icon_title; } 131 const std::string &getIconTitle() const { return client.icon_title; }
130 int getXFrame() const { return frame.x; } 132 int getXFrame() const { return frame.x; }
@@ -245,7 +247,7 @@ private:
245 BaseDisplay::BlackboxAttributes blackbox_attrib; 247 BaseDisplay::BlackboxAttributes blackbox_attrib;
246 248
247 Time lastButtonPressTime; 249 Time lastButtonPressTime;
248 Windowmenu *windowmenu; 250 std::auto_ptr<Windowmenu> m_windowmenu;
249 251
250 timeval lastFocusTime; 252 timeval lastFocusTime;
251 253