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
This commit is contained in:
Mark Tiefenbruck 2021-07-06 16:31:49 -07:00
parent 43ae328658
commit 0279936d83
5 changed files with 56 additions and 32 deletions

View file

@ -100,6 +100,8 @@ public:
bool doAutoRaise() const { return *resource.auto_raise; } bool doAutoRaise() const { return *resource.auto_raise; }
bool clickRaises() const { return *resource.click_raises; } bool clickRaises() const { return *resource.click_raises; }
bool doOpaqueMove() const { return *resource.opaque_move; } bool doOpaqueMove() const { return *resource.opaque_move; }
bool doOpaqueResize() const { return *resource.opaque_resize; }
unsigned int opaqueResizeDelay() const { return *resource.opaque_resize_delay; }
bool doFullMax() const { return *resource.full_max; } bool doFullMax() const { return *resource.full_max; }
bool getMaxIgnoreIncrement() const { return *resource.max_ignore_inc; } bool getMaxIgnoreIncrement() const { return *resource.max_ignore_inc; }
bool getMaxDisableMove() const { return *resource.max_disable_move; } bool getMaxDisableMove() const { return *resource.max_disable_move; }

View file

@ -83,6 +83,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm,
const std::string& scrname, const std::string& scrname,
const std::string& altscrname): const std::string& altscrname):
opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"), opaque_move(rm, true, scrname + ".opaqueMove", altscrname+".OpaqueMove"),
opaque_resize(rm, false, scrname + ".opaqueResize", altscrname+".OpaqueResize"),
full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"), full_max(rm, false, scrname+".fullMaximization", altscrname+".FullMaximization"),
max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"), max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"),
max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"), max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"),
@ -110,6 +111,7 @@ ScreenResource::ScreenResource(FbTk::ResourceManager& rm,
clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"), clientmenu_use_pixmap(rm, true, scrname+".clientMenu.usePixmap", altscrname+".ClientMenu.UsePixmap"),
tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"), tabs_use_pixmap(rm, true, scrname+".tabs.usePixmap", altscrname+".Tabs.UsePixmap"),
max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"), max_over_tabs(rm, false, scrname+".tabs.maxOver", altscrname+".Tabs.MaxOver"),
default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar") { default_internal_tabs(rm, true /* TODO: autoconf option? */ , scrname+".tabs.intitlebar", altscrname+".Tabs.InTitlebar"),
opaque_resize_delay(rm, 50, scrname + ".opaqueResizeDelay", altscrname+".OpaqueResizeDelay") {
} }

View file

@ -32,6 +32,7 @@ struct ScreenResource {
const std::string &scrname, const std::string &altscrname); const std::string &scrname, const std::string &altscrname);
FbTk::Resource<bool> opaque_move, FbTk::Resource<bool> opaque_move,
opaque_resize,
full_max, full_max,
max_ignore_inc, max_ignore_inc,
max_disable_move, max_disable_move,
@ -61,6 +62,7 @@ struct ScreenResource {
FbTk::Resource<bool> tabs_use_pixmap; FbTk::Resource<bool> tabs_use_pixmap;
FbTk::Resource<bool> max_over_tabs; FbTk::Resource<bool> max_over_tabs;
FbTk::Resource<bool> default_internal_tabs; FbTk::Resource<bool> default_internal_tabs;
FbTk::Resource<unsigned int> opaque_resize_delay;
}; };
#endif #endif

View file

