summaryrefslogtreecommitdiffstats
path: root/win/tkWinPointer.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinPointer.c')
-rw-r--r--win/tkWinPointer.c218
1 files changed, 110 insertions, 108 deletions
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 0d9ed61..d29e952 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinPointer.c --
*
* Windows specific mouse tracking code.
@@ -6,8 +6,8 @@
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1998-1999 by Scriptics Corporation.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkWinInt.h"
@@ -31,7 +31,7 @@ static int mouseTimerSet = 0; /* 1 if the mouse timer is active. */
* Forward declarations of procedures used in this file.
*/
-static void MouseTimerProc _ANSI_ARGS_((ClientData clientData));
+static void MouseTimerProc(ClientData clientData);
/*
*----------------------------------------------------------------------
@@ -50,7 +50,7 @@ static void MouseTimerProc _ANSI_ARGS_((ClientData clientData));
*/
int
-TkWinGetModifierState()
+TkWinGetModifierState(void)
{
int state = 0;
@@ -89,10 +89,9 @@ TkWinGetModifierState()
*
* Tk_PointerEvent --
*
- * This procedure is called for each pointer-related event.
- * It converts the position to root coords and updates the
- * global pointer state machine. It also ensures that the
- * mouse timer is scheduled.
+ * This procedure is called for each pointer-related event. It converts
+ * the position to root coords and updates the global pointer state
+ * machine. It also ensures that the mouse timer is scheduled.
*
* Results:
* None.
@@ -104,11 +103,11 @@ TkWinGetModifierState()
*/
void
-Tk_PointerEvent(hwnd, x, y)
- HWND hwnd; /* Window for coords, or NULL for
- * the root window. */
- int x, y; /* Coords relative to hwnd, or screen
- * if hwnd is NULL. */
+Tk_PointerEvent(
+ HWND hwnd, /* Window for coords, or NULL for the root
+ * window. */
+ int x, int y) /* Coords relative to hwnd, or screen if hwnd
+ * is NULL. */
{
POINT pos;
int state;
@@ -126,11 +125,11 @@ Tk_PointerEvent(hwnd, x, y)
}
/*
- * If the mouse is captured, Windows will report all pointer
- * events to the capture window. So, we need to determine which
- * window the mouse is really over and change the event. Note
- * that the computed hwnd may point to a window not owned by Tk,
- * or a toplevel decorative frame, so tkwin can be NULL.
+ * If the mouse is captured, Windows will report all pointer events to the
+ * capture window. So, we need to determine which window the mouse is
+ * really over and change the event. Note that the computed hwnd may point
+ * to a window not owned by Tk, or a toplevel decorative frame, so tkwin
+ * can be NULL.
*/
if (captured || hwnd == NULL) {
@@ -166,14 +165,13 @@ Tk_PointerEvent(hwnd, x, y)
*/
int
-XGrabKeyboard(display, grab_window, owner_events, pointer_mode,
- keyboard_mode, time)
- Display* display;
- Window grab_window;
- Bool owner_events;
- int pointer_mode;
- int keyboard_mode;
- Time time;
+XGrabKeyboard(
+ Display *display,
+ Window grab_window,
+ Bool owner_events,
+ int pointer_mode,
+ int keyboard_mode,
+ Time time)
{
keyboardWinPtr = TkWinGetWinPtr(grab_window);
return GrabSuccess;
@@ -196,9 +194,9 @@ XGrabKeyboard(display, grab_window, owner_events, pointer_mode,
*/
void
-XUngrabKeyboard(display, time)
- Display* display;
- Time time;
+XUngrabKeyboard(
+ Display *display,
+ Time time)
{
keyboardWinPtr = NULL;
}
@@ -208,8 +206,7 @@ XUngrabKeyboard(display, time)
*
* MouseTimerProc --
*
- * Check the current mouse position and look for enter/leave
- * events.
+ * Check the current mouse position and look for enter/leave events.
*
* Results:
* None.
@@ -221,16 +218,16 @@ XUngrabKeyboard(display, time)
*/
void
-MouseTimerProc(clientData)
- ClientData clientData;
+MouseTimerProc(
+ ClientData clientData)
{
POINT pos;
mouseTimerSet = 0;
/*
- * Get the current mouse position and window. Don't do anything
- * if the mouse hasn't moved since the last time we looked.
+ * Get the current mouse position and window. Don't do anything if the
+ * mouse hasn't moved since the last time we looked.
*/
GetCursorPos(&pos);
@@ -254,7 +251,7 @@ MouseTimerProc(clientData)
*/
void
-TkWinCancelMouseTimer()
+TkWinCancelMouseTimer(void)
{
if (mouseTimerSet) {
Tcl_DeleteTimerHandler(mouseTimer);
@@ -270,8 +267,8 @@ TkWinCancelMouseTimer()
* Fetch the position of the mouse pointer.
*
* Results:
- * *xPtr and *yPtr are filled in with the root coordinates
- * of the mouse pointer for the display.
+ * *xPtr and *yPtr are filled in with the root coordinates of the mouse
+ * pointer for the display.
*
* Side effects:
* None.
@@ -280,10 +277,10 @@ TkWinCancelMouseTimer()
*/
void
-TkGetPointerCoords(tkwin, xPtr, yPtr)
- Tk_Window tkwin; /* Window that identifies screen on which
+TkGetPointerCoords(
+ Tk_Window tkwin, /* Window that identifies screen on which
* lookup is to be done. */
- int *xPtr, *yPtr; /* Store pointer coordinates here. */
+ int *xPtr, int *yPtr) /* Store pointer coordinates here. */
{
POINT point;
@@ -297,13 +294,13 @@ TkGetPointerCoords(tkwin, xPtr, yPtr)
*
* XQueryPointer --
*
- * Check the current state of the mouse. This is not a complete
- * implementation of this function. It only computes the root
- * coordinates and the current mask.
+ * Check the current state of the mouse. This is not a complete
+ * implementation of this function. It only computes the root coordinates
+ * and the current mask.
*
* Results:
- * Sets root_x_return, root_y_return, and mask_return. Returns
- * true on success.
+ * Sets root_x_return, root_y_return, and mask_return. Returns true on
+ * success.
*
* Side effects:
* None.
@@ -312,17 +309,16 @@ TkGetPointerCoords(tkwin, xPtr, yPtr)
*/
Bool
-XQueryPointer(display, w, root_return, child_return, root_x_return,
- root_y_return, win_x_return, win_y_return, mask_return)
- Display* display;
- Window w;
- Window* root_return;
- Window* child_return;
- int* root_x_return;
- int* root_y_return;
- int* win_x_return;
- int* win_y_return;
- unsigned int* mask_return;
+XQueryPointer(
+ Display *display,
+ Window w,
+ Window *root_return,
+ Window *child_return,
+ int *root_x_return,
+ int *root_y_return,
+ int *win_x_return,
+ int *win_y_return,
+ unsigned int *mask_return)
{
display->request++;
TkGetPointerCoords(NULL, root_x_return, root_y_return);
@@ -335,8 +331,8 @@ XQueryPointer(display, w, root_return, child_return, root_x_return,
*
* XWarpPointer --
*
- * Move pointer to new location. This is not a complete
- * implementation of this function.
+ * Move pointer to new location. This is not a complete implementation of
+ * this function.
*
* Results:
* None.
@@ -348,22 +344,21 @@ XQueryPointer(display, w, root_return, child_return, root_x_return,
*/
void
-XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width,
- src_height, dest_x, dest_y)
- Display* display;
- Window src_w;
- Window dest_w;
- int src_x;
- int src_y;
- unsigned int src_width;
- unsigned int src_height;
- int dest_x;
- int dest_y;
+XWarpPointer(
+ Display *display,
+ Window src_w,
+ Window dest_w,
+ int src_x,
+ int src_y,
+ unsigned int src_width,
+ unsigned int src_height,
+ int dest_x,
+ int dest_y)
{
RECT r;
GetWindowRect(Tk_GetHWND(dest_w), &r);
- SetCursorPos(r.left+dest_x, r.top+dest_y);
+ SetCursorPos(r.left+dest_x, r.top+dest_y);
}
/*
@@ -383,12 +378,13 @@ XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width,
*/
void
-XGetInputFocus(display, focus_return, revert_to_return)
- Display *display;
- Window *focus_return;
- int *revert_to_return;
+XGetInputFocus(
+ Display *display,
+ Window *focus_return,
+ int *revert_to_return)
{
Tk_Window tkwin = Tk_HWNDToWindow(GetFocus());
+
*focus_return = tkwin ? Tk_WindowId(tkwin) : None;
*revert_to_return = RevertToParent;
display->request++;
@@ -412,11 +408,11 @@ XGetInputFocus(display, focus_return, revert_to_return)
*/
void
-XSetInputFocus(display, focus, revert_to, time)
- Display* display;
- Window focus;
- int revert_to;
- Time time;
+XSetInputFocus(
+ Display *display,
+ Window focus,
+ int revert_to,
+ Time time)
{
display->request++;
if (focus != None) {
@@ -429,29 +425,28 @@ XSetInputFocus(display, focus, revert_to, time)
*
* TkpChangeFocus --
*
- * This procedure is invoked to move the system focus from
- * one window to another.
+ * This procedure is invoked to move the system focus from one window to
+ * another.
*
* Results:
- * The return value is the serial number of the command that
- * changed the focus. It may be needed by the caller to filter
- * out focus change events that were queued before the command.
- * If the procedure doesn't actually change the focus then
- * it returns 0.
+ * The return value is the serial number of the command that changed the
+ * focus. It may be needed by the caller to filter out focus change
+ * events that were queued before the command. If the procedure doesn't
+ * actually change the focus then it returns 0.
*
* Side effects:
- * The official Windows focus window changes; the application's focus
+ * The official Windows focus window changes; the application's focus
* window isn't changed by this procedure.
*
*----------------------------------------------------------------------
*/
int
-TkpChangeFocus(winPtr, force)
- TkWindow *winPtr; /* Window that is to receive the X focus. */
- int force; /* Non-zero means claim the focus even
- * if it didn't originally belong to
- * topLevelPtr's application. */
+TkpChangeFocus(
+ TkWindow *winPtr, /* Window that is to receive the X focus. */
+ int force) /* Non-zero means claim the focus even if it
+ * didn't originally belong to topLevelPtr's
+ * application. */
{
TkDisplay *dispPtr = winPtr->dispPtr;
Window focusWindow;
@@ -467,12 +462,12 @@ TkpChangeFocus(winPtr, force)
}
if (winPtr->window == None) {
- panic("ChangeXFocus got null X window");
+ Tcl_Panic("ChangeXFocus got null X window");
}
-
+
/*
- * Change the foreground window so the focus window is raised to the top of
- * the system stacking order and gets the keyboard focus.
+ * Change the foreground window so the focus window is raised to the top
+ * of the system stacking order and gets the keyboard focus.
*/
if (force) {
@@ -482,10 +477,10 @@ TkpChangeFocus(winPtr, force)
CurrentTime);
/*
- * Remember the current serial number for the X server and issue
- * a dummy server request. This marks the position at which we
- * changed the focus, so we can distinguish FocusIn and FocusOut
- * events on either side of the mark.
+ * Remember the current serial number for the X server and issue a dummy
+ * server request. This marks the position at which we changed the focus,
+ * so we can distinguish FocusIn and FocusOut events on either side of the
+ * mark.
*/
serial = NextRequest(winPtr->display);
@@ -498,10 +493,9 @@ TkpChangeFocus(winPtr, force)
*
* TkpSetCapture --
*
- * This function captures the mouse so that all future events
- * will be reported to this window, even if the mouse is outside
- * the window. If the specified window is NULL, then the mouse
- * is released.
+ * This function captures the mouse so that all future events will be
+ * reported to this window, even if the mouse is outside the window. If
+ * the specified window is NULL, then the mouse is released.
*
* Results:
* None.
@@ -513,8 +507,8 @@ TkpChangeFocus(winPtr, force)
*/
void
-TkpSetCapture(winPtr)
- TkWindow *winPtr; /* Capture window, or NULL. */
+TkpSetCapture(
+ TkWindow *winPtr) /* Capture window, or NULL. */
{
if (winPtr) {
SetCapture(Tk_GetHWND(Tk_WindowId(winPtr)));
@@ -524,3 +518,11 @@ TkpSetCapture(winPtr)
ReleaseCapture();
}
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */