📄 gdk.c
字号:
{ /* de-initialisation is done by the gdk_exit_funct(), no need to do this here (Alex J.) */ exit (errorcode);}voidgdk_set_use_xshm (gint use_xshm){ gdk_use_xshm = use_xshm;}gintgdk_get_use_xshm (void){ return gdk_use_xshm;}/* *-------------------------------------------------------------- * gdk_time_get * * Get the number of milliseconds since the library was * initialized. * * Arguments: * * Results: * The time since the library was initialized is returned. * This time value is accurate to milliseconds even though * a more accurate time down to the microsecond could be * returned. * * Side effects: * *-------------------------------------------------------------- */guint32gdk_time_get (void){ struct timeval end; struct timeval elapsed; guint32 milliseconds; X_GETTIMEOFDAY (&end); if (start.tv_usec > end.tv_usec) { end.tv_usec += 1000000; end.tv_sec--; } elapsed.tv_sec = end.tv_sec - start.tv_sec; elapsed.tv_usec = end.tv_usec - start.tv_usec; milliseconds = (elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000); return milliseconds;}/* *-------------------------------------------------------------- * gdk_timer_get * * Returns the current timer. * * Arguments: * * Results: * Returns the current timer interval. This interval is * in units of milliseconds. * * Side effects: * *-------------------------------------------------------------- */guint32gdk_timer_get (void){ return timer_val;}/* *-------------------------------------------------------------- * gdk_timer_set * * Sets the timer interval. * * Arguments: * "milliseconds" is the new value for the timer. * * Results: * * Side effects: * Calls to "gdk_event_get" will last for a maximum * of time of "milliseconds". However, a value of 0 * milliseconds will cause "gdk_event_get" to block * indefinately until an event is received. * *-------------------------------------------------------------- */voidgdk_timer_set (guint32 milliseconds){ timer_val = milliseconds; timer.tv_sec = milliseconds / 1000; timer.tv_usec = (milliseconds % 1000) * 1000; }voidgdk_timer_enable (void){ timerp = &timer;}voidgdk_timer_disable (void){ timerp = NULL;}/* *-------------------------------------------------------------- * gdk_pointer_grab * * Grabs the pointer to a specific window * * Arguments: * "window" is the window which will receive the grab * "owner_events" specifies whether events will be reported as is, * or relative to "window" * "event_mask" masks only interesting events * "confine_to" limits the cursor movement to the specified window * "cursor" changes the cursor for the duration of the grab * "time" specifies the time * * Results: * * Side effects: * requires a corresponding call to gdk_pointer_ungrab * *-------------------------------------------------------------- */gintgdk_pointer_grab (GdkWindow * window, gint owner_events, GdkEventMask event_mask, GdkWindow * confine_to, GdkCursor * cursor, guint32 time){ /* From gdkwindow.c */ gint return_val; GdkWindowPrivate *window_private; GdkWindowPrivate *confine_to_private; GdkCursorPrivate *cursor_private; guint xevent_mask; Window xwindow; Window xconfine_to; Cursor xcursor; int i; g_return_val_if_fail (window != NULL, 0); window_private = (GdkWindowPrivate*) window; confine_to_private = (GdkWindowPrivate*) confine_to; cursor_private = (GdkCursorPrivate*) cursor; xwindow = window_private->xwindow; if (!confine_to || confine_to_private->destroyed) xconfine_to = None; else xconfine_to = confine_to_private->xwindow; if (!cursor) xcursor = None; else xcursor = cursor_private->xcursor; xevent_mask = 0; for (i = 0; i < gdk_nevent_masks; i++) { if (event_mask & (1 << (i + 1))) xevent_mask |= gdk_event_mask_table[i]; } if (gdk_input_vtable.grab_pointer) return_val = gdk_input_vtable.grab_pointer (window, owner_events, event_mask, confine_to, time); else return_val = Success; if (return_val == Success) { if (!window_private->destroyed) return_val = XGrabPointer (window_private->xdisplay, xwindow, owner_events, xevent_mask, GrabModeAsync, GrabModeAsync, xconfine_to, xcursor, time); else return_val = AlreadyGrabbed; } if (return_val == GrabSuccess) gdk_xgrab_window = window_private; return return_val;}/* *-------------------------------------------------------------- * gdk_pointer_ungrab * * Releases any pointer grab * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */voidgdk_pointer_ungrab (guint32 time){ if (gdk_input_vtable.ungrab_pointer) gdk_input_vtable.ungrab_pointer (time); XUngrabPointer (gdk_display, time); gdk_xgrab_window = NULL;}/* *-------------------------------------------------------------- * gdk_pointer_is_grabbed * * Tell wether there is an active x pointer grab in effect * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */gintgdk_pointer_is_grabbed (void){ return gdk_xgrab_window != NULL;}/* *-------------------------------------------------------------- * gdk_keyboard_grab * * Grabs the keyboard to a specific window * * Arguments: * "window" is the window which will receive the grab * "owner_events" specifies whether events will be reported as is, * or relative to "window" * "time" specifies the time * * Results: * * Side effects: * requires a corresponding call to gdk_keyboard_ungrab * *-------------------------------------------------------------- */gintgdk_keyboard_grab (GdkWindow * window, gint owner_events, guint32 time){ GdkWindowPrivate *window_private; Window xwindow; g_return_val_if_fail (window != NULL, 0); window_private = (GdkWindowPrivate*) window; xwindow = window_private->xwindow; if (!window_private->destroyed) return XGrabKeyboard (window_private->xdisplay, xwindow, owner_events, GrabModeAsync, GrabModeAsync, time); else return AlreadyGrabbed;}/* *-------------------------------------------------------------- * gdk_keyboard_ungrab * * Releases any keyboard grab * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */voidgdk_keyboard_ungrab (guint32 time){ XUngrabKeyboard (gdk_display, time);}/* *-------------------------------------------------------------- * gdk_screen_width * * Return the width of the screen. * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */gintgdk_screen_width (void){ gint return_val; return_val = DisplayWidth (gdk_display, gdk_screen); return return_val;}/* *-------------------------------------------------------------- * gdk_screen_height * * Return the height of the screen. * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */gintgdk_screen_height (void){ gint return_val; return_val = DisplayHeight (gdk_display, gdk_screen); return return_val;}/* *-------------------------------------------------------------- * gdk_screen_width_mm * * Return the width of the screen in millimeters. * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */gintgdk_screen_width_mm (void){ gint return_val; return_val = DisplayWidthMM (gdk_display, gdk_screen); return return_val;}/* *-------------------------------------------------------------- * gdk_screen_height * * Return the height of the screen in millimeters. * * Arguments: * * Results: * * Side effects: * *-------------------------------------------------------------- */gintgdk_screen_height_mm (void){ gint return_val; return_val = DisplayHeightMM (gdk_display, gdk_screen); return return_val;}/* *-------------------------------------------------------------- * gdk_set_sm_client_id * * Set the SM_CLIENT_ID property on the WM_CLIENT_LEADER window * so that the window manager can save our state using the * X11R6 ICCCM session management protocol. A NULL value should * be set following disconnection from the session manager to * remove the SM_CLIENT_ID property. * * Arguments: * * "sm_client_id" specifies the client id assigned to us by the * session manager or NULL to remove the property. * * Results: * * Side effects: * *-------------------------------------------------------------- */voidgdk_set_sm_client_id (const gchar* sm_client_id){ if (sm_client_id && strcmp (sm_client_id, "")) { XChangeProperty (gdk_display, gdk_leader_window, gdk_atom_intern ("SM_CLIENT_ID", FALSE), XA_STRING, 8, PropModeReplace, sm_client_id, strlen(sm_client_id)); } else XDeleteProperty (gdk_display, gdk_leader_window, gdk_atom_intern ("SM_CLIENT_ID", FALSE));}voidgdk_key_repeat_disable (void){ XAutoRepeatOff (gdk_display);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -