Index: uspace/srv/hid/display/window.c
===================================================================
--- uspace/srv/hid/display/window.c	(revision 0b7e394d99939661ce387bc7b8b283491437ef4d)
+++ uspace/srv/hid/display/window.c	(revision 76a02db7e731b87168f35adc71ee97a16e324e30)
@@ -405,16 +405,15 @@
  *
  * @param wnd Window
- * @param event Button press event
- */
-static void ds_window_start_move(ds_window_t *wnd, pos_event_t *event)
+ * @param pos Position where mouse button was pressed
+ */
+static void ds_window_start_move(ds_window_t *wnd, gfx_coord2_t *pos)
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_move (%d, %d)",
-	    (int) event->hpos, (int) event->vpos);
+	    (int) pos->x, (int) pos->y);
 
 	if (wnd->state != dsw_idle)
 		return;
 
-	wnd->orig_pos.x = event->hpos;
-	wnd->orig_pos.y = event->vpos;
+	wnd->orig_pos = *pos;
 	wnd->state = dsw_moving;
 }
@@ -423,21 +422,18 @@
  *
  * @param wnd Window
- * @param event Button release event
- */
-static void ds_window_finish_move(ds_window_t *wnd, pos_event_t *event)
-{
-	gfx_coord2_t pos;
+ * @param pos Position where mouse button was released
+ */
+static void ds_window_finish_move(ds_window_t *wnd, gfx_coord2_t *pos)
+{
 	gfx_coord2_t dmove;
 	gfx_coord2_t nwpos;
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_move (%d, %d)",
-	    (int) event->hpos, (int) event->vpos);
+	    (int) pos->x, (int) pos->y);
 
 	if (wnd->state != dsw_moving)
 		return;
 
-	pos.x = event->hpos;
-	pos.y = event->vpos;
-	gfx_coord2_subtract(&pos, &wnd->orig_pos, &dmove);
+	gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
 
 	gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
@@ -451,9 +447,8 @@
  *
  * @param wnd Window
- * @param event Position update event
- */
-static void ds_window_update_move(ds_window_t *wnd, pos_event_t *event)
-{
-	gfx_coord2_t pos;
+ * @param pos Current mouse position
+ */
+static void ds_window_update_move(ds_window_t *wnd, gfx_coord2_t *pos)
+{
 	gfx_coord2_t dmove;
 	gfx_coord2_t nwpos;
@@ -464,5 +459,5 @@
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_move (%d, %d)",
-	    (int) event->hpos, (int) event->vpos);
+	    (int) pos->x, (int) pos->y);
 
 	if (wnd->state != dsw_moving)
@@ -477,12 +472,10 @@
 	}
 
-	pos.x = event->hpos;
-	pos.y = event->vpos;
-	gfx_coord2_subtract(&pos, &wnd->orig_pos, &dmove);
+	gfx_coord2_subtract(pos, &wnd->orig_pos, &dmove);
 
 	gfx_coord2_add(&wnd->dpos, &dmove, &nwpos);
 	gfx_rect_translate(&nwpos, &wnd->rect, &drect);
 
-	wnd->orig_pos = pos;
+	wnd->orig_pos = *pos;
 	wnd->dpos = nwpos;
 
@@ -500,17 +493,36 @@
 }
 
+/** Start resizing a window by mouse drag.
+ *
+ * @param wnd Window
+ * @param rsztype Resize type (which part of window is being dragged)
+ * @param pos Position where mouse button was pressed
+ */
+static void ds_window_start_resize(ds_window_t *wnd,
+    display_wnd_rsztype_t rsztype, gfx_coord2_t *pos)
+{
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_start_resize (%d, %d)",
+	    (int) pos->x, (int) pos->y);
+
+	if (wnd->state != dsw_idle)
+		return;
+
+	wnd->orig_pos = *pos;
+	wnd->state = dsw_resizing;
+	wnd->rsztype = rsztype;
+}
+
 /** Finish resizing a window by mouse drag.
  *
  * @param wnd Window
- * @param event Button release event
- */
-static void ds_window_finish_resize(ds_window_t *wnd, pos_event_t *event)
-{
-	gfx_coord2_t pos;
+ * @param pos Position where mouse button was released
+ */
+static void ds_window_finish_resize(ds_window_t *wnd, gfx_coord2_t *pos)
+{
 	gfx_coord2_t dresize;
 	gfx_rect_t nrect;
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_finish_resize (%d, %d)",
-	    (int) event->hpos, (int) event->vpos);
+	    (int) pos->x, (int) pos->y);
 
 	if (wnd->state != dsw_resizing)
