aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-12-03 23:35:38 (GMT)
committerfluxgen <fluxgen>2002-12-03 23:35:38 (GMT)
commitec1947ccc1555b7cdf2335dec7f64c238422f77a (patch)
tree9ed25cc1f06990ac278e57edf819d6a1d4dcdc1e
parentfa1d775e099f752328b0dfd5da824986abdec85b (diff)
downloadfluxbox_pavel-ec1947ccc1555b7cdf2335dec7f64c238422f77a.zip
fluxbox_pavel-ec1947ccc1555b7cdf2335dec7f64c238422f77a.tar.bz2
using FbTk EventHandler and FbTk FbWindow. Fixed indenting and other minor cleaning
-rw-r--r--src/Basemenu.cc368
1 files changed, 181 insertions, 187 deletions
diff --git a/src/Basemenu.cc b/src/Basemenu.cc
index 384287f..8d9d181 100644
--- a/src/Basemenu.cc
+++ b/src/Basemenu.cc
@@ -22,15 +22,15 @@
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: Basemenu.cc,v 1.39 2002/12/01 13:41:54 rathnor Exp $ 25// $Id: Basemenu.cc,v 1.40 2002/12/03 23:35:38 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
29#define _GNU_SOURCE 29#define _GNU_SOURCE
30#endif // _GNU_SOURCE 30#endif // _GNU_SOURCE
31 31
32#ifdef HAVE_CONFIG_H 32#ifdef HAVE_CONFIG_H
33# include "../config.h" 33#include "../config.h"
34#endif // HAVE_CONFIG_H 34#endif // HAVE_CONFIG_H
35 35
36#include "i18n.hh" 36#include "i18n.hh"
@@ -39,6 +39,8 @@
39#include "Screen.hh" 39#include "Screen.hh"
40#include "ImageControl.hh" 40#include "ImageControl.hh"
41#include "StringUtil.hh" 41#include "StringUtil.hh"
42#include "FbWindow.hh"
43#include "EventManager.hh"
42 44
43#include <cstdio> 45#include <cstdio>
44#include <cstdlib> 46#include <cstdlib>
@@ -109,15 +111,14 @@ Basemenu::Basemenu(BScreen *screen):
109 attrib.override_redirect = True; 111 attrib.override_redirect = True;
110 attrib.event_mask = ButtonPressMask | ButtonReleaseMask | 112 attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
111 ButtonMotionMask | ExposureMask; 113 ButtonMotionMask | ExposureMask;
112 114
113 //create menu window 115 //create menu window
114 menu.window = 116 menu.window = XCreateWindow(m_display, m_screen->getRootWindow(), menu.x, menu.y, menu.width,
115 XCreateWindow(m_display, m_screen->getRootWindow(), menu.x, menu.y, menu.width,
116 menu.height, m_screen->getBorderWidth(), m_screen->getDepth(), 117 menu.height, m_screen->getBorderWidth(), m_screen->getDepth(),
117 InputOutput, m_screen->getVisual(), attrib_mask, &attrib); 118 InputOutput, m_screen->getVisual(), attrib_mask, &attrib);
118 119
119 Fluxbox * const fluxbox = Fluxbox::instance(); 120 FbTk::EventManager &evm = *FbTk::EventManager::instance();
120 fluxbox->saveMenuSearch(menu.window, this); 121 evm.add(*this, menu.window);
121 122
122 //attibutes for title to menuwindow 123 //attibutes for title to menuwindow
123 attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask; 124 attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask;
@@ -125,25 +126,24 @@ Basemenu::Basemenu(BScreen *screen):
125 attrib.event_mask |= EnterWindowMask | LeaveWindowMask; 126 attrib.event_mask |= EnterWindowMask | LeaveWindowMask;
126 //create menu title 127 //create menu title
127 menu.title = 128 menu.title =
128 XCreateWindow(m_display, menu.window, 0, 0, menu.width, menu.height, 0, 129 XCreateWindow(m_display, menu.window.window(), 0, 0, menu.width, menu.height, 0,
129 m_screen->getDepth(), InputOutput, m_screen->getVisual(), 130 m_screen->getDepth(), InputOutput, m_screen->getVisual(),
130 attrib_mask, &attrib); 131 attrib_mask, &attrib);
131 fluxbox->saveMenuSearch(menu.title, this); 132 evm.add(*this, menu.title);
132 133
133 attrib.event_mask |= PointerMotionMask; 134 attrib.event_mask |= PointerMotionMask;
134 menu.frame = XCreateWindow(m_display, menu.window, 0, 135 menu.frame = XCreateWindow(m_display, menu.window.window(), 0,
135 menu.title_h + m_screen->getBorderWidth(), 136 menu.title_h + m_screen->getBorderWidth(),
136 menu.width, menu.frame_h, 0, 137 menu.width, menu.frame_h, 0,
137 m_screen->getDepth(), InputOutput, 138 m_screen->getDepth(), InputOutput,
138 m_screen->getVisual(), attrib_mask, &attrib); 139 m_screen->getVisual(), attrib_mask, &attrib);
139 fluxbox->saveMenuSearch(menu.frame, this); 140 evm.add(*this, menu.frame);
140
141} 141}
142 142
143 143
144Basemenu::~Basemenu() { 144Basemenu::~Basemenu() {
145 XUnmapWindow(m_display, menu.window); 145 menu.window.hide();
146 146
147 if (shown && shown->windowID() == windowID()) 147 if (shown && shown->windowID() == windowID())
148 shown = (Basemenu *) 0; 148 shown = (Basemenu *) 0;
149 149
@@ -164,16 +164,11 @@ Basemenu::~Basemenu() {
164 if (menu.sel_pixmap) 164 if (menu.sel_pixmap)
165 m_image_ctrl->removeImage(menu.sel_pixmap); 165 m_image_ctrl->removeImage(menu.sel_pixmap);
166 166
167 Fluxbox * fluxbox = Fluxbox::instance(); 167 FbTk::EventManager &evm = *FbTk::EventManager::instance();
168 168 evm.remove(menu.title);
169 fluxbox->removeMenuSearch(menu.title); 169 evm.remove(menu.frame);
170 XDestroyWindow(m_display, menu.title); 170 evm.remove(menu.window);
171 171
172 fluxbox->removeMenuSearch(menu.frame);
173 XDestroyWindow(m_display, menu.frame);
174
175 fluxbox->removeMenuSearch(menu.window);
176 XDestroyWindow(m_display, menu.window);
177} 172}
178 173
179 174
@@ -238,11 +233,11 @@ int Basemenu::remove(unsigned int index) {
238} 233}
239 234
240void Basemenu::raise() { 235void Basemenu::raise() {
241 XRaiseWindow(BaseDisplay::getXDisplay(), windowID()); 236 menu.window.raise();
242} 237}
243 238
244void Basemenu::lower() { 239void Basemenu::lower() {
245 XLowerWindow(BaseDisplay::getXDisplay(), windowID()); 240 menu.window.lower();
246} 241}
247 242
248void Basemenu::update() { 243void Basemenu::update() {
@@ -254,8 +249,8 @@ void Basemenu::update() {
254 if (title_vis) { 249 if (title_vis) {
255 const char *s = (menu.label!="") ? menu.label.c_str() : 250 const char *s = (menu.label!="") ? menu.label.c_str() :
256 i18n->getMessage( 251 i18n->getMessage(
257 FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, 252 FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu,
258 "fluxbox Menu"); 253 "fluxbox Menu");
259 int l = strlen(s); 254 int l = strlen(s);
260 255
261 menu.item_w = m_screen->getMenuStyle()->titlefont.textWidth(s, l); 256 menu.item_w = m_screen->getMenuStyle()->titlefont.textWidth(s, l);
@@ -313,28 +308,28 @@ void Basemenu::update() {
313 const FbTk::Texture &tex = m_screen->getMenuStyle()->title; 308 const FbTk::Texture &tex = m_screen->getMenuStyle()->title;
314 if (tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { 309 if (tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
315 menu.title_pixmap = None; 310 menu.title_pixmap = None;
316 XSetWindowBackground(m_display, menu.title, tex.color().pixel()); 311 menu.title.setBackgroundColor(tex.color());
317 } else { 312 } else {
318 menu.title_pixmap = 313 menu.title_pixmap =
319 m_image_ctrl->renderImage(menu.width, menu.title_h, tex); 314 m_image_ctrl->renderImage(menu.width, menu.title_h, tex);
320 XSetWindowBackgroundPixmap(m_display, menu.title, menu.title_pixmap); 315 menu.title.setBackgroundPixmap(menu.title_pixmap);
321 } 316 }
322 317
323 if (tmp) 318 if (tmp)
324 m_image_ctrl->removeImage(tmp); 319 m_image_ctrl->removeImage(tmp);
325 320
326 XClearWindow(m_display, menu.title); 321 menu.title.clear();
327 } 322 }
328 323
329 tmp = menu.frame_pixmap; 324 tmp = menu.frame_pixmap;
330 const FbTk::Texture &frame_tex = m_screen->getMenuStyle()->frame; 325 const FbTk::Texture &frame_tex = m_screen->getMenuStyle()->frame;
331 if (frame_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { 326 if (frame_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) {
332 menu.frame_pixmap = None; 327 menu.frame_pixmap = None;
333 XSetWindowBackground(m_display, menu.frame, frame_tex.color().pixel()); 328 menu.frame.setBackgroundColor(frame_tex.color());
334 } else { 329 } else {
335 menu.frame_pixmap = 330 menu.frame_pixmap =
336 m_image_ctrl->renderImage(menu.width, menu.frame_h, frame_tex); 331 m_image_ctrl->renderImage(menu.width, menu.frame_h, frame_tex);
337 XSetWindowBackgroundPixmap(m_display, menu.frame, menu.frame_pixmap); 332 menu.frame.setBackgroundPixmap(menu.frame_pixmap);
338 } 333 }
339 334
340 if (tmp) 335 if (tmp)
@@ -361,21 +356,21 @@ void Basemenu::update() {
361 if (tmp) 356 if (tmp)
362 m_image_ctrl->removeImage(tmp); 357 m_image_ctrl->removeImage(tmp);
363 358
364 XResizeWindow(m_display, menu.window, menu.width, menu.height); 359 menu.window.resize(menu.width, menu.height);
365 360
366 if (title_vis) 361 if (title_vis)
367 XResizeWindow(m_display, menu.title, menu.width, menu.title_h); 362 menu.title.resize(menu.width, menu.title_h);
368 363
369 XMoveResizeWindow(m_display, menu.frame, 0, 364 menu.frame.moveResize(0,
370 ((title_vis) ? menu.title_h + 365 ((title_vis) ? menu.title_h +
371 m_screen->getBorderWidth() : 0), menu.width, 366 m_screen->getBorderWidth() : 0), menu.width,
372 menu.frame_h); 367 menu.frame_h);
368 menu.window.clear();
369 menu.title.clear();
370 menu.frame.clear();
373 371
374 XClearWindow(m_display, menu.window); 372 if (title_vis && visible)
375 XClearWindow(m_display, menu.title); 373 redrawTitle();
376 XClearWindow(m_display, menu.frame);
377
378 if (title_vis && visible) redrawTitle();
379 374
380 unsigned int i = 0; 375 unsigned int i = 0;
381 for (i = 0; visible && i < menuitems.size(); i++) { 376 for (i = 0; visible && i < menuitems.size(); i++) {
@@ -383,19 +378,19 @@ void Basemenu::update() {
383 drawItem(i, True, 0); 378 drawItem(i, True, 0);
384 drawSubmenu(i); 379 drawSubmenu(i);
385 } else 380 } else
386 drawItem(i, False, 0); 381 drawItem(i, false, 0);
387 } 382 }
388 383
389 if (m_parent && visible) 384 if (m_parent && visible)
390 m_parent->drawSubmenu(m_parent->which_sub); 385 m_parent->drawSubmenu(m_parent->which_sub);
391 386
392 XMapSubwindows(m_display, menu.window); 387 XMapSubwindows(m_display, menu.window.window());
393} 388}
394 389
395 390
396void Basemenu::show() { 391void Basemenu::show() {
397 XMapSubwindows(m_display, menu.window); 392 XMapSubwindows(m_display, menu.window.window());
398 XMapWindow(m_display, menu.window); 393 menu.window.show();
399 visible = True; 394 visible = True;
400 395
401 if (! m_parent) { 396 if (! m_parent) {
@@ -436,14 +431,15 @@ void Basemenu::internal_hide() {
436 torn = visible = false; 431 torn = visible = false;
437 which_sub = which_press = which_sub = -1; 432 which_sub = which_press = which_sub = -1;
438 433
439 XUnmapWindow(m_display, menu.window); 434 menu.window.hide();
440} 435}
441 436
442 437
443void Basemenu::move(int x, int y) { 438void Basemenu::move(int x, int y) {
444 menu.x = x; 439 menu.x = x;
445 menu.y = y; 440 menu.y = y;
446 XMoveWindow(m_display, menu.window, x, y); 441 menu.window.move(x, y);
442
447 if (which_sub != -1) 443 if (which_sub != -1)
448 drawSubmenu(which_sub); 444 drawSubmenu(which_sub);
449} 445}
@@ -471,7 +467,7 @@ void Basemenu::redrawTitle() {
471 } 467 }
472 468
473 m_screen->getMenuStyle()->titlefont.drawText( 469 m_screen->getMenuStyle()->titlefont.drawText(
474 menu.title, // drawable 470 menu.title.window(), // drawable
475 m_screen->getScreenNumber(), 471 m_screen->getScreenNumber(),
476 m_screen->getMenuStyle()->t_text_gc, // graphic context 472 m_screen->getMenuStyle()->t_text_gc, // graphic context
477 text, len, // text string with lenght 473 text, len, // text string with lenght
@@ -656,7 +652,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
656 sel_y = item_y + quarter_w; 652 sel_y = item_y + quarter_w;
657 653
658 if (clear) { 654 if (clear) {
659 XClearArea(m_display, menu.frame, item_x, item_y, menu.item_w, menu.item_h, 655 XClearArea(m_display, menu.frame.window(), item_x, item_y, menu.item_w, menu.item_h,
660 False); 656 False);
661 } else if (! (x == y && y == -1 && w == h && h == 0)) { 657 } else if (! (x == y && y == -1 && w == h && h == 0)) {
662 // calculate the which part of the hilite to redraw 658 // calculate the which part of the hilite to redraw
@@ -687,11 +683,11 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
687 683
688 if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { 684 if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
689 if (menu.hilite_pixmap) { 685 if (menu.hilite_pixmap) {
690 XCopyArea(m_display, menu.hilite_pixmap, menu.frame, 686 XCopyArea(m_display, menu.hilite_pixmap, menu.frame.window(),
691 m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y, 687 m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y,
692 hilite_w, hilite_h, hilite_x, hilite_y); 688 hilite_w, hilite_h, hilite_x, hilite_y);
693 } else { 689 } else {
694 XFillRectangle(m_display, menu.frame, 690 XFillRectangle(m_display, menu.frame.window(),
695 m_screen->getMenuStyle()->hilite_gc, 691 m_screen->getMenuStyle()->hilite_gc,
696 hilite_x, hilite_y, hilite_w, hilite_h); 692 hilite_x, hilite_y, hilite_w, hilite_h);
697 } 693 }
@@ -700,11 +696,11 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
700 if (dosel && item->isSelected() && 696 if (dosel && item->isSelected() &&
701 (menu.sel_pixmap != ParentRelative)) { 697 (menu.sel_pixmap != ParentRelative)) {
702 if (menu.sel_pixmap) { 698 if (menu.sel_pixmap) {
703 XCopyArea(m_display, highlight ? menu.frame_pixmap : menu.sel_pixmap, menu.frame, 699 XCopyArea(m_display, highlight ? menu.frame_pixmap : menu.sel_pixmap, menu.frame.window(),
704 m_screen->getMenuStyle()->hilite_gc, 0, 0, 700 m_screen->getMenuStyle()->hilite_gc, 0, 0,
705 half_w, half_w, sel_x, sel_y); 701 half_w, half_w, sel_x, sel_y);
706 } else { 702 } else {
707 XFillRectangle(m_display, menu.frame, 703 XFillRectangle(m_display, menu.frame.window(),
708 m_screen->getMenuStyle()->hilite_gc, 704 m_screen->getMenuStyle()->hilite_gc,
709 sel_x, sel_y, half_w, half_w); 705 sel_x, sel_y, half_w, half_w);
710 } 706 }
@@ -712,18 +708,18 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
712 708
713 if (dotext && text) { 709 if (dotext && text) {
714 m_screen->getMenuStyle()->framefont.drawText( 710 m_screen->getMenuStyle()->framefont.drawText(
715 menu.frame, // drawable 711 menu.frame.window(), // drawable
716 m_screen->getScreenNumber(), 712 m_screen->getScreenNumber(),
717 tgc, 713 tgc,
718 text, len, // text string and lenght 714 text, len, // text string and lenght
719 text_x, text_y); // position 715 text_x, text_y); // position
720 716
721 } 717 }
722 718
723 if (dosel && item->submenu()) { 719 if (dosel && item->submenu()) {
724 switch (m_screen->getMenuStyle()->bullet) { 720 switch (m_screen->getMenuStyle()->bullet) {
725 case SQUARE: 721 case SQUARE:
726 XDrawRectangle(m_display, menu.frame, gc, sel_x, sel_y, half_w, half_w); 722 XDrawRectangle(m_display, menu.frame.window(), gc, sel_x, sel_y, half_w, half_w);
727 break; 723 break;
728 724
729 case TRIANGLE: 725 case TRIANGLE:
@@ -745,7 +741,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
745 tri[2].y = -4; 741 tri[2].y = -4;
746 } 742 }
747 743
748 XFillPolygon(m_display, menu.frame, gc, tri, 3, Convex, 744 XFillPolygon(m_display, menu.frame.window(), gc, tri, 3, Convex,
749 CoordModePrevious); 745 CoordModePrevious);
750 break; 746 break;
751 747
@@ -761,7 +757,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
761 dia[3].x = -3; 757 dia[3].x = -3;
762 dia[3].y = 3; 758 dia[3].y = 3;
763 759
764 XFillPolygon(m_display, menu.frame, gc, dia, 4, Convex, 760 XFillPolygon(m_display, menu.frame.window(), gc, dia, 4, Convex,
765 CoordModePrevious); 761 CoordModePrevious);
766 break; 762 break;
767 } 763 }
@@ -819,9 +815,9 @@ bool Basemenu::isItemEnabled(unsigned int index) const {
819} 815}
820 816
821 817
822void Basemenu::buttonPressEvent(XButtonEvent *be) { 818void Basemenu::buttonPressEvent(XButtonEvent &be) {
823 if (be->window == menu.frame) { 819 if (be.window == menu.frame) {
824 int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); 820 int sbl = (be.x / menu.item_w), i = (be.y / menu.item_h);
825 int w = (sbl * menu.persub) + i; 821 int w = (sbl * menu.persub) + i;
826 822
827 if (w < static_cast<int>(menuitems.size()) && w >= 0) { 823 if (w < static_cast<int>(menuitems.size()) && w >= 0) {
@@ -836,14 +832,14 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
836 drawItem(w, (item->isEnabled()), true); 832 drawItem(w, (item->isEnabled()), true);
837 } 833 }
838 } else { 834 } else {
839 menu.x_move = be->x_root - menu.x; 835 menu.x_move = be.x_root - menu.x;
840 menu.y_move = be->y_root - menu.y; 836 menu.y_move = be.y_root - menu.y;
841 } 837 }
842} 838}
843 839
844 840
845void Basemenu::buttonReleaseEvent(XButtonEvent *re) { 841void Basemenu::buttonReleaseEvent(XButtonEvent &re) {
846 if (re->window == menu.title) { 842 if (re.window == menu.title) {
847 if (moving) { 843 if (moving) {
848 moving = false; 844 moving = false;
849 845
@@ -851,19 +847,19 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
851 drawSubmenu(which_sub); 847 drawSubmenu(which_sub);
852 } 848 }
853 849
854 if (re->x >= 0 && re->x <= (signed) menu.width && 850 if (re.x >= 0 && re.x <= (signed) menu.width &&
855 re->y >= 0 && re->y <= (signed) menu.title_h && 851 re.y >= 0 && re.y <= (signed) menu.title_h &&
856 re->button == 3) 852 re.button == 3)
857 hide(); 853 hide();
858 854
859 } else if (re->window == menu.frame && 855 } else if (re.window == menu.frame &&
860 re->x >= 0 && re->x < (signed) menu.width && 856 re.x >= 0 && re.x < (signed) menu.width &&
861 re->y >= 0 && re->y < (signed) menu.frame_h) { 857 re.y >= 0 && re.y < (signed) menu.frame_h) {
862 858
863 if (re->button == 3) { 859 if (re.button == 3) {
864 hide(); 860 hide();
865 } else { 861 } else {
866 int sbl = (re->x / menu.item_w), i = (re->y / menu.item_h), 862 int sbl = (re.x / menu.item_w), i = (re.y / menu.item_h),
867 ix = sbl * menu.item_w, iy = i * menu.item_h, 863 ix = sbl * menu.item_w, iy = i * menu.item_h,
868 w = (sbl * menu.persub) + i, 864 w = (sbl * menu.persub) + i,
869 p = (which_sbl * menu.persub) + which_press; 865 p = (which_sbl * menu.persub) + which_press;
@@ -872,9 +868,9 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
872 drawItem(p, (p == which_sub), True); 868 drawItem(p, (p == which_sub), True);
873 869
874 if (p == w && isItemEnabled(w)) { 870 if (p == w && isItemEnabled(w)) {
875 if (re->x > ix && re->x < (signed) (ix + menu.item_w) && 871 if (re.x > ix && re.x < (signed) (ix + menu.item_w) &&
876 re->y > iy && re->y < (signed) (iy + menu.item_h)) { 872 re.y > iy && re.y < (signed) (iy + menu.item_h)) {
877 itemSelected(re->button, w); 873 itemSelected(re.button, w);
878 } 874 }
879 } 875 }
880 } else 876 } else
@@ -885,12 +881,12 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
885} 881}
886 882
887 883
888void Basemenu::motionNotifyEvent(XMotionEvent *me) { 884void Basemenu::motionNotifyEvent(XMotionEvent &me) {
889 if (me->window == menu.title && (me->state & Button1Mask)) { 885 if (me.window == menu.title && (me.state & Button1Mask)) {
890 if (movable) { 886 if (movable) {
891 if (! moving) { 887 if (! moving) {
892 if (m_parent && (! torn)) { 888 if (m_parent && (! torn)) {
893 m_parent->drawItem(m_parent->which_sub, False, True); 889 m_parent->drawItem(m_parent->which_sub, false, true);
894 m_parent->which_sub = -1; 890 m_parent->which_sub = -1;
895 } 891 }
896 892
@@ -899,19 +895,19 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
899 if (which_sub >= 0) 895 if (which_sub >= 0)
900 drawSubmenu(which_sub); 896 drawSubmenu(which_sub);
901 } else { 897 } else {
902 menu.x = me->x_root - menu.x_move, 898 menu.x = me.x_root - menu.x_move,
903 menu.y = me->y_root - menu.y_move; 899 menu.y = me.y_root - menu.y_move;
904 900
905 XMoveWindow(m_display, menu.window, menu.x, menu.y); 901 menu.window.move(menu.x, menu.y);
906 902
907 if (which_sub >= 0) 903 if (which_sub >= 0)
908 drawSubmenu(which_sub); 904 drawSubmenu(which_sub);
909 } 905 }
910 } 906 }
911 } else if ((! (me->state & Button1Mask)) && me->window == menu.frame && 907 } else if ((! (me.state & Button1Mask)) && me.window == menu.frame &&
912 me->x >= 0 && me->x < (signed) menu.width && 908 me.x >= 0 && me.x < (signed) menu.width &&
913 me->y >= 0 && me->y < (signed) menu.frame_h) { 909 me.y >= 0 && me.y < (signed) menu.frame_h) {
914 int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h), 910 int sbl = (me.x / menu.item_w), i = (me.y / menu.item_h),
915 w = (sbl * menu.persub) + i; 911 w = (sbl * menu.persub) + i;
916 912
917 if ((i != which_press || sbl != which_sbl) && 913 if ((i != which_press || sbl != which_sbl) &&
@@ -944,19 +940,19 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
944} 940}
945 941
946 942
947void Basemenu::exposeEvent(XExposeEvent *ee) { 943void Basemenu::exposeEvent(XExposeEvent &ee) {
948 if (ee->window == menu.title) { 944 if (ee.window == menu.title) {
949 redrawTitle(); 945 redrawTitle();
950 } else if (ee->window == menu.frame) { 946 } else if (ee.window == menu.frame) {
951 // this is a compilicated algorithm... lets do it step by step... 947 // this is a compilicated algorithm... lets do it step by step...
952 // first... we see in which sub level the expose starts... and how many 948 // first... we see in which sub level the expose starts... and how many
953 // items down in that sublevel 949 // items down in that sublevel
954 950
955 int sbl = (ee->x / menu.item_w), id = (ee->y / menu.item_h), 951 int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h),
956 // next... figure out how many sublevels over the redraw spans 952 // next... figure out how many sublevels over the redraw spans
957 sbl_d = ((ee->x + ee->width) / menu.item_w), 953 sbl_d = ((ee.x + ee.width) / menu.item_w),
958 // then we see how many items down to redraw 954 // then we see how many items down to redraw
959 id_d = ((ee->y + ee->height) / menu.item_h); 955 id_d = ((ee.y + ee.height) / menu.item_h);
960 956
961 if (id_d > menu.persub) id_d = menu.persub; 957 if (id_d > menu.persub) id_d = menu.persub;
962 958
@@ -972,7 +968,7 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
972 int index = ii + (i * menu.persub); 968 int index = ii + (i * menu.persub);
973 // redraw the item 969 // redraw the item
974 drawItem(index, (which_sub == index), true, 970 drawItem(index, (which_sub == index), true,
975 ee->x, ee->y, ee->width, ee->height); 971 ee.x, ee.y, ee.width, ee.height);
976 } 972 }
977 } 973 }
978 } 974 }
@@ -980,110 +976,108 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
980} 976}
981 977
982 978
983void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { 979void Basemenu::enterNotifyEvent(XCrossingEvent &ce) {
984#ifdef XINERAMA 980
985 int head = m_screen->hasXinerama() ? m_screen->getCurrHead() : 0; 981 #ifdef XINERAMA
986 982 int head = m_screen->hasXinerama() ? m_screen->getCurrHead() : 0;
987 if (ce->window == menu.frame) { 983
988 menu.x_shift = menu.x, menu.y_shift = menu.y; 984 if (ce.window == menu.frame) {
989 if (menu.x + menu.width > 985 menu.x_shift = menu.x, menu.y_shift = menu.y;
990 (m_screen->getHeadX(head) + m_screen->getHeadWidth(head))) { 986 if (menu.x + menu.width >
991 menu.x_shift = m_screen->getHeadX(head) + m_screen->getHeadWidth(head) - 987 (m_screen->getHeadX(head) + m_screen->getHeadWidth(head))) {
992 menu.width - m_screen->getBorderWidth2x(); 988 menu.x_shift = m_screen->getHeadX(head) + m_screen->getHeadWidth(head) -
993 shifted = True; 989 menu.width - m_screen->getBorderWidth2x();
994 } else if (menu.x < m_screen->getHeadX(head)) { 990 shifted = true;
995 menu.x_shift = m_screen->getHeadX(head); 991 } else if (menu.x < m_screen->getHeadX(head)) {
996 shifted = True; 992 menu.x_shift = m_screen->getHeadX(head);
997 } 993 shifted = true;
998 994 }
999 if (menu.y + menu.height > 995
1000 (m_screen->getHeadY(head) + m_screen->getHeadHeight(head))) { 996 if (menu.y + menu.height >
1001 menu.y_shift = m_screen->getHeadY(head) + m_screen->getHeadHeight(head) - 997 (m_screen->getHeadY(head) + m_screen->getHeadHeight(head))) {
1002 menu.height - m_screen->getBorderWidth2x(); 998 menu.y_shift = m_screen->getHeadY(head) + m_screen->getHeadHeight(head) -
1003 shifted = True; 999 menu.height - m_screen->getBorderWidth2x();
1004 } else if (menu.y + (signed) menu.title_h < m_screen->getHeadY(head)) { 1000 shifted = true;
1005 menu.y_shift = m_screen->getHeadY(head); 1001 } else if (menu.y + static_cast<signed>(menu.title_h) < m_screen->getHeadY(head)) {
1006 shifted = True; 1002 menu.y_shift = m_screen->getHeadY(head);
1007 } 1003 shifted = true;
1004 }
1008 1005
1009#else // !XINERAMA 1006#else // !XINERAMA
1010 1007
1011 if (ce->window == menu.frame) { 1008 if (ce.window == menu.frame) {
1012 menu.x_shift = menu.x, menu.y_shift = menu.y; 1009 menu.x_shift = menu.x, menu.y_shift = menu.y;
1013 if (menu.x + menu.width > m_screen->getWidth()) { 1010 if (menu.x + menu.width > m_screen->getWidth()) {
1014 menu.x_shift = m_screen->getWidth() - menu.width - 1011 menu.x_shift = m_screen->getWidth() - menu.width -
1015 m_screen->getBorderWidth(); 1012 m_screen->getBorderWidth();
1016 shifted = True; 1013 shifted = true;
1017 } else if (menu.x < 0) { 1014 } else if (menu.x < 0) {
1018 menu.x_shift = -m_screen->getBorderWidth(); 1015 menu.x_shift = -m_screen->getBorderWidth();
1019 shifted = True; 1016 shifted = true;
1020 } 1017 }
1021 1018
1022 if (menu.y + menu.height > m_screen->getHeight()) { 1019 if (menu.y + menu.height > m_screen->getHeight()) {
1023 menu.y_shift = m_screen->getHeight() - menu.height - 1020 menu.y_shift = m_screen->getHeight() - menu.height -
1024 m_screen->getBorderWidth(); 1021 m_screen->getBorderWidth();
1025 shifted = True; 1022 shifted = true;
1026 } else if (menu.y + (signed) menu.title_h < 0) { 1023 } else if (menu.y + (signed) menu.title_h < 0) {
1027 menu.y_shift = -m_screen->getBorderWidth(); 1024 menu.y_shift = -m_screen->getBorderWidth();
1028 shifted = True; 1025 shifted = true;
1029 } 1026 }
1030 1027
1031#endif // XINERAMA 1028#endif // XINERAMA
1032 1029
1033 if (shifted) { 1030 if (shifted) {
1034#ifdef XINERAMA 1031#ifdef XINERAMA
1035 menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads 1032 menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads
1036 menu.y = menu.y_shift; 1033 menu.y = menu.y_shift;
1037#endif // XINERAMA 1034#endif // XINERAMA
1038 XMoveWindow(m_display, menu.window, menu.x_shift, menu.y_shift); 1035 menu.window.move(menu.x_shift, menu.y_shift);
1039 } 1036 }
1040 1037
1041 if (which_sub >= 0 && static_cast<size_t>(which_sub) < menuitems.size()) { 1038 if (which_sub >= 0 && static_cast<size_t>(which_sub) < menuitems.size()) {
1042 BasemenuItem *tmp = menuitems[which_sub]; 1039 BasemenuItem *tmp = menuitems[which_sub];
1043 if (tmp->submenu()->isVisible()) { 1040 if (tmp->submenu()->isVisible()) {
1044 int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), 1041 int sbl = (ce.x / menu.item_w), i = (ce.y / menu.item_h),
1045 w = (sbl * menu.persub) + i; 1042 w = (sbl * menu.persub) + i;
1046 1043
1047 if (w != which_sub && (! tmp->submenu()->isTorn())) { 1044 if (w != which_sub && (! tmp->submenu()->isTorn())) {
1048 tmp->submenu()->internal_hide(); 1045 tmp->submenu()->internal_hide();
1049 1046
1050 drawItem(which_sub, False, True); 1047 drawItem(which_sub, false, true);
1051 which_sub = -1; 1048 which_sub = -1;
1052 }
1053 }
1054 } 1049 }
1055 } 1050 }
1056 } 1051 }
1052 }
1053}
1057 1054
1055void Basemenu::leaveNotifyEvent(XCrossingEvent &ce) {
1056 if (ce.window == menu.frame) {
1057 if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) {
1058 int p = (which_sbl * menu.persub) + which_press;
1058 1059
1059 void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) { 1060 drawItem(p, (p == which_sub), true);
1060 if (ce->window == menu.frame) {
1061 if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) {
1062 int p = (which_sbl * menu.persub) + which_press;
1063
1064 drawItem(p, (p == which_sub), true);
1065 1061
1066 which_sbl = which_press = -1; 1062 which_sbl = which_press = -1;
1067 } 1063 }
1068 1064
1069 if (shifted) { 1065 if (shifted) {
1070 XMoveWindow(m_display, menu.window, menu.x, menu.y); 1066 menu.window.move(menu.x, menu.y);
1071 shifted = false; 1067 shifted = false;
1072 1068
1073 if (which_sub >= 0) 1069 if (which_sub >= 0)
1074 drawSubmenu(which_sub); 1070 drawSubmenu(which_sub);
1075 } 1071 }
1076 }
1077 } 1072 }
1073}
1078 1074
1079 1075
1080 void Basemenu::reconfigure(void) { 1076void Basemenu::reconfigure() {
1081 XSetWindowBackground(m_display, menu.window, 1077 menu.window.setBackgroundColor(*m_screen->getBorderColor());
1082 m_screen->getBorderColor()->pixel()); 1078 menu.window.setBorderColor(*m_screen->getBorderColor());
1083 XSetWindowBorder(m_display, menu.window, 1079 menu.window.setBorderWidth(m_screen->getBorderWidth());
1084 m_screen->getBorderColor()->pixel());
1085 XSetWindowBorderWidth(m_display, menu.window, m_screen->getBorderWidth());
1086 1080
1087 menu.bevel_w = m_screen->getBevelWidth(); 1081 menu.bevel_w = m_screen->getBevelWidth();
1088 update(); 1082 update();
1089 } 1083}