aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2021-07-06 23:31:49 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2021-07-06 23:31:49 (GMT)
commit0279936d835d7d88537bcf1208035787c02ced59 (patch)
tree29ef6609dbd82041ba6b6363c9f1356c447112dc
parent43ae328658518a4ee1b3bf363f8865234c64a674 (diff)
downloadfluxbox-0279936d835d7d88537bcf1208035787c02ced59.zip
fluxbox-0279936d835d7d88537bcf1208035787c02ced59.tar.bz2
Patch from Thomas Luebking
Adds (secret) opaque resize mode. It sure would be nice if it was documented.... The relevant init file resources and their default values are: session.screen0.opaqueResize: False session.screen0.opaqueResizeDelay: 40
-rw-r--r--src/Screen.hh2
-rw-r--r--src/ScreenResource.cc4
-rw-r--r--src/ScreenResource.hh2
-rw-r--r--src/Window.cc79
-rw-r--r--src/Window.hh3
5 files changed, 57 insertions, 33 deletions
diff --git a/src/Screen.hh b/src/Screen.hh
index 15eb349..83c5cb5 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -100,6 +100,8 @@ public:
100 bool doAutoRaise() const { return *resource.auto_raise; } 100 bool doAutoRaise() const { return *resource.auto_raise; }
101 bool clickRaises() const { return *resource.click_raises; } 101 bool clickRaises() const { return *resource.click_raises; }
102 bool doOpaqueMove() const { return *resource.opaque_move; } 102 bool doOpaqueMove() const { return *resource.opaque_move; }
103 bool doOpaqueResize() const { return *resource.opaque_resize; }
104 unsigned int opaqueResizeDelay() const { return *resource.opaque_resize_delay; }
103 bool doFullMax() const { return *resource.full_max; } 105 bool doFullMax() const { return *resource.full_max; }
104 bool getMaxIgnoreIncrement() const { return *resource.max_ignore_inc; } 106 bool getMaxIgnoreIncrement() const { return *resource.max_ignore_inc; }
105 bool getMaxDisableMove() const { return *resource.max_disable_move; } 107 bool getMaxDisableMove() const { return *resource.max_disable_move; }
diff --git a/src/ScreenResource.cc b/src/ScreenResource.cc
index c188648..c5e0027 100644
--- a/src/ScreenResource.cc
+++ b/src/ScreenResource.cc
@@ -83,6 +83,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm,
83 const std::string& scrname, 83 const std::string& scrname,
84 const std::string& altscrname): 84 const std::string& altscrname):
85 opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"), 85 opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"),
86 opaque_resize(rm, false, scrname + ".opaqueResize", altscrname+".OpaqueResize"),
86 full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"), 87 full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"),
87 max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"), 88 max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"),
88 max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), 89 max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"),
@@ -110,6 +111,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm,
110 clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), 111 clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"),
111 tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), 112 tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"),
112 max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), 113 max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"),
113 default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { 114 default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar"),
115 opaque_resize_delay(rm, 50, scrname + ".opaqueResizeDelay", altscrname+".OpaqueResizeDelay") {
114 116
115} 117}
diff --git a/src/ScreenResource.hh b/src/ScreenResource.hh
index bc782e1..120ecf9 100644
--- a/src/ScreenResource.hh
+++ b/src/ScreenResource.hh
@@ -32,6 +32,7 @@ struct ScreenResource {
32 const std::string &scrname, const std::string &altscrname); 32 const std::string &scrname, const std::string &altscrname);
33 33
34 FbTk::Resource<bool> opaque_move, 34 FbTk::Resource<bool> opaque_move,
35 opaque_resize,
35 full_max, 36 full_max,
36 max_ignore_inc, 37 max_ignore_inc,
37 max_disable_move, 38 max_disable_move,
@@ -61,6 +62,7 @@ struct ScreenResource {
61 FbTk::Resource<bool> tabs_use_pixmap; 62 FbTk::Resource<bool> tabs_use_pixmap;
62 FbTk::Resource<bool> max_over_tabs; 63 FbTk::Resource<bool> max_over_tabs;
63 FbTk::Resource<bool> default_internal_tabs; 64 FbTk::Resource<bool> default_internal_tabs;
65 FbTk::Resource<unsigned int> opaque_resize_delay;
64}; 66};
65 67
66#endif 68#endif
diff --git a/src/Window.cc b/src/Window.cc
index 6714d0a..1f2d184 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -449,6 +449,12 @@ void FluxboxWindow::init() {
449 m_tabActivationTimer.setCommand(activate_tab_cmd); 449 m_tabActivationTimer.setCommand(activate_tab_cmd);
450 m_tabActivationTimer.fireOnce(true); 450 m_tabActivationTimer.fireOnce(true);
451 451
452 m_resizeTimer.setTimeout(screen().opaqueResizeDelay() * FbTk::FbTime::IN_MILLISECONDS);
453 FbTk::RefCount<FbTk::Command<void> > resize_cmd(new FbTk::SimpleCommand<FluxboxWindow>(*this,
454 &FluxboxWindow::updateResize));
455 m_resizeTimer.setCommand(resize_cmd);
456 m_resizeTimer.fireOnce(true);
457
452 m_reposLabels_timer.setTimeout(IconButton::updateLaziness()); 458 m_reposLabels_timer.setTimeout(IconButton::updateLaziness());
453 m_reposLabels_timer.fireOnce(true); 459 m_reposLabels_timer.fireOnce(true);
454 FbTk::RefCount<FbTk::Command<void> > elrs(new FbTk::SimpleCommand<FluxboxWindow>(*this, &FluxboxWindow::emitLabelReposSig)); 460 FbTk::RefCount<FbTk::Command<void> > elrs(new FbTk::SimpleCommand<FluxboxWindow>(*this, &FluxboxWindow::emitLabelReposSig));
@@ -2663,36 +2669,36 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2663 int old_resize_w = m_last_resize_w; 2669 int old_resize_w = m_last_resize_w;
2664 int old_resize_h = m_last_resize_h; 2670 int old_resize_h = m_last_resize_h;
2665 2671
2666 int dx = me.x - m_button_grab_x; 2672 int dx = me.x_root - m_button_grab_x;
2667 int dy = me.y - m_button_grab_y; 2673 int dy = me.y_root - m_button_grab_y;
2668 2674
2669 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || 2675 if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM ||
2670 m_resize_corner == LEFT) { 2676 m_resize_corner == LEFT) {
2671 m_last_resize_w = frame().width() - dx; 2677 m_last_resize_w = resize_base_w - dx;
2672 m_last_resize_x = frame().x() + dx; 2678 m_last_resize_x = resize_base_x + dx;
2673 } 2679 }
2674 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || 2680 if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP ||
2675 m_resize_corner == TOP) { 2681 m_resize_corner == TOP) {
2676 m_last_resize_h = frame().height() - dy; 2682 m_last_resize_h = resize_base_h - dy;
2677 m_last_resize_y = frame().y() + dy; 2683 m_last_resize_y = resize_base_y + dy;
2678 } 2684 }
2679 if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM || 2685 if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM ||
2680 m_resize_corner == RIGHTBOTTOM) 2686 m_resize_corner == RIGHTBOTTOM)
2681 m_last_resize_h = frame().height() + dy; 2687 m_last_resize_h = resize_base_h + dy;
2682 if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP || 2688 if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP ||
2683 m_resize_corner == RIGHT) 2689 m_resize_corner == RIGHT)
2684 m_last_resize_w = frame().width() + dx; 2690 m_last_resize_w = resize_base_w + dx;
2685 if (m_resize_corner == CENTER) { 2691 if (m_resize_corner == CENTER) {
2686 // dx or dy must be at least 2 2692 // dx or dy must be at least 2
2687 if (abs(dx) >= 2 || abs(dy) >= 2) { 2693 if (abs(dx) >= 2 || abs(dy) >= 2) {
2688 // take max and make it even 2694 // take max and make it even
2689 int diff = 2 * (max(dx, dy) / 2); 2695 int diff = 2 * (max(dx, dy) / 2);
2690 2696
2691 m_last_resize_h = frame().height() + diff; 2697 m_last_resize_h = resize_base_h + diff;
2692 2698
2693 m_last_resize_w = frame().width() + diff; 2699 m_last_resize_w = resize_base_w + diff;
2694 m_last_resize_x = frame().x() - diff/2; 2700 m_last_resize_x = resize_base_x - diff/2;
2695 m_last_resize_y = frame().y() - diff/2; 2701 m_last_resize_y = resize_base_y - diff/2;
2696 } 2702 }
2697 } 2703 }
2698 2704
@@ -2780,18 +2786,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
2780 } 2786 }
2781 } 2787 }
2782 2788
2783 // draw over old rect 2789 if (m_last_resize_w != old_resize_w || m_last_resize_h != old_resize_h) {
2784 parent().drawRectangle(screen().rootTheme()->opGC(), 2790 if (screen().doOpaqueResize()) {
2785 old_resize_x, old_resize_y, 2791 m_resizeTimer.start();
2786 old_resize_w - 1 + 2 * frame().window().borderWidth(), 2792 } else {
2787 old_resize_h - 1 + 2 * frame().window().borderWidth()); 2793 // draw over old rect
2788 2794 parent().drawRectangle(screen().rootTheme()->opGC(),
2789 // draw resize rectangle 2795 old_resize_x, old_resize_y,
2790 parent().drawRectangle(screen().rootTheme()->opGC(), 2796 old_resize_w - 1 + 2 * frame().window().borderWidth(),
2791 m_last_resize_x, m_last_resize_y, 2797 old_resize_h - 1 + 2 * frame().window().borderWidth());
2792 m_last_resize_w - 1 + 2 * frame().window().borderWidth(), 2798
2793 m_last_resize_h - 1 + 2 * frame().window().borderWidth()); 2799 // draw resize rectangle
2794 2800 parent().drawRectangle(screen().rootTheme()->opGC(),
2801 m_last_resize_x, m_last_resize_y,
2802 m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
2803 m_last_resize_h - 1 + 2 * frame().window().borderWidth());
2804 }
2805 }
2795 } 2806 }
2796 } 2807 }
2797} 2808}
@@ -3320,29 +3331,33 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) {
3320 false, ButtonMotionMask | ButtonReleaseMask, 3331 false, ButtonMotionMask | ButtonReleaseMask,
3321 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); 3332 GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
3322 3333
3323 m_button_grab_x = x; 3334 m_button_grab_x = x + frame().x();
3324 m_button_grab_y = y; 3335 m_button_grab_y = y + frame().y();
3325 m_last_resize_x = frame().x(); 3336 resize_base_x = m_last_resize_x = frame().x();
3326 m_last_resize_y = frame().y(); 3337 resize_base_y = m_last_resize_y = frame().y();
3327 m_last_resize_w = frame().width(); 3338 resize_base_w = m_last_resize_w = frame().width();
3328 m_last_resize_h = frame().height(); 3339 resize_base_h = m_last_resize_h = frame().height();
3329 3340
3330 fixSize(); 3341 fixSize();
3331 frame().displaySize(m_last_resize_w, m_last_resize_h); 3342 frame().displaySize(m_last_resize_w, m_last_resize_h);
3332 3343
3333 parent().drawRectangle(screen().rootTheme()->opGC(), 3344 if (!screen().doOpaqueResize()) {
3345 parent().drawRectangle(screen().rootTheme()->opGC(),
3334 m_last_resize_x, m_last_resize_y, 3346 m_last_resize_x, m_last_resize_y,
3335 m_last_resize_w - 1 + 2 * frame().window().borderWidth(), 3347 m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
3336 m_last_resize_h - 1 + 2 * frame().window().borderWidth()); 3348 m_last_resize_h - 1 + 2 * frame().window().borderWidth());
3349 }
3337} 3350}
3338 3351
3339void FluxboxWindow::stopResizing(bool interrupted) { 3352void FluxboxWindow::stopResizing(bool interrupted) {
3340 resizing = false; 3353 resizing = false;
3341 3354
3342 parent().drawRectangle(screen().rootTheme()->opGC(), 3355 if (!screen().doOpaqueResize()) {
3356 parent().drawRectangle(screen().rootTheme()->opGC(),
3343 m_last_resize_x, m_last_resize_y, 3357 m_last_resize_x, m_last_resize_y,
3344 m_last_resize_w - 1 + 2 * frame().window().borderWidth(), 3358 m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
3345 m_last_resize_h - 1 + 2 * frame().window().borderWidth()); 3359 m_last_resize_h - 1 + 2 * frame().window().borderWidth());
3360 }
3346 3361
3347 screen().hideGeometry(); 3362 screen().hideGeometry();
3348 3363
diff --git a/src/Window.hh b/src/Window.hh
index 407d51b..c6e3ce4 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -528,6 +528,7 @@ private:
528 void moveResizeClient(WinClient &client); 528 void moveResizeClient(WinClient &client);
529 /// sends configurenotify to all clients 529 /// sends configurenotify to all clients
530 void sendConfigureNotify(); 530 void sendConfigureNotify();
531 void updateResize() { moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); }
531 532
532 static void grabPointer(Window grab_window, 533 static void grabPointer(Window grab_window,
533 Bool owner_events, 534 Bool owner_events,
@@ -553,6 +554,7 @@ private:
553 uint64_t m_last_keypress_time; 554 uint64_t m_last_keypress_time;
554 FbTk::Timer m_timer; 555 FbTk::Timer m_timer;
555 FbTk::Timer m_tabActivationTimer; 556 FbTk::Timer m_tabActivationTimer;
557 FbTk::Timer m_resizeTimer;
556 558
557 // Window states 559 // Window states
558 bool moving, resizing, m_initialized; 560 bool moving, resizing, m_initialized;
@@ -565,6 +567,7 @@ private:
565 int m_last_resize_x, m_last_resize_y; // handles last button press event for resize 567 int m_last_resize_x, m_last_resize_y; // handles last button press event for resize
566 int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving 568 int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving
567 int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" 569 int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window"
570 int resize_base_x, resize_base_y, resize_base_w, resize_base_h; // opaque and transparent resize alignment
568 int m_last_pressed_button; 571 int m_last_pressed_button;
569 572
570 unsigned int m_workspace_number; 573 unsigned int m_workspace_number;