From 53b7d488ef9d35a2bcacab327f5cbf7c509096f6 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sat, 19 Jan 2008 13:44:54 +0000 Subject: [PATCH] Introduce EwinWarpTo(). SVN revision: 33535 --- src/ewins.c | 13 +++++++++++++ src/ewins.h | 4 +++- src/focus.c | 7 ++----- src/warp.c | 14 +++----------- src/zoom.c | 8 +++----- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/ewins.c b/src/ewins.c index 55f253df..72a2415a 100644 --- a/src/ewins.c +++ b/src/ewins.c @@ -1806,6 +1806,19 @@ EwinReposition(EWin * ewin) EwinMove(ewin, xn, yn); } +void +EwinWarpTo(EWin * ewin) +{ + if (ewin == Mode.mouse_over_ewin) + return; + + if (ewin->state.iconified) + return; + + EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2); + Mode.mouse_over_ewin = ewin; +} + typedef union { unsigned int all; diff --git a/src/ewins.h b/src/ewins.h index 2557aa47..07cb7f94 100644 --- a/src/ewins.h +++ b/src/ewins.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -390,6 +390,8 @@ void EwinUpdateOpacity(EWin * ewin); void EwinChange(EWin * ewin, unsigned int flag); +void EwinWarpTo(EWin * ewin); + EWin **EwinListTransients(const EWin * ewin, int *num, int group); EWin **EwinListTransientFor(const EWin * ewin, int *num); diff --git a/src/focus.c b/src/focus.c index 44137e77..7a369e2a 100644 --- a/src/focus.c +++ b/src/focus.c @@ -399,11 +399,8 @@ doFocusToEwin(EWin * ewin, int why) if (Conf.focus.warp_always) do_warp = 1; - if (do_warp && ewin != Mode.mouse_over_ewin) - { - EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2); - Mode.mouse_over_ewin = ewin; - } + if (do_warp) + EwinWarpTo(ewin); RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT"); switch (why) diff --git a/src/warp.c b/src/warp.c index fa9c7ac1..0fb31a42 100644 --- a/src/warp.c +++ b/src/warp.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -354,11 +354,7 @@ WarpFocus(int delta) if (Conf.focus.raise_on_next) EwinRaise(ewin); if (Conf.focus.warp_on_next) - if (ewin != Mode.mouse_over_ewin && !ewin->state.iconified) - { - EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2); - Mode.mouse_over_ewin = ewin; - } + EwinWarpTo(ewin); if (Conf.warplist.warpfocused) FocusToEWin(ewin, FOCUS_SET); } @@ -402,11 +398,7 @@ WarpFocusFinish(void) EwinOpActivate(ewin, OPSRC_USER, Conf.warplist.raise_on_select); if (Conf.warplist.warp_on_select) - if (ewin != Mode.mouse_over_ewin) - { - EXWarpPointer(EoGetXwin(ewin), EoGetW(ewin) / 2, EoGetH(ewin) / 2); - Mode.mouse_over_ewin = ewin; - } + EwinWarpTo(ewin); } static void diff --git a/src/zoom.c b/src/zoom.c index 6ac3f13d..0ccd4162 100644 --- a/src/zoom.c +++ b/src/zoom.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2004-2007 Kim Woelders + * Copyright (C) 2004-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -218,8 +218,7 @@ Zoom(EWin * ewin) if (zoom_mask_4) EDestroyWindow(zoom_mask_4); SwitchRes(0, 0, 0, 0, 0); - EXWarpPointer(EwinGetClientXwin(ewin), ewin->client.w / 2, - ewin->client.h / 2); + EwinWarpTo(ewin); ESync(); zoom_last_ewin = NULL; } @@ -250,8 +249,7 @@ Zoom(EWin * ewin) EwinBorderGetSize(ewin, &bl, &br, &bt, &bb); EwinMove(ewin, -bl + x1, -bt + y1); FocusToEWin(ewin, FOCUS_SET); - EXWarpPointer(EwinGetClientXwin(ewin), ewin->client.w / 2, - ewin->client.h / 2); + EwinWarpTo(ewin); #if 0 /* Doesn't work as intended */ XGrabPointer(disp, EwinGetClientXwin(ewin), True, ButtonPressMask | ButtonReleaseMask |