@ -449,6 +449,12 @@ void FluxboxWindow::init() {
m_tabActivationTimer.setCommand(activate_tab_cmd); m_tabActivationTimer.setCommand(activate_tab_cmd);
m_tabActivationTimer.fireOnce(true); m_tabActivationTimer.fireOnce(true);
m_resizeTimer.setTimeout(screen().opaqueResizeDelay() * FbTk::FbTime::IN_MILLISECONDS);
FbTk::RefCount<FbTk::Command<void> > resize_cmd(new FbTk::SimpleCommand<FluxboxWindow>(*this,
&FluxboxWindow::updateResize));
m_resizeTimer.setCommand(resize_cmd);
m_resizeTimer.fireOnce(true);
m_reposLabels_timer.setTimeout(IconButton::updateLaziness()); m_reposLabels_timer.setTimeout(IconButton::updateLaziness());
m_reposLabels_timer.fireOnce(true); m_reposLabels_timer.fireOnce(true);
FbTk::RefCount<FbTk::Command<void> > elrs(new FbTk::SimpleCommand<FluxboxWindow>(*this, &FluxboxWindow::emitLabelReposSig)); FbTk::RefCount<FbTk::Command<void> > elrs(new FbTk::SimpleCommand<FluxboxWindow>(*this, &FluxboxWindow::emitLabelReposSig));
@ -2663,36 +2669,36 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
int old_resize_w = m_last_resize_w; int old_resize_w = m_last_resize_w;
int old_resize_h = m_last_resize_h; int old_resize_h = m_last_resize_h;
int dx = me.x - m_button_grab_x; int dx = me.x_root - m_button_grab_x;
int dy = me.y - m_button_grab_y; int dy = me.y_root - m_button_grab_y;
if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM || if (m_resize_corner == LEFTTOP || m_resize_corner == LEFTBOTTOM ||
m_resize_corner == LEFT) { m_resize_corner == LEFT) {
m_last_resize_w = frame().width() - dx; m_last_resize_w = resize_base_w - dx;
m_last_resize_x = frame().x() + dx; m_last_resize_x = resize_base_x + dx;
} }
if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP || if (m_resize_corner == LEFTTOP || m_resize_corner == RIGHTTOP ||
m_resize_corner == TOP) { m_resize_corner == TOP) {
m_last_resize_h = frame().height() - dy; m_last_resize_h = resize_base_h - dy;
m_last_resize_y = frame().y() + dy; m_last_resize_y = resize_base_y + dy;
} }
if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM || if (m_resize_corner == LEFTBOTTOM || m_resize_corner == BOTTOM ||
m_resize_corner == RIGHTBOTTOM) m_resize_corner == RIGHTBOTTOM)
m_last_resize_h = frame().height() + dy; m_last_resize_h = resize_base_h + dy;
if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP || if (m_resize_corner == RIGHTBOTTOM || m_resize_corner == RIGHTTOP ||
m_resize_corner == RIGHT) m_resize_corner == RIGHT)
m_last_resize_w = frame().width() + dx; m_last_resize_w = resize_base_w + dx;
if (m_resize_corner == CENTER) { if (m_resize_corner == CENTER) {
// dx or dy must be at least 2 // dx or dy must be at least 2
if (abs(dx) >= 2 || abs(dy) >= 2) { if (abs(dx) >= 2 || abs(dy) >= 2) {
// take max and make it even // take max and make it even
int diff = 2 * (max(dx, dy) / 2); int diff = 2 * (max(dx, dy) / 2);
m_last_resize_h = frame().height() + diff; m_last_resize_h = resize_base_h + diff;
m_last_resize_w = frame().width() + diff; m_last_resize_w = resize_base_w + diff;
m_last_resize_x = frame().x() - diff/2; m_last_resize_x = resize_base_x - diff/2;
m_last_resize_y = frame().y() - diff/2; m_last_resize_y = resize_base_y - diff/2;
} }
} }
@ -2780,18 +2786,23 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) {
} }
} }
// draw over old rect if (m_last_resize_w != old_resize_w || m_last_resize_h != old_resize_h) {
parent().drawRectangle(screen().rootTheme()->opGC(), if (screen().doOpaqueResize()) {
old_resize_x, old_resize_y, m_resizeTimer.start();
old_resize_w - 1 + 2 * frame().window().borderWidth(), } else {
old_resize_h - 1 + 2 * frame().window().borderWidth()); // draw over old rect
parent().drawRectangle(screen().rootTheme()->opGC(),
// draw resize rectangle old_resize_x, old_resize_y,
parent().drawRectangle(screen().rootTheme()->opGC(), old_resize_w - 1 + 2 * frame().window().borderWidth(),
m_last_resize_x, m_last_resize_y, old_resize_h - 1 + 2 * frame().window().borderWidth());
m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
m_last_resize_h - 1 + 2 * frame().window().borderWidth());
// draw resize rectangle
parent().drawRectangle(screen().rootTheme()->opGC(),
m_last_resize_x, m_last_resize_y,
m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
m_last_resize_h - 1 + 2 * frame().window().borderWidth());
}
}
} }
} }
} }
@ -3320,29 +3331,33 @@ void FluxboxWindow::startResizing(int x, int y, ReferenceCorner dir) {
false, ButtonMotionMask | ButtonReleaseMask, false, ButtonMotionMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime);
m_button_grab_x = x; m_button_grab_x = x + frame().x();
m_button_grab_y = y; m_button_grab_y = y + frame().y();
m_last_resize_x = frame().x(); resize_base_x = m_last_resize_x = frame().x();
m_last_resize_y = frame().y(); resize_base_y = m_last_resize_y = frame().y();
m_last_resize_w = frame().width(); resize_base_w = m_last_resize_w = frame().width();
m_last_resize_h = frame().height(); resize_base_h = m_last_resize_h = frame().height();
fixSize(); fixSize();
frame().displaySize(m_last_resize_w, m_last_resize_h); frame().displaySize(m_last_resize_w, m_last_resize_h);
parent().drawRectangle(screen().rootTheme()->opGC(), if (!screen().doOpaqueResize()) {
parent().drawRectangle(screen().rootTheme()->opGC(),
m_last_resize_x, m_last_resize_y, m_last_resize_x, m_last_resize_y,
m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
m_last_resize_h - 1 + 2 * frame().window().borderWidth()); m_last_resize_h - 1 + 2 * frame().window().borderWidth());
}
} }
void FluxboxWindow::stopResizing(bool interrupted) { void FluxboxWindow::stopResizing(bool interrupted) {
resizing = false; resizing = false;
parent().drawRectangle(screen().rootTheme()->opGC(), if (!screen().doOpaqueResize()) {
parent().drawRectangle(screen().rootTheme()->opGC(),
m_last_resize_x, m_last_resize_y, m_last_resize_x, m_last_resize_y,
m_last_resize_w - 1 + 2 * frame().window().borderWidth(), m_last_resize_w - 1 + 2 * frame().window().borderWidth(),
m_last_resize_h - 1 + 2 * frame().window().borderWidth()); m_last_resize_h - 1 + 2 * frame().window().borderWidth());
}
screen().hideGeometry(); screen().hideGeometry();

View file

@ -528,6 +528,7 @@ private:
void moveResizeClient(WinClient &client); void moveResizeClient(WinClient &client);
/// sends configurenotify to all clients /// sends configurenotify to all clients
void sendConfigureNotify(); void sendConfigureNotify();
void updateResize() { moveResize(m_last_resize_x, m_last_resize_y, m_last_resize_w, m_last_resize_h); }
static void grabPointer(Window grab_window, static void grabPointer(Window grab_window,
Bool owner_events, Bool owner_events,
@ -553,6 +554,7 @@ private:
uint64_t m_last_keypress_time; uint64_t m_last_keypress_time;
FbTk::Timer m_timer; FbTk::Timer m_timer;
FbTk::Timer m_tabActivationTimer; FbTk::Timer m_tabActivationTimer;
FbTk::Timer m_resizeTimer;
// Window states // Window states
bool moving, resizing, m_initialized; bool moving, resizing, m_initialized;
@ -565,6 +567,7 @@ private:
int m_last_resize_x, m_last_resize_y; // handles last button press event for resize int m_last_resize_x, m_last_resize_y; // handles last button press event for resize
int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving int m_last_move_x, m_last_move_y; // handles last pos for non opaque moving
int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window" int m_last_resize_h, m_last_resize_w; // handles height/width for resize "window"
int resize_base_x, resize_base_y, resize_base_w, resize_base_h; // opaque and transparent resize alignment
int m_last_pressed_button; int m_last_pressed_button;
unsigned int m_workspace_number; unsigned int m_workspace_number;