introduce mouse.[ch] files and move uicb_mouse*() to them
This commit is contained in:
parent
3d7cfe4e5b
commit
cfa31c399d
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = client.c draw.c event.c layout.c awesome.c tag.c util.c config.c screen.c statusbar.c uicb.c window.c rules.c awesome-client-common.c
|
SRC = client.c draw.c event.c layout.c awesome.c tag.c util.c config.c screen.c statusbar.c uicb.c window.c rules.c mouse.c awesome-client-common.c
|
||||||
OBJ = ${SRC:.c=.o} ${LAYOUTS:.c=.o}
|
OBJ = ${SRC:.c=.o} ${LAYOUTS:.c=.o}
|
||||||
|
|
||||||
SRCCLIENT = awesome-client.c awesome-client-common.c util.c
|
SRCCLIENT = awesome-client.c awesome-client-common.c util.c
|
||||||
|
|
5
config.c
5
config.c
|
@ -30,12 +30,11 @@
|
||||||
#include "awesome.h"
|
#include "awesome.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "event.h"
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "rules.h"
|
#include "rules.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "event.h"
|
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
#include "mouse.h"
|
||||||
#include "layouts/tile.h"
|
#include "layouts/tile.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
#include "layouts/max.h"
|
#include "layouts/max.h"
|
||||||
|
@ -103,7 +102,7 @@ const NameFuncLink UicbList[] = {
|
||||||
/* config.c */
|
/* config.c */
|
||||||
{"reloadconfig", uicb_reloadconfig},
|
{"reloadconfig", uicb_reloadconfig},
|
||||||
{"setstatustext", uicb_setstatustext},
|
{"setstatustext", uicb_setstatustext},
|
||||||
/* event.c */
|
/* mouse.c */
|
||||||
{"movemouse", uicb_movemouse},
|
{"movemouse", uicb_movemouse},
|
||||||
{"resizemouse", uicb_resizemouse},
|
{"resizemouse", uicb_resizemouse},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
|
122
event.c
122
event.c
|
@ -33,130 +33,11 @@
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
#include "mouse.h"
|
||||||
#include "layouts/tile.h"
|
#include "layouts/tile.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
#define CLEANMASK(mask, acf) (mask & ~(acf.numlockmask | LockMask))
|
#define CLEANMASK(mask, acf) (mask & ~(acf.numlockmask | LockMask))
|
||||||
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
|
||||||
|
|
||||||
void
|
|
||||||
uicb_movemouse(awesome_config *awesomeconf, const char *arg __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
int x1, y1, ocx, ocy, di, nx, ny;
|
|
||||||
unsigned int dui;
|
|
||||||
Window dummy;
|
|
||||||
XEvent ev;
|
|
||||||
ScreenInfo *si;
|
|
||||||
Client *c = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
|
|
||||||
|
|
||||||
if(!c)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if((get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating)
|
|
||||||
&& !c->isfloating)
|
|
||||||
uicb_togglefloating(awesomeconf, "DUMMY");
|
|
||||||
else
|
|
||||||
restack(awesomeconf);
|
|
||||||
|
|
||||||
si = get_screen_info(c->display, c->screen, &awesomeconf->statusbar);
|
|
||||||
|
|
||||||
ocx = nx = c->x;
|
|
||||||
ocy = ny = c->y;
|
|
||||||
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
|
||||||
None, awesomeconf->cursor[CurMove], CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
XQueryPointer(c->display, RootWindow(c->display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
|
||||||
switch (ev.type)
|
|
||||||
{
|
|
||||||
case ButtonRelease:
|
|
||||||
XUngrabPointer(c->display, CurrentTime);
|
|
||||||
p_delete(&si);
|
|
||||||
return;
|
|
||||||
case ConfigureRequest:
|
|
||||||
handle_event_configurerequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case Expose:
|
|
||||||
handle_event_expose(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case MapRequest:
|
|
||||||
handle_event_maprequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
XSync(c->display, False);
|
|
||||||
nx = ocx + (ev.xmotion.x - x1);
|
|
||||||
ny = ocy + (ev.xmotion.y - y1);
|
|
||||||
if(abs(nx) < awesomeconf->snap + si[c->screen].x_org && nx > si[c->screen].x_org)
|
|
||||||
nx = si[c->screen].x_org;
|
|
||||||
else if(abs((si[c->screen].x_org + si[c->screen].width) - (nx + c->w + 2 * c->border)) < awesomeconf->snap)
|
|
||||||
nx = si[c->screen].x_org + si[c->screen].width - c->w - 2 * c->border;
|
|
||||||
if(abs(ny) < awesomeconf->snap + si[c->screen].y_org && ny > si[c->screen].y_org)
|
|
||||||
ny = si[c->screen].y_org;
|
|
||||||
else if(abs((si[c->screen].y_org + si[c->screen].height) - (ny + c->h + 2 * c->border)) < awesomeconf[c->screen].snap)
|
|
||||||
ny = si[c->screen].y_org + si[c->screen].height - c->h - 2 * c->border;
|
|
||||||
client_resize(c, nx, ny, c->w, c->h, awesomeconf, False, False);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
uicb_resizemouse(awesome_config *awesomeconf, const char *arg __attribute__ ((unused)))
|
|
||||||
{
|
|
||||||
int ocx, ocy, nw, nh;
|
|
||||||
XEvent ev;
|
|
||||||
Client *c = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
|
|
||||||
|
|
||||||
if(!c)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if((get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating)
|
|
||||||
&& !c->isfloating)
|
|
||||||
uicb_togglefloating(awesomeconf, "DUMMY");
|
|
||||||
else
|
|
||||||
restack(awesomeconf);
|
|
||||||
|
|
||||||
ocx = c->x;
|
|
||||||
ocy = c->y;
|
|
||||||
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen),
|
|
||||||
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
|
||||||
None, awesomeconf->cursor[CurResize], CurrentTime) != GrabSuccess)
|
|
||||||
return;
|
|
||||||
c->ismax = False;
|
|
||||||
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
|
||||||
switch (ev.type)
|
|
||||||
{
|
|
||||||
case ButtonRelease:
|
|
||||||
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
|
||||||
XUngrabPointer(c->display, CurrentTime);
|
|
||||||
while(XCheckMaskEvent(c->display, EnterWindowMask, &ev));
|
|
||||||
return;
|
|
||||||
case ConfigureRequest:
|
|
||||||
handle_event_configurerequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case Expose:
|
|
||||||
handle_event_expose(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case MapRequest:
|
|
||||||
handle_event_maprequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
|
||||||
break;
|
|
||||||
case MotionNotify:
|
|
||||||
XSync(c->display, False);
|
|
||||||
if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
|
||||||
nw = 1;
|
|
||||||
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
|
||||||
nh = 1;
|
|
||||||
client_resize(c, c->x, c->y, nw, nh, awesomeconf, True, False);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_mouse_button_press(awesome_config *awesomeconf,
|
handle_mouse_button_press(awesome_config *awesomeconf,
|
||||||
|
@ -175,6 +56,7 @@ handle_mouse_button_press(awesome_config *awesomeconf,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
|
|
3
event.h
3
event.h
|
@ -41,8 +41,5 @@ void handle_event_unmapnotify(XEvent *, awesome_config *);
|
||||||
void handle_event_shape(XEvent *, awesome_config *);
|
void handle_event_shape(XEvent *, awesome_config *);
|
||||||
void handle_event_randr_screen_change_notify(XEvent *, awesome_config *);
|
void handle_event_randr_screen_change_notify(XEvent *, awesome_config *);
|
||||||
|
|
||||||
UICB_PROTO(uicb_movemouse);
|
|
||||||
UICB_PROTO(uicb_resizemouse);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
||||||
|
|
|
@ -0,0 +1,150 @@
|
||||||
|
/*
|
||||||
|
* mouse.c - mouse managing
|
||||||
|
*
|
||||||
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mouse.h"
|
||||||
|
#include "screen.h"
|
||||||
|
#include "layout.h"
|
||||||
|
#include "tag.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "event.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
uicb_movemouse(awesome_config *awesomeconf, const char *arg __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
int x1, y1, ocx, ocy, di, nx, ny;
|
||||||
|
unsigned int dui;
|
||||||
|
Window dummy;
|
||||||
|
XEvent ev;
|
||||||
|
ScreenInfo *si;
|
||||||
|
Client *c = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
|
||||||
|
|
||||||
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if((get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating)
|
||||||
|
&& !c->isfloating)
|
||||||
|
uicb_togglefloating(awesomeconf, "DUMMY");
|
||||||
|
else
|
||||||
|
restack(awesomeconf);
|
||||||
|
|
||||||
|
si = get_screen_info(c->display, c->screen, &awesomeconf->statusbar);
|
||||||
|
|
||||||
|
ocx = nx = c->x;
|
||||||
|
ocy = ny = c->y;
|
||||||
|
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
|
None, awesomeconf->cursor[CurMove], CurrentTime) != GrabSuccess)
|
||||||
|
return;
|
||||||
|
XQueryPointer(c->display, RootWindow(c->display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||||
|
switch (ev.type)
|
||||||
|
{
|
||||||
|
case ButtonRelease:
|
||||||
|
XUngrabPointer(c->display, CurrentTime);
|
||||||
|
p_delete(&si);
|
||||||
|
return;
|
||||||
|
case ConfigureRequest:
|
||||||
|
handle_event_configurerequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case Expose:
|
||||||
|
handle_event_expose(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case MapRequest:
|
||||||
|
handle_event_maprequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
XSync(c->display, False);
|
||||||
|
nx = ocx + (ev.xmotion.x - x1);
|
||||||
|
ny = ocy + (ev.xmotion.y - y1);
|
||||||
|
if(abs(nx) < awesomeconf->snap + si[c->screen].x_org && nx > si[c->screen].x_org)
|
||||||
|
nx = si[c->screen].x_org;
|
||||||
|
else if(abs((si[c->screen].x_org + si[c->screen].width) - (nx + c->w + 2 * c->border)) < awesomeconf->snap)
|
||||||
|
nx = si[c->screen].x_org + si[c->screen].width - c->w - 2 * c->border;
|
||||||
|
if(abs(ny) < awesomeconf->snap + si[c->screen].y_org && ny > si[c->screen].y_org)
|
||||||
|
ny = si[c->screen].y_org;
|
||||||
|
else if(abs((si[c->screen].y_org + si[c->screen].height) - (ny + c->h + 2 * c->border)) < awesomeconf[c->screen].snap)
|
||||||
|
ny = si[c->screen].y_org + si[c->screen].height - c->h - 2 * c->border;
|
||||||
|
client_resize(c, nx, ny, c->w, c->h, awesomeconf, False, False);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
uicb_resizemouse(awesome_config *awesomeconf, const char *arg __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
int ocx, ocy, nw, nh;
|
||||||
|
XEvent ev;
|
||||||
|
Client *c = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
|
||||||
|
|
||||||
|
if(!c)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if((get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating)
|
||||||
|
&& !c->isfloating)
|
||||||
|
uicb_togglefloating(awesomeconf, "DUMMY");
|
||||||
|
else
|
||||||
|
restack(awesomeconf);
|
||||||
|
|
||||||
|
ocx = c->x;
|
||||||
|
ocy = c->y;
|
||||||
|
if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen),
|
||||||
|
False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
||||||
|
None, awesomeconf->cursor[CurResize], CurrentTime) != GrabSuccess)
|
||||||
|
return;
|
||||||
|
c->ismax = False;
|
||||||
|
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
||||||
|
switch (ev.type)
|
||||||
|
{
|
||||||
|
case ButtonRelease:
|
||||||
|
XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
||||||
|
XUngrabPointer(c->display, CurrentTime);
|
||||||
|
while(XCheckMaskEvent(c->display, EnterWindowMask, &ev));
|
||||||
|
return;
|
||||||
|
case ConfigureRequest:
|
||||||
|
handle_event_configurerequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case Expose:
|
||||||
|
handle_event_expose(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case MapRequest:
|
||||||
|
handle_event_maprequest(&ev, &awesomeconf[0 - awesomeconf->screen]);
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
XSync(c->display, False);
|
||||||
|
if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
||||||
|
nw = 1;
|
||||||
|
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
||||||
|
nh = 1;
|
||||||
|
client_resize(c, c->x, c->y, nw, nh, awesomeconf, True, False);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* mouse.h - mouse managing header
|
||||||
|
*
|
||||||
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AWESOME_MOUSE_H
|
||||||
|
#define AWESOME_MOUSE_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
||||||
|
|
||||||
|
UICB_PROTO(uicb_movemouse);
|
||||||
|
UICB_PROTO(uicb_resizemouse);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99
|
Loading…
Reference in New Issue