@@ -519,7 +531,5 @@
 	(void) ds_display_paint(wnd->display, NULL);
 
-	pos.x = event->hpos;
-	pos.y = event->vpos;
-	gfx_coord2_subtract(&pos, &wnd->orig_pos, &dresize);
+	gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
 
 	/* Compute new rectangle */
@@ -533,9 +543,8 @@
  *
  * @param wnd Window
- * @param event Position update event
- */
-static void ds_window_update_resize(ds_window_t *wnd, pos_event_t *event)
-{
-	gfx_coord2_t pos;
+ * @param pos Current mouse position
+ */
+static void ds_window_update_resize(ds_window_t *wnd, gfx_coord2_t *pos)
+{
 	gfx_coord2_t dresize;
 	gfx_rect_t nrect;
@@ -546,5 +555,5 @@
 
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_update_resize (%d, %d)",
-	    (int) event->hpos, (int) event->vpos);
+	    (int) pos->x, (int) pos->y);
 
 	if (wnd->state != dsw_resizing)
@@ -559,7 +568,5 @@
 	}
 
-	pos.x = event->hpos;
-	pos.y = event->vpos;
-	gfx_coord2_subtract(&pos, &wnd->orig_pos, &dresize);
+	gfx_coord2_subtract(pos, &wnd->orig_pos, &dresize);
 
 	ds_window_calc_resize(wnd, &dresize, &nrect);
@@ -623,14 +630,14 @@
 
 	if (event->type == POS_PRESS && event->btn_num == 2 && inside)
-		ds_window_start_move(wnd, event);
+		ds_window_start_move(wnd, &pos);
 
 	if (event->type == POS_RELEASE) {
-		ds_window_finish_move(wnd, event);
-		ds_window_finish_resize(wnd, event);
+		ds_window_finish_move(wnd, &pos);
+		ds_window_finish_resize(wnd, &pos);
 	}
 
 	if (event->type == POS_UPDATE) {
-		ds_window_update_move(wnd, event);
-		ds_window_update_resize(wnd, event);
+		ds_window_update_move(wnd, &pos);
+		ds_window_update_resize(wnd, &pos);
 	}
 
@@ -674,12 +681,11 @@
 void ds_window_move_req(ds_window_t *wnd, gfx_coord2_t *pos)
 {
+	gfx_coord2_t orig_pos;
+
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ds_window_move_req (%d, %d)",
 	    (int) pos->x, (int) pos->y);
 
-	if (wnd->state != dsw_idle)
-		return;
-
-	gfx_coord2_add(&wnd->dpos, pos, &wnd->orig_pos);
-	wnd->state = dsw_moving;
+	gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
+	ds_window_start_move(wnd, &orig_pos);
 }
 
@@ -705,13 +711,11 @@
     gfx_coord2_t *pos)
 {
+	gfx_coord2_t orig_pos;
+
 	log_msg(LOG_DEFAULT, LVL_NOTE, "ds_window_resize_req (%d, %d, %d)",
 	    (int) rsztype, (int) pos->x, (int) pos->y);
 
-	if (wnd->state != dsw_idle)
-		return;
-
-	gfx_coord2_add(&wnd->dpos, pos, &wnd->orig_pos);
-	wnd->state = dsw_resizing;
-	wnd->rsztype = rsztype;
+	gfx_coord2_add(&wnd->dpos, pos, &orig_pos);
+	ds_window_start_resize(wnd, rsztype, &orig_pos);
 }
 
