2 * ion/ioncore/presize.c
4 * Copyright (c) Tuomo Valkonen 1999-2008.
6 * See the included file LICENSE for details.
19 static int p_dx1mul=0, p_dx2mul=0, p_dy1mul=0, p_dy2mul=0;
25 void window_p_resize_prepare(WWindow *wwin, XButtonEvent *ev)
27 int ww=REGION_GEOM(wwin).w/2;
28 int hh=REGION_GEOM(wwin).h/2;
30 int tmpx, tmpy, atmpx, atmpy;
44 if(xdiv<MINCORNER && xdiv>1){
50 if(ydiv<MINCORNER && ydiv>1){
58 }else if(hh*atmpx/xdiv>=tmpy && -hh*atmpx/xdiv<=tmpy){
65 }else if(ww*atmpy/ydiv>=tmpx && -ww*atmpy/ydiv<=tmpx){
72 static void p_moveres_end(WWindow *wwin, XButtonEvent *ev)
74 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
76 moveresmode_do_end(mode, TRUE);
80 static void p_moveres_cancel(WWindow *wwin)
82 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
84 moveresmode_do_end(mode, FALSE);
88 static void confine_to_parent(WWindow *wwin)
90 WRegion *par=REGION_PARENT_REG(wwin);
92 ioncore_grab_confine_to(region_xwindow(par));
96 static void p_resize_motion(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
98 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
100 moveresmode_delta_resize(mode, p_dx1mul*dx, p_dx2mul*dx,
101 p_dy1mul*dy, p_dy2mul*dy, NULL);
106 static void p_resize_begin(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
108 region_begin_resize((WRegion*)wwin, NULL, TRUE);
109 p_resize_motion(wwin, ev, dx, dy);
114 * Start resizing \var{wwin} with the mouse or other pointing device.
115 * This function should only be used by binding it to \emph{mpress} or
116 * \emph{mdrag} action.
119 void window_p_resize(WWindow *wwin)
121 if(!ioncore_set_drag_handlers((WRegion*)wwin,
122 (WMotionHandler*)p_resize_begin,
123 (WMotionHandler*)p_resize_motion,
124 (WButtonHandler*)p_moveres_end,
126 (GrabKilledHandler*)p_moveres_cancel))
129 confine_to_parent(wwin);
139 static void p_move_motion(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
141 WMoveresMode *mode=moveres_mode((WRegion*)wwin);
143 moveresmode_delta_move(mode, dx, dy, NULL);
147 static void p_move_begin(WWindow *wwin, XMotionEvent *ev, int dx, int dy)
149 region_begin_move((WRegion*)wwin, NULL, TRUE);
150 p_move_motion(wwin, ev, dx, dy);
155 * Start moving \var{wwin} with the mouse or other pointing device.
156 * This function should only be used by binding it to \emph{mpress} or
157 * \emph{mdrag} action.
160 void window_p_move(WWindow *wwin)
162 if(!ioncore_set_drag_handlers((WRegion*)wwin,
163 (WMotionHandler*)p_move_begin,
164 (WMotionHandler*)p_move_motion,
165 (WButtonHandler*)p_moveres_end,
167 (GrabKilledHandler*)p_moveres_cancel))
170 confine_to_parent(wwin);