aboutsummaryrefslogtreecommitdiff
path: root/src/FbWinFrame.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-01-07 01:30:57 (GMT)
committerfluxgen <fluxgen>2003-01-07 01:30:57 (GMT)
commit06f63eec84fa37e0832fee0432cd398f55f7aeba (patch)
tree48644dbb2b3571baff95513f9e9768725bc4f82d /src/FbWinFrame.cc
parent65fe7c36750f0c8418acbdc2732e0095eb344344 (diff)
downloadfluxbox-06f63eec84fa37e0832fee0432cd398f55f7aeba.zip
fluxbox-06f63eec84fa37e0832fee0432cd398f55f7aeba.tar.bz2
added double click interval, fixed actions on titlebar, added hide/show decorations
Diffstat (limited to 'src/FbWinFrame.cc')
-rw-r--r--src/FbWinFrame.cc119
1 files changed, 104 insertions, 15 deletions
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc
index caa6f8f..d467ccd 100644
--- a/src/FbWinFrame.cc
+++ b/src/FbWinFrame.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: FbWinFrame.cc,v 1.1 2003/01/05 22:14:10 fluxgen Exp $ 22// $Id: FbWinFrame.cc,v 1.2 2003/01/07 01:30:57 fluxgen Exp $
23 23
24#include "FbWinFrame.hh" 24#include "FbWinFrame.hh"
25#include "ImageControl.hh" 25#include "ImageControl.hh"
@@ -62,7 +62,7 @@ FbWinFrame::FbWinFrame(FbWinFrameTheme &theme, BImageControl &imgctrl, int scree
62 m_clientwin(0), 62 m_clientwin(0),
63 m_bevel(1), 63 m_bevel(1),
64 m_use_titlebar(true), 64 m_use_titlebar(true),
65 m_use_handles(true), 65 m_use_handle(true),
66 m_button_pm(0) { 66 m_button_pm(0) {
67 init(); 67 init();
68} 68}
@@ -96,6 +96,23 @@ FbWinFrame::~FbWinFrame() {
96 96
97} 97}
98 98
99bool FbWinFrame::setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &ref, int mousebutton_num,
100 bool double_click, bool pressed) {
101 // find mousebutton_num
102 if (mousebutton_num < 1 || mousebutton_num > 5)
103 return false;
104 if (double_click)
105 m_commands[mousebutton_num - 1].double_click = ref;
106 else {
107 if (pressed)
108 m_commands[mousebutton_num - 1].click_pressed = ref;
109 else
110 m_commands[mousebutton_num - 1].click = ref;
111 }
112
113 return true;
114}
115
99void FbWinFrame::hide() { 116void FbWinFrame::hide() {
100 m_window.hide(); 117 m_window.hide();
101} 118}
@@ -146,6 +163,10 @@ void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) {
146 // total height for frame without client 163 // total height for frame without client
147 unsigned int total_height = m_handle.height() + m_titlebar.height(); 164 unsigned int total_height = m_handle.height() + m_titlebar.height();
148 // resize frame height with total height + specified height 165 // resize frame height with total height + specified height
166 if (!m_use_titlebar)
167 total_height -= m_titlebar.height();
168 if (!m_use_handle)
169 total_height -= m_handle.height();
149 resize(width, total_height + height); 170 resize(width, total_height + height);
150} 171}
151 172
@@ -167,6 +188,10 @@ void FbWinFrame::setFocus(bool newvalue) {
167 reconfigure(); // reconfigure rendering for new focus value 188 reconfigure(); // reconfigure rendering for new focus value
168} 189}
169 190
191void FbWinFrame::setDoubleClickTime(unsigned int time) {
192 m_double_click_time = time;
193}
194
170void FbWinFrame::setBevel(int bevel) { 195void FbWinFrame::setBevel(int bevel) {
171 m_bevel = bevel; 196 m_bevel = bevel;
172 reconfigure(); 197 reconfigure();
@@ -238,18 +263,41 @@ void FbWinFrame::removeClient() {
238 263
239void FbWinFrame::hideTitlebar() { 264void FbWinFrame::hideTitlebar() {
240 m_titlebar.hide(); 265 m_titlebar.hide();
266 m_use_titlebar = false;
241} 267}
242 268
243void FbWinFrame::showTitlebar() { 269void FbWinFrame::showTitlebar() {
244 m_titlebar.show(); 270 m_titlebar.show();
271 m_use_titlebar = true;
245} 272}
246 273
247void FbWinFrame::hideHandle() { 274void FbWinFrame::hideHandle() {
248 m_handle.hide(); 275 m_handle.hide();
276 m_grip_left.hide();
277 m_grip_right.hide();
278 m_use_handle = false;
249} 279}
250 280
251void FbWinFrame::showHandle() { 281void FbWinFrame::showHandle() {
252 m_handle.show(); 282 m_handle.show();
283 m_grip_left.show();
284 m_grip_right.show();
285 m_use_handle = true;
286}
287
288void FbWinFrame::hideAllDecorations() {
289 hideHandle();
290 hideTitlebar();
291 resizeForClient(m_clientarea.width(), m_clientarea.height() - m_window.borderWidth());
292 reconfigure();
293}
294
295void FbWinFrame::showAllDecorations() {
296 if (!m_use_handle)
297 showHandle();
298 if (!m_use_titlebar)
299 showTitlebar();
300 resizeForClient(m_clientarea.width(), m_clientarea.height() - m_window.borderWidth());
253} 301}
254 302
255/** 303/**
@@ -282,7 +330,37 @@ void FbWinFrame::removeEventHandler() {
282} 330}
283 331
284void FbWinFrame::buttonPressEvent(XButtonEvent &event) { 332void FbWinFrame::buttonPressEvent(XButtonEvent &event) {
285 m_window.raise(); 333 if (event.window != m_titlebar.window() &&
334 event.window != m_label.window())
335 return;
336
337 if (event.button > 5 || event.button < 1)
338 return;
339
340 if (*m_commands[event.button - 1].click_pressed) {
341 cerr<<"Pressed event button = "<<event.button<<endl;
342 m_commands[event.button - 1].click_pressed->execute();
343 }
344}
345
346void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) {
347 if (event.window != m_titlebar.window() &&
348 event.window != m_label.window())
349 return;
350
351 if (event.button < 1 || event.button > 5)
352 return;
353
354 static int last_release_time = 0;
355 bool double_click = (event.time - last_release_time <= m_double_click_time);
356 last_release_time = event.time;
357 int real_button = event.button - 1;
358
359 if (double_click && *m_commands[real_button].double_click)
360 m_commands[real_button].double_click->execute();
361 else if (*m_commands[real_button].click)
362 m_commands[real_button].click->execute();
363
286} 364}
287 365
288void FbWinFrame::exposeEvent(XExposeEvent &event) { 366void FbWinFrame::exposeEvent(XExposeEvent &event) {
@@ -305,11 +383,22 @@ void FbWinFrame::reconfigure() {
305 m_window.clear(); 383 m_window.clear();
306 384
307 // align titlebar and render it 385 // align titlebar and render it
308 reconfigureTitlebar(); 386 if (m_use_titlebar)
387 reconfigureTitlebar();
388 // setup client area size/pos
389 int next_y = m_titlebar.height() + 2*m_titlebar.borderWidth();
390 unsigned int client_height = m_window.height() - m_titlebar.height() - m_handle.height();
391
392 if (!m_use_titlebar) {
393 next_y = 0;
394 if (!m_use_handle)
395 client_height = m_window.height();
396 else
397 client_height = m_window.height() - m_handle.height();
398 }
309 399
310 m_clientarea.moveResize(0, m_titlebar.height() + 2*m_titlebar.borderWidth(), 400 m_clientarea.moveResize(0, next_y,
311 m_window.width(), 401 m_window.width(), client_height);
312 m_window.height() - m_titlebar.height() - m_handle.height());
313 402
314 if (m_clientwin != 0) { 403 if (m_clientwin != 0) {
315 XMoveResizeWindow(FbTk::App::instance()->display(), m_clientwin, 404 XMoveResizeWindow(FbTk::App::instance()->display(), m_clientwin,
@@ -317,6 +406,9 @@ void FbWinFrame::reconfigure() {
317 m_clientarea.width(), m_clientarea.height()); 406 m_clientarea.width(), m_clientarea.height());
318 } 407 }
319 408
409 if (!m_use_handle) // no need to do anything more
410 return;
411
320 // align handle and grips 412 // align handle and grips
321 const int grip_height = m_handle.height(); 413 const int grip_height = m_handle.height();
322 const int grip_width = 20; //TODO 414 const int grip_width = 20; //TODO
@@ -336,7 +428,6 @@ void FbWinFrame::reconfigure() {
336 // render the theme 428 // render the theme
337 renderButtons(); 429 renderButtons();
338 renderHandles(); 430 renderHandles();
339
340} 431}
341 432
342unsigned int FbWinFrame::titleHeight() const { 433unsigned int FbWinFrame::titleHeight() const {
@@ -476,7 +567,7 @@ void FbWinFrame::renderTitlebar() {
476 567
477 568
478void FbWinFrame::renderHandles() { 569void FbWinFrame::renderHandles() {
479 if (!m_use_handles) 570 if (!m_use_handle)
480 return; 571 return;
481 render(m_theme.handleFocusTexture(), m_handle_focused_color, 572 render(m_theme.handleFocusTexture(), m_handle_focused_color,
482 m_handle_focused_pm, 573 m_handle_focused_pm,
@@ -559,7 +650,7 @@ void FbWinFrame::init() {
559 m_title_focused_pm = m_title_unfocused_pm = 0; 650 m_title_focused_pm = m_title_unfocused_pm = 0;
560 m_label_focused_pm = m_label_unfocused_pm = 0; 651 m_label_focused_pm = m_label_unfocused_pm = 0;
561 m_button_unfocused_pm = m_button_pressed_pm = 0; 652 m_button_unfocused_pm = m_button_pressed_pm = 0;
562 653 m_double_click_time = 200;
563 m_button_pm = 0; 654 m_button_pm = 0;
564 m_button_size = 26; 655 m_button_size = 26;
565 m_handle_focused_pm = 656 m_handle_focused_pm =
@@ -567,12 +658,10 @@ void FbWinFrame::init() {
567 m_grip_unfocused_pm = m_grip_focused_pm = 0; 658 m_grip_unfocused_pm = m_grip_focused_pm = 0;
568 659
569 m_shaded = false; 660 m_shaded = false;
570
571 m_label.show(); 661 m_label.show();
572 m_titlebar.show(); 662
573 m_handle.show(); 663 showHandle();
574 m_grip_right.show(); 664 showTitlebar();
575 m_grip_left.show();
576 // note: we don't show clientarea yet 665 // note: we don't show clientarea yet
577 666
578 setEventHandler(*this); 667 setEventHandler(*this);