2 * ion/ioncore/presize.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
22 static int p_dx1mul=0, p_dx2mul=0, p_dy1mul=0, p_dy2mul=0;
28 void window_p_resize_prepare(WWindow *wwin, XButtonEvent *ev)
30 int ww=REGION_GEOM(wwin).w/2;
31 int hh=REGION_GEOM(wwin).h/2;
33 int tmpx, tmpy, atmpx, atmpy;
47 if(xdiv<MINCORNER && xdiv>1){
53 if(ydiv<MINCORNER && ydiv>1){
61 }else if(hh*atmpx/xdiv>=tmpy && -hh*atmpx/xdiv<=tmpy){
68 }else if(ww*atmpy/ydiv>=tmpx && -ww*atmpy/ydiv<=tmpx){
75 static void p_moveres_end(WWindow *wwin, XButtonEvent *ev)
77 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
79 moveresmode_do_end(mode, TRUE);
83 static void p_moveres_cancel(WWindow *wwin)
85 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
87 moveresmode_do_end(mode, FALSE);
91 static void confine_to_parent(WWindow *wwin)
93 WRegion *par=REGION_PARENT_REG(wwin);
95 ioncore_grab_confine_to(region_xwindow(par));
99 static void p_resize_motion(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
101 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
103 moveresmode_delta_resize(mode, p_dx1mul*dx, p_dx2mul*dx,
104 p_dy1mul*dy, p_dy2mul*dy, NULL);
109 static void p_resize_begin(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
111 region_begin_resize((WRegion*)wwin, NULL, TRUE);
112 p_resize_motion(wwin, ev, dx, dy);
117 * Start resizing \var{wwin} with the mouse or other pointing device.
118 * This function should only be used by binding it to \emph{mpress} or
119 * \emph{mdrag} action.
122 void window_p_resize(WWindow *wwin)
124 if(!ioncore_set_drag_handlers((WRegion*)wwin,
125 (WMotionHandler*)p_resize_begin,
126 (WMotionHandler*)p_resize_motion,
127 (WButtonHandler*)p_moveres_end,
129 (GrabKilledHandler*)p_moveres_cancel))
132 confine_to_parent(wwin);
142 static void p_move_motion(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
144 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
146 moveresmode_delta_move(mode, dx, dy, NULL);
150 static void p_move_begin(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
152 region_begin_move((WRegion*)wwin, NULL, TRUE);
153 p_move_motion(wwin, ev, dx, dy);
158 * Start moving \var{wwin} with the mouse or other pointing device.
159 * This function should only be used by binding it to \emph{mpress} or
160 * \emph{mdrag} action.
163 void window_p_move(WWindow *wwin)
165 if(!ioncore_set_drag_handlers((WRegion*)wwin,
166 (WMotionHandler*)p_move_begin,
167 (WMotionHandler*)p_move_motion,
168 (WButtonHandler*)p_moveres_end,
170 (GrabKilledHandler*)p_moveres_cancel))
173 confine_to_parent(wwin);