2007-11-13 22:57:57 +01:00
|
|
|
/*
|
|
|
|
* mouse.c - mouse managing
|
|
|
|
*
|
2008-03-15 09:10:32 +01:00
|
|
|
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
|
2007-11-13 22:57:57 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-12-28 17:37:41 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2007-11-13 22:57:57 +01:00
|
|
|
#include "mouse.h"
|
|
|
|
#include "screen.h"
|
|
|
|
#include "tag.h"
|
|
|
|
#include "event.h"
|
2008-01-01 17:25:48 +01:00
|
|
|
#include "client.h"
|
2008-03-25 14:56:38 +01:00
|
|
|
#include "titlebar.h"
|
2007-11-13 22:57:57 +01:00
|
|
|
#include "layouts/floating.h"
|
2007-12-28 17:11:20 +01:00
|
|
|
#include "layouts/tile.h"
|
2008-03-13 09:05:34 +01:00
|
|
|
#include "common/xscreen.h"
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2008-03-25 14:41:06 +01:00
|
|
|
#define MOUSEMASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
|
2008-01-29 08:23:20 +01:00
|
|
|
|
2007-12-19 04:46:44 +01:00
|
|
|
extern AwesomeConf globalconf;
|
2007-12-16 02:45:38 +01:00
|
|
|
|
2008-03-25 15:24:45 +01:00
|
|
|
static area_t
|
|
|
|
mouse_snapclienttogeometry_outside(area_t geometry, area_t snap_geometry, int snap)
|
|
|
|
{
|
|
|
|
if(geometry.x < snap + snap_geometry.x + snap_geometry.width
|
|
|
|
&& geometry.x > snap_geometry.x + snap_geometry.width)
|
|
|
|
geometry.x = snap_geometry.x + snap_geometry.width;
|
|
|
|
else if(geometry.x + geometry.width < snap_geometry.x
|
|
|
|
&& geometry.x + geometry.width > snap_geometry.x - snap)
|
|
|
|
geometry.x = snap_geometry.x - geometry.width;
|
|
|
|
|
|
|
|
|
|
|
|
if(geometry.y < snap + snap_geometry.y + snap_geometry.height
|
|
|
|
&& geometry.y > snap_geometry.y + snap_geometry.height)
|
|
|
|
geometry.y = snap_geometry.y + snap_geometry.height;
|
|
|
|
else if(geometry.y + geometry.height < snap_geometry.y
|
|
|
|
&& geometry.y + geometry.height > snap_geometry.y - snap)
|
|
|
|
geometry.y = snap_geometry.y - geometry.height;
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static area_t
|
|
|
|
mouse_snapclienttogeometry_inside(area_t geometry, area_t snap_geometry, int snap)
|
|
|
|
{
|
|
|
|
if(abs(geometry.x) < snap + snap_geometry.x && geometry.x > snap_geometry.x)
|
|
|
|
geometry.x = snap_geometry.x;
|
|
|
|
else if(abs((snap_geometry.x + snap_geometry.width) - (geometry.x + geometry.width))
|
|
|
|
< snap)
|
|
|
|
geometry.x = snap_geometry.x + snap_geometry.width - geometry.width;
|
|
|
|
if(abs(geometry.y) < snap + snap_geometry.y && geometry.y > snap_geometry.y)
|
|
|
|
geometry.y = snap_geometry.y;
|
|
|
|
else if(abs((snap_geometry.y + snap_geometry.height) - (geometry.y + geometry.height))
|
|
|
|
< snap)
|
|
|
|
geometry.y = snap_geometry.y + snap_geometry.height - geometry.height;
|
|
|
|
|
|
|
|
return geometry;
|
|
|
|
}
|
|
|
|
|
2008-03-25 14:41:06 +01:00
|
|
|
static area_t
|
|
|
|
mouse_snapclient(Client *c, area_t geometry)
|
|
|
|
{
|
2008-03-25 15:24:45 +01:00
|
|
|
Client *snapper;
|
2008-03-25 14:41:06 +01:00
|
|
|
int snap = globalconf.screens[c->screen].snap;
|
2008-03-25 15:24:45 +01:00
|
|
|
area_t snapper_geometry;
|
2008-03-25 14:41:06 +01:00
|
|
|
area_t screen_geometry =
|
|
|
|
screen_get_area(c->screen,
|
|
|
|
globalconf.screens[c->screen].statusbar,
|
|
|
|
&globalconf.screens[c->screen].padding);
|
|
|
|
|
2008-03-25 14:56:38 +01:00
|
|
|
geometry = titlebar_geometry_add(&c->titlebar, geometry);
|
2008-03-25 15:24:45 +01:00
|
|
|
geometry.width += 2 * c->border;
|
|
|
|
geometry.height += 2 * c->border;
|
2008-03-25 14:56:38 +01:00
|
|
|
|
2008-03-25 15:24:45 +01:00
|
|
|
geometry =
|
|
|
|
mouse_snapclienttogeometry_inside(geometry, screen_geometry, snap);
|
|
|
|
|
|
|
|
for(snapper = globalconf.clients; snapper; snapper = snapper->next)
|
|
|
|
if(snapper != c && client_isvisible(c, c->screen))
|
|
|
|
{
|
|
|
|
snapper_geometry = snapper->geometry;
|
|
|
|
snapper_geometry.width += 2 * c->border;
|
|
|
|
snapper_geometry.height += 2 * c->border;
|
|
|
|
snapper_geometry = titlebar_geometry_add(&snapper->titlebar,
|
|
|
|
snapper_geometry);
|
|
|
|
geometry =
|
|
|
|
mouse_snapclienttogeometry_outside(geometry,
|
|
|
|
snapper_geometry,
|
|
|
|
snap);
|
|
|
|
}
|
2008-03-25 14:41:06 +01:00
|
|
|
|
2008-03-25 15:24:45 +01:00
|
|
|
geometry.width -= 2 * c->border;
|
|
|
|
geometry.height -= 2 * c->border;
|
2008-03-25 14:56:38 +01:00
|
|
|
return titlebar_geometry_remove(&c->titlebar, geometry);
|
2008-03-25 14:41:06 +01:00
|
|
|
}
|
|
|
|
|
2008-03-25 16:10:12 +01:00
|
|
|
static void
|
2008-04-04 10:36:28 +02:00
|
|
|
mouse_resizebar_draw(DrawCtx *ctx, style_t style, SimpleWindow *sw, area_t geometry, int border)
|
2008-03-25 16:10:12 +01:00
|
|
|
{
|
|
|
|
area_t draw_geometry = { 0, 0, ctx->width, ctx->height, NULL, NULL };
|
|
|
|
char size[64];
|
|
|
|
|
|
|
|
snprintf(size, sizeof(size), "%dx%d+%d+%d",
|
|
|
|
geometry.x, geometry.y, geometry.width, geometry.height);
|
|
|
|
draw_text(ctx, draw_geometry, AlignCenter, style.font->height / 2, size, style);
|
|
|
|
simplewindow_move(sw,
|
|
|
|
geometry.x + ((2 * border + geometry.width) - sw->geometry.width) / 2,
|
|
|
|
geometry.y + ((2 * border + geometry.height) - sw->geometry.height) / 2);
|
|
|
|
simplewindow_refresh_drawable(sw, sw->phys_screen);
|
|
|
|
}
|
|
|
|
|
2008-04-08 09:45:48 +02:00
|
|
|
/** Move client with the mouse.
|
2007-12-19 04:39:59 +01:00
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg Unused
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-11-13 22:57:57 +01:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
|
2007-11-13 22:57:57 +01:00
|
|
|
{
|
2008-03-21 10:53:17 +01:00
|
|
|
int x, y, ocx, ocy, di, newscreen;
|
2007-11-13 22:57:57 +01:00
|
|
|
unsigned int dui;
|
2008-01-28 10:37:47 +01:00
|
|
|
Window dummy, child;
|
2007-11-13 22:57:57 +01:00
|
|
|
XEvent ev;
|
2008-03-25 14:41:06 +01:00
|
|
|
area_t geometry;
|
2008-01-28 10:37:47 +01:00
|
|
|
Client *c = globalconf.focus->client, *target;
|
2008-02-12 10:09:36 +01:00
|
|
|
Layout *layout = layout_get_current(screen);
|
2008-03-25 16:10:12 +01:00
|
|
|
SimpleWindow *sw = NULL;
|
|
|
|
DrawCtx *ctx;
|
|
|
|
style_t style;
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2008-03-25 16:10:12 +01:00
|
|
|
if(!c
|
|
|
|
|| XGrabPointer(globalconf.display,
|
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
|
|
|
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
|
|
|
globalconf.cursor[CurMove], CurrentTime) != GrabSuccess)
|
2007-11-13 22:57:57 +01:00
|
|
|
return;
|
|
|
|
|
2007-12-27 23:10:43 +01:00
|
|
|
XQueryPointer(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
2008-01-28 10:37:47 +01:00
|
|
|
&dummy, &dummy, &x, &y, &di, &di, &dui);
|
2008-03-25 16:10:12 +01:00
|
|
|
|
|
|
|
geometry = c->geometry;
|
|
|
|
ocx = geometry.x;
|
|
|
|
ocy = geometry.y;
|
2007-12-27 23:50:19 +01:00
|
|
|
c->ismax = False;
|
2008-03-25 16:10:12 +01:00
|
|
|
|
2008-03-28 13:22:26 +01:00
|
|
|
style = globalconf.screens[c->screen].styles.focus;
|
|
|
|
|
2008-03-25 16:10:12 +01:00
|
|
|
if(c->isfloating || layout->arrange == layout_floating)
|
|
|
|
{
|
|
|
|
sw = simplewindow_new(globalconf.display, c->phys_screen, 0, 0,
|
|
|
|
draw_textwidth(globalconf.display,
|
|
|
|
globalconf.screens[c->screen].styles.focus.font,
|
|
|
|
"0000x0000+0000+0000") + style.font->height,
|
|
|
|
1.5 * style.font->height, 0);
|
|
|
|
|
|
|
|
ctx = draw_context_new(globalconf.display, sw->phys_screen,
|
|
|
|
sw->geometry.width, sw->geometry.height,
|
|
|
|
sw->drawable);
|
|
|
|
XMapRaised(globalconf.display, sw->window);
|
2008-04-04 10:36:28 +02:00
|
|
|
mouse_resizebar_draw(ctx, style, sw, geometry, c->border);
|
2008-03-25 16:10:12 +01:00
|
|
|
}
|
|
|
|
|
2007-11-13 22:57:57 +01:00
|
|
|
for(;;)
|
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
switch (ev.type)
|
|
|
|
{
|
2008-01-28 10:37:47 +01:00
|
|
|
case ButtonRelease:
|
2007-12-27 23:10:43 +01:00
|
|
|
XUngrabPointer(globalconf.display, CurrentTime);
|
2008-03-25 16:10:12 +01:00
|
|
|
if(sw)
|
|
|
|
{
|
|
|
|
draw_context_delete(&ctx);
|
|
|
|
simplewindow_delete(&sw);
|
|
|
|
}
|
2007-11-13 22:57:57 +01:00
|
|
|
return;
|
2008-01-28 10:37:47 +01:00
|
|
|
case ConfigureRequest:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_configurerequest(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case Expose:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_expose(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case MapRequest:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_maprequest(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case EnterNotify:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_enternotify(&ev);
|
2008-01-28 10:37:47 +01:00
|
|
|
break;
|
|
|
|
case MotionNotify:
|
|
|
|
if(c->isfloating || layout->arrange == layout_floating)
|
|
|
|
{
|
|
|
|
geometry.x = ocx + (ev.xmotion.x - x);
|
|
|
|
geometry.y = ocy + (ev.xmotion.y - y);
|
2008-03-15 15:24:47 +01:00
|
|
|
|
2008-03-25 14:41:06 +01:00
|
|
|
geometry = mouse_snapclient(c, geometry);
|
2008-03-15 15:24:47 +01:00
|
|
|
|
2008-03-17 20:49:34 +01:00
|
|
|
c->ismoving = True;
|
2008-03-16 10:01:55 +01:00
|
|
|
client_resize(c, geometry, False);
|
2008-03-17 20:49:34 +01:00
|
|
|
c->ismoving = False;
|
2008-03-25 16:10:12 +01:00
|
|
|
if(sw)
|
2008-04-04 10:36:28 +02:00
|
|
|
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
2008-01-28 10:37:47 +01:00
|
|
|
}
|
2008-01-28 11:32:55 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
XQueryPointer(globalconf.display,
|
2008-03-21 10:53:17 +01:00
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
2008-01-28 11:32:55 +01:00
|
|
|
&dummy, &child, &x, &y, &di, &di, &dui);
|
2008-03-13 09:28:21 +01:00
|
|
|
if((newscreen = screen_get_bycoord(globalconf.screens_info, c->screen, x, y)) != c->screen)
|
2008-01-28 11:32:55 +01:00
|
|
|
{
|
|
|
|
move_client_to_screen(c, newscreen, True);
|
|
|
|
globalconf.screens[c->screen].need_arrange = True;
|
2008-03-16 17:51:46 +01:00
|
|
|
if(layout_get_current(newscreen)->arrange != layout_floating)
|
|
|
|
globalconf.screens[newscreen].need_arrange = True;
|
2008-01-28 11:32:55 +01:00
|
|
|
layout_refresh();
|
|
|
|
}
|
2008-01-29 08:21:05 +01:00
|
|
|
if((target = client_get_bywin(globalconf.clients, child))
|
2008-02-12 14:39:52 +01:00
|
|
|
&& target != c && !target->isfloating)
|
2008-01-28 11:32:55 +01:00
|
|
|
{
|
|
|
|
client_list_swap(&globalconf.clients, c, target);
|
|
|
|
globalconf.screens[c->screen].need_arrange = True;
|
|
|
|
layout_refresh();
|
|
|
|
}
|
|
|
|
}
|
2008-03-16 17:51:46 +01:00
|
|
|
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-08 09:45:48 +02:00
|
|
|
/** Resize client with the mouse.
|
2007-12-19 04:39:59 +01:00
|
|
|
* \param screen Screen ID
|
|
|
|
* \param arg Unused
|
|
|
|
* \ingroup ui_callback
|
|
|
|
*/
|
2007-11-13 22:57:57 +01:00
|
|
|
void
|
2007-12-17 01:17:54 +01:00
|
|
|
uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
2007-11-13 22:57:57 +01:00
|
|
|
{
|
2008-01-05 20:18:30 +01:00
|
|
|
int ocx = 0, ocy = 0, n;
|
2007-11-13 22:57:57 +01:00
|
|
|
XEvent ev;
|
2007-12-16 02:45:38 +01:00
|
|
|
Client *c = globalconf.focus->client;
|
2008-01-29 08:31:13 +01:00
|
|
|
Tag **curtags = tags_get_current(screen);
|
2008-01-12 23:25:36 +01:00
|
|
|
Layout *layout = curtags[0]->layout;
|
2008-03-28 13:22:26 +01:00
|
|
|
area_t area = { 0, 0, 0, 0, NULL, NULL }, geometry = { 0, 0, 0, 0, NULL, NULL };
|
2007-12-28 17:11:20 +01:00
|
|
|
double mwfact;
|
2008-03-25 16:10:12 +01:00
|
|
|
SimpleWindow *sw = NULL;
|
|
|
|
DrawCtx *ctx = NULL;
|
|
|
|
style_t style;
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2007-12-28 17:11:20 +01:00
|
|
|
/* only handle floating and tiled layouts */
|
2008-03-28 13:22:26 +01:00
|
|
|
if(!c || c->isfixed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
style = globalconf.screens[c->screen].styles.focus;
|
|
|
|
|
|
|
|
if(layout->arrange == layout_floating || c->isfloating)
|
2007-12-28 17:11:20 +01:00
|
|
|
{
|
2008-03-28 13:22:26 +01:00
|
|
|
ocx = c->geometry.x;
|
|
|
|
ocy = c->geometry.y;
|
|
|
|
c->ismax = False;
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2008-03-28 13:22:26 +01:00
|
|
|
sw = simplewindow_new(globalconf.display, c->phys_screen, 0, 0,
|
|
|
|
draw_textwidth(globalconf.display,
|
|
|
|
globalconf.screens[c->screen].styles.focus.font,
|
|
|
|
"0000x0000+0000+0000") + style.font->height,
|
|
|
|
1.5 * style.font->height, 0);
|
2007-11-13 22:57:57 +01:00
|
|
|
|
2008-03-28 13:22:26 +01:00
|
|
|
ctx = draw_context_new(globalconf.display, sw->phys_screen,
|
|
|
|
sw->geometry.width, sw->geometry.height,
|
|
|
|
sw->drawable);
|
|
|
|
XMapRaised(globalconf.display, sw->window);
|
2008-04-04 10:36:28 +02:00
|
|
|
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
2008-03-28 13:22:26 +01:00
|
|
|
}
|
|
|
|
else if (layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
|
|
|
|| layout->arrange == layout_tilebottom || layout->arrange == layout_tiletop)
|
|
|
|
{
|
|
|
|
for(n = 0, c = globalconf.clients; c; c = c->next)
|
|
|
|
if(IS_TILED(c, screen))
|
|
|
|
n++;
|
2007-12-28 17:11:20 +01:00
|
|
|
|
2008-03-28 13:22:26 +01:00
|
|
|
if(n <= curtags[0]->nmaster) return;
|
|
|
|
|
|
|
|
for(c = globalconf.clients; c && !IS_TILED(c, screen); c = c->next);
|
|
|
|
if(!c) return;
|
|
|
|
|
|
|
|
area = screen_get_area(screen,
|
|
|
|
globalconf.screens[c->screen].statusbar,
|
|
|
|
&globalconf.screens[c->screen].padding);
|
2007-12-28 17:11:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
2007-12-27 12:50:55 +01:00
|
|
|
|
2008-03-21 10:53:17 +01:00
|
|
|
if(XGrabPointer(globalconf.display,
|
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
2007-11-13 22:57:57 +01:00
|
|
|
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
2008-03-21 10:53:17 +01:00
|
|
|
RootWindow(globalconf.display, c->phys_screen),
|
2008-01-28 10:37:47 +01:00
|
|
|
globalconf.cursor[CurResize], CurrentTime) != GrabSuccess)
|
2007-11-13 22:57:57 +01:00
|
|
|
return;
|
2007-12-28 17:11:20 +01:00
|
|
|
|
|
|
|
if(curtags[0]->layout->arrange == layout_tileleft)
|
2008-03-28 13:22:26 +01:00
|
|
|
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, 0,
|
|
|
|
c->geometry.height + c->border - 1);
|
2008-01-17 17:04:40 +01:00
|
|
|
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
2008-03-28 13:22:26 +01:00
|
|
|
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
|
|
|
c->geometry.width + c->border - 1, c->geometry.height + c->border - 1);
|
2008-01-17 17:04:40 +01:00
|
|
|
else if(curtags[0]->layout->arrange == layout_tiletop)
|
2008-03-28 13:22:26 +01:00
|
|
|
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
|
|
|
c->geometry.width + c->border - 1, 0);
|
2007-12-28 17:11:20 +01:00
|
|
|
else
|
2008-03-28 13:22:26 +01:00
|
|
|
XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0,
|
|
|
|
c->geometry.width + c->border - 1, c->geometry.height + c->border - 1);
|
2007-12-28 17:11:20 +01:00
|
|
|
|
2007-11-13 22:57:57 +01:00
|
|
|
for(;;)
|
|
|
|
{
|
2007-12-27 23:10:43 +01:00
|
|
|
XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
switch (ev.type)
|
|
|
|
{
|
2008-01-28 10:37:47 +01:00
|
|
|
case ButtonRelease:
|
2007-12-27 23:10:43 +01:00
|
|
|
XUngrabPointer(globalconf.display, CurrentTime);
|
2008-03-25 16:10:12 +01:00
|
|
|
if(sw)
|
|
|
|
{
|
|
|
|
draw_context_delete(&ctx);
|
|
|
|
simplewindow_delete(&sw);
|
|
|
|
}
|
2007-11-13 22:57:57 +01:00
|
|
|
return;
|
2008-01-28 10:37:47 +01:00
|
|
|
case ConfigureRequest:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_configurerequest(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case Expose:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_expose(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case MapRequest:
|
2008-03-06 09:09:59 +01:00
|
|
|
event_handle_maprequest(&ev);
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
2008-01-28 10:37:47 +01:00
|
|
|
case MotionNotify:
|
2008-01-12 23:25:36 +01:00
|
|
|
if(layout->arrange == layout_floating || c->isfloating)
|
2007-12-28 17:11:20 +01:00
|
|
|
{
|
2008-01-05 20:18:30 +01:00
|
|
|
if((geometry.width = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
|
|
|
geometry.width = 1;
|
|
|
|
if((geometry.height = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
|
|
|
geometry.height = 1;
|
|
|
|
geometry.x = c->geometry.x;
|
|
|
|
geometry.y = c->geometry.y;
|
2008-03-16 10:01:55 +01:00
|
|
|
client_resize(c, geometry, True);
|
2008-03-25 16:10:12 +01:00
|
|
|
if(sw)
|
2008-04-04 10:36:28 +02:00
|
|
|
mouse_resizebar_draw(ctx, style, sw, c->geometry, c->border);
|
2007-12-28 17:11:20 +01:00
|
|
|
}
|
2008-01-14 00:37:46 +01:00
|
|
|
else if(layout->arrange == layout_tile || layout->arrange == layout_tileleft
|
2008-01-17 17:04:40 +01:00
|
|
|
|| layout->arrange == layout_tiletop || layout->arrange == layout_tilebottom)
|
2007-12-28 17:11:20 +01:00
|
|
|
{
|
2008-01-12 23:25:36 +01:00
|
|
|
if(layout->arrange == layout_tile)
|
2007-12-28 17:11:20 +01:00
|
|
|
mwfact = (double) (ev.xmotion.x - area.x) / area.width;
|
2008-01-14 00:37:46 +01:00
|
|
|
else if(curtags[0]->layout->arrange == layout_tileleft)
|
2007-12-28 17:11:20 +01:00
|
|
|
mwfact = 1 - (double) (ev.xmotion.x - area.x) / area.width;
|
2008-01-17 17:04:40 +01:00
|
|
|
else if(curtags[0]->layout->arrange == layout_tilebottom)
|
2008-01-14 00:37:46 +01:00
|
|
|
mwfact = (double) (ev.xmotion.y - area.y) / area.height;
|
|
|
|
else
|
|
|
|
mwfact = 1 - (double) (ev.xmotion.y - area.y) / area.height;
|
2007-12-28 17:11:20 +01:00
|
|
|
if(mwfact < 0.1) mwfact = 0.1;
|
|
|
|
else if(mwfact > 0.9) mwfact = 0.9;
|
2008-01-28 11:05:32 +01:00
|
|
|
if(fabs(curtags[0]->mwfact - mwfact) >= 0.01)
|
2007-12-28 17:37:41 +01:00
|
|
|
{
|
|
|
|
curtags[0]->mwfact = mwfact;
|
2008-01-17 19:17:53 +01:00
|
|
|
globalconf.screens[screen].need_arrange = True;
|
2008-01-28 11:05:32 +01:00
|
|
|
layout_refresh();
|
|
|
|
while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev));
|
2007-12-28 17:37:41 +01:00
|
|
|
}
|
2007-12-28 17:11:20 +01:00
|
|
|
}
|
|
|
|
|
2007-11-13 22:57:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-12-28 17:11:20 +01:00
|
|
|
p_delete(&curtags);
|
2007-11-13 22:57:57 +01:00
|
|
|
}
|
|
|
|
|
2007-12-18 09:24:15 +01:00
|
|
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|