From 7d5e50bab8a49d67332f2d9e88f5c25b1cb60289 Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Thu, 6 Sep 2001 19:44:06 +0000 Subject: [PATCH] Tune electric borders... svn path=/trunk/kdebase/kwin/; revision=113523 --- options.cpp | 10 +++++++++- options.h | 5 +++++ workspace.cpp | 11 ++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/options.cpp b/options.cpp index 6bec759825..a82a44deb4 100644 --- a/options.cpp +++ b/options.cpp @@ -20,7 +20,8 @@ class OptionsPrivate { public: OptionsPrivate() : title_buttons_left( "MS" ), title_buttons_right( "HIAX" ), - custom_button_positions( false ), electric_borders( false ) {}; + custom_button_positions( false ), electric_borders( false ), + electric_border_delay(0) {}; QColor colors[KWINCOLORS*2]; QColorGroup *cg[KWINCOLORS*2]; QString title_buttons_left; @@ -30,6 +31,7 @@ public: bool fade_tooltips; bool animate_tooltips; bool electric_borders; + int electric_border_delay; }; }; @@ -220,6 +222,7 @@ void Options::reload() windowSnapZone = config->readNumEntry("WindowSnapZone", 10); snapOnlyWhenOverlapping=config->readBoolEntry("SnapOnlyWhenOverlapping",FALSE); d->electric_borders = config->readBoolEntry("ElectricBorders", false); + d->electric_border_delay = config->readNumEntry("ElectricBorderDelay", 150); OpTitlebarDblClick = windowOperation( config->readEntry("TitlebarDoubleClickCommand", "Shade") ); @@ -357,5 +360,10 @@ bool Options::electricBorders() return d->electric_borders; } +int Options::electricBorderDelay() +{ + return d->electric_border_delay; +} + #include "options.moc" diff --git a/options.h b/options.h index 89cac29a32..eaadf5deac 100644 --- a/options.h +++ b/options.h @@ -316,6 +316,11 @@ public: */ bool electricBorders(); + /** + * @returns the activation delay for electric borders in milliseconds. + */ + int electricBorderDelay(); + public slots: void reload(); diff --git a/workspace.cpp b/workspace.cpp index 27f412441e..e0d5d67d1e 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -116,6 +116,7 @@ public: WId electric_right_border; Time electric_time_first; Time electric_time_last; + QPoint electric_push_point; Client *movingClient; }; @@ -4215,11 +4216,14 @@ void Workspace::electricBorder(XEvent *e) { Window border = e->xcrossing.window; Time now = e->xcrossing.time; - int treshold_set = 150; // set timeout - int treshold_reset = 150; // reset timeout + int treshold_set = options->electricBorderDelay(); // set timeout + int treshold_reset = 250; // reset timeout + int distance_reset = 10; // Mouse should not move more than this many pixels + QPoint p(e->xcrossing.x_root, e->xcrossing.y_root); if ((d->electric_current_border == border) && - (TimeDiff(d->electric_time_last, now) < treshold_reset)) + (TimeDiff(d->electric_time_last, now) < treshold_reset) && + ((p-d->electric_push_point).manhattanLength() < distance_reset)) { d->electric_time_last = now; @@ -4257,6 +4261,7 @@ void Workspace::electricBorder(XEvent *e) d->electric_current_border = border; d->electric_time_first = now; d->electric_time_last = now; + d->electric_push_point = p; } int mouse_warp = 1;