aboutsummaryrefslogtreecommitdiff
path: root/dw/layout.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2012-11-06 12:27:39 +0100
committerSebastian Geerken <devnull@localhost>2012-11-06 12:27:39 +0100
commit2b5f65a0354aca9496373a55b4cfb5286c1b041c (patch)
treea984d6ff9d9b0941293cd5295fffc8ad64b22cf4 /dw/layout.cc
parent163ea78f0fe31ed999d94407c780af7efa520b68 (diff)
parent2e217082100a213c5d716d84dbf696826de64379 (diff)
Merge.
Diffstat (limited to 'dw/layout.cc')
-rw-r--r--dw/layout.cc39
1 files changed, 34 insertions, 5 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index d2610687..89cdf9a6 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -774,7 +774,7 @@ bool Layout::buttonEvent (ButtonEventType type, View *view, int numPressed,
event.button = button;
event.numPressed = numPressed;
- return processMouseEvent (&event, type, true);
+ return processMouseEvent (&event, type);
}
/**
@@ -793,7 +793,7 @@ bool Layout::motionNotify (View *view, int x, int y, ButtonState state)
event.yCanvas = y;
event.state = state;
- return processMouseEvent (&event, MOTION_NOTIFY, true);
+ return processMouseEvent (&event, MOTION_NOTIFY);
}
/**
@@ -946,12 +946,41 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state)
* has been called before.
*/
bool Layout::processMouseEvent (MousePositionEvent *event,
- ButtonEventType type, bool mayBeSuppressed)
+ ButtonEventType type)
{
Widget *widget;
- for (widget = widgetAtPoint; widget; widget = widget->getParent ()) {
- if (!mayBeSuppressed || widget->isButtonSensitive ()) {
+ /*
+ * If the event is outside of the visible region of the canvas, treat it
+ * as occurring at the region's edge. Notably, this helps when selecting
+ * text.
+ */
+ if (event->xCanvas < scrollX)
+ event->xCanvas = scrollX;
+ else {
+ int actualVScrollbarThickness =
+ canvasAscent + canvasDescent > viewportHeight ? vScrollbarThickness:0;
+ int maxX = scrollX + viewportWidth - actualVScrollbarThickness - 1;
+
+ if (event->xCanvas > maxX)
+ event->xCanvas = maxX;
+ }
+ if (event->yCanvas < scrollY)
+ event->yCanvas = scrollY;
+ else {
+ int actualHScrollbarThickness =
+ (canvasWidth > viewportWidth) ? hScrollbarThickness : 0;
+ int maxY = misc::min(scrollY + viewportHeight -actualHScrollbarThickness,
+ canvasAscent + canvasDescent) - 1;
+
+ if (event->yCanvas > maxY)
+ event->yCanvas = maxY;
+ }
+
+ widget = getWidgetAtPoint(event->xCanvas, event->yCanvas);
+
+ for (; widget; widget = widget->getParent ()) {
+ if (widget->isButtonSensitive ()) {
event->xWidget = event->xCanvas - widget->getAllocation()->x;
event->yWidget = event->yCanvas - widget->getAllocation()->y;