Compare commits
2 Commits
main
...
gdk-win32-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0237e852cc | ||
|
|
ff8f1d480a |
@@ -158,7 +158,6 @@ static const GdkDebugKey gdk_feature_keys[] = {
|
||||
{ "dmabuf", GDK_FEATURE_DMABUF, "Disable dmabuf support" },
|
||||
{ "offload", GDK_FEATURE_OFFLOAD, "Disable graphics offload" },
|
||||
{ "color-mgmt", GDK_FEATURE_COLOR_MANAGEMENT, "Disable color management" },
|
||||
{ "aerosnap", GDK_FEATURE_AEROSNAP, "Disable Aerosnap support on Windows" },
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ typedef enum {
|
||||
GDK_FEATURE_DMABUF = 1 << 7,
|
||||
GDK_FEATURE_OFFLOAD = 1 << 8,
|
||||
GDK_FEATURE_COLOR_MANAGEMENT = 1 << 9,
|
||||
GDK_FEATURE_AEROSNAP = 1 << 10,
|
||||
} GdkFeatures;
|
||||
|
||||
#define GDK_ALL_FEATURES ((1 << 10) - 1)
|
||||
|
||||
@@ -175,11 +175,6 @@ typedef struct
|
||||
|
||||
/* to store keycodes for shift keys */
|
||||
int both_shift_pressed[2];
|
||||
|
||||
/* AeroSnap emulation event handling */
|
||||
/* low-level keyboard hook handle */
|
||||
HHOOK aerosnap_keyboard_hook;
|
||||
UINT aerosnap_message;
|
||||
} event_records;
|
||||
|
||||
struct _GdkWin32Display
|
||||
|
||||
@@ -283,132 +283,6 @@ _gdk_win32_surface_procedure (HWND hwnd,
|
||||
return retval;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
low_level_keystroke_handler (WPARAM message,
|
||||
KBDLLHOOKSTRUCT *kbdhook,
|
||||
GdkSurface *surface)
|
||||
{
|
||||
GdkSurface *toplevel = surface;
|
||||
static DWORD last_keydown = 0;
|
||||
|
||||
if (message == WM_KEYDOWN &&
|
||||
!GDK_SURFACE_DESTROYED (toplevel) &&
|
||||
_gdk_win32_surface_lacks_wm_decorations (toplevel) && /* For CSD only */
|
||||
last_keydown != kbdhook->vkCode &&
|
||||
((GetKeyState (VK_LWIN) & 0x8000) ||
|
||||
(GetKeyState (VK_RWIN) & 0x8000)))
|
||||
{
|
||||
GdkWin32AeroSnapCombo combo = GDK_WIN32_AEROSNAP_COMBO_NOTHING;
|
||||
gboolean lshiftdown = GetKeyState (VK_LSHIFT) & 0x8000;
|
||||
gboolean rshiftdown = GetKeyState (VK_RSHIFT) & 0x8000;
|
||||
gboolean oneshiftdown = (lshiftdown || rshiftdown) && !(lshiftdown && rshiftdown);
|
||||
gboolean maximized = gdk_toplevel_get_state (GDK_TOPLEVEL (toplevel)) & GDK_TOPLEVEL_STATE_MAXIMIZED;
|
||||
|
||||
switch (kbdhook->vkCode)
|
||||
{
|
||||
case VK_UP:
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_UP;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_DOWN;
|
||||
break;
|
||||
case VK_LEFT:
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_LEFT;
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (oneshiftdown && combo != GDK_WIN32_AEROSNAP_COMBO_NOTHING)
|
||||
combo += 4;
|
||||
|
||||
/* These are the only combos that Windows WM does handle for us */
|
||||
if (combo == GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT ||
|
||||
combo == GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT)
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_NOTHING;
|
||||
|
||||
/* On Windows 10 the WM will handle this specific combo */
|
||||
if (combo == GDK_WIN32_AEROSNAP_COMBO_DOWN && maximized &&
|
||||
g_win32_check_windows_version (6, 4, 0, G_WIN32_OS_ANY))
|
||||
combo = GDK_WIN32_AEROSNAP_COMBO_NOTHING;
|
||||
|
||||
if (combo != GDK_WIN32_AEROSNAP_COMBO_NOTHING)
|
||||
{
|
||||
GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (toplevel));
|
||||
|
||||
PostMessage (GDK_SURFACE_HWND (toplevel),
|
||||
display->event_record->aerosnap_message,
|
||||
(WPARAM) combo, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (message == WM_KEYDOWN)
|
||||
last_keydown = kbdhook->vkCode;
|
||||
else if (message == WM_KEYUP && last_keydown == kbdhook->vkCode)
|
||||
last_keydown = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK
|
||||
low_level_keyboard_proc (int code,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
KBDLLHOOKSTRUCT *kbdhook;
|
||||
HWND kbd_focus_owner;
|
||||
GdkSurface *gdk_kbd_focus_owner;
|
||||
LRESULT chain;
|
||||
|
||||
do
|
||||
{
|
||||
if (code < 0)
|
||||
break;
|
||||
|
||||
kbd_focus_owner = GetFocus ();
|
||||
|
||||
if (kbd_focus_owner == NULL)
|
||||
break;
|
||||
|
||||
gdk_kbd_focus_owner = gdk_win32_display_handle_table_lookup_ (NULL, kbd_focus_owner);
|
||||
|
||||
if (gdk_kbd_focus_owner == NULL)
|
||||
break;
|
||||
|
||||
kbdhook = (KBDLLHOOKSTRUCT *) lParam;
|
||||
chain = low_level_keystroke_handler (wParam, kbdhook, gdk_kbd_focus_owner);
|
||||
|
||||
if (chain != 0)
|
||||
return chain;
|
||||
} while (FALSE);
|
||||
|
||||
return CallNextHookEx (0, code, wParam, lParam);
|
||||
}
|
||||
|
||||
static void
|
||||
set_up_low_level_keyboard_hook (GdkDisplay *display)
|
||||
{
|
||||
HHOOK hook_handle;
|
||||
|
||||
if (!gdk_has_feature (GDK_FEATURE_AEROSNAP))
|
||||
return;
|
||||
|
||||
if (GDK_WIN32_DISPLAY (display)->event_record->aerosnap_keyboard_hook != NULL)
|
||||
return;
|
||||
|
||||
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
|
||||
(HOOKPROC) low_level_keyboard_proc,
|
||||
this_module (), 0);
|
||||
|
||||
if (hook_handle != NULL)
|
||||
GDK_WIN32_DISPLAY (display)->event_record->aerosnap_keyboard_hook = hook_handle;
|
||||
else
|
||||
WIN32_API_FAILED ("SetWindowsHookEx");
|
||||
|
||||
GDK_WIN32_DISPLAY (display)->event_record->aerosnap_message = RegisterWindowMessage (L"GDK_WIN32_AEROSNAP_MESSAGE");
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_events_init (GdkDisplay *display)
|
||||
{
|
||||
@@ -518,8 +392,6 @@ _gdk_events_init (GdkDisplay *display)
|
||||
g_source_add_poll (source, &event_source->event_poll_fd);
|
||||
g_source_set_can_recurse (source, TRUE);
|
||||
g_source_attach (source, NULL);
|
||||
|
||||
set_up_low_level_keyboard_hook (display);
|
||||
}
|
||||
|
||||
#if 0 /* Unused, but might be useful to re-introduce in some debugging output? */
|
||||
@@ -1805,10 +1677,6 @@ gdk_event_translate (MSG *msg,
|
||||
*/
|
||||
#define return GOTO_DONE_INSTEAD
|
||||
|
||||
if (msg->message == win32_display->event_record->aerosnap_message)
|
||||
_gdk_win32_surface_handle_aerosnap (surface,
|
||||
(GdkWin32AeroSnapCombo) msg->wParam);
|
||||
|
||||
switch (msg->message)
|
||||
{
|
||||
case WM_INPUTLANGCHANGE:
|
||||
|
||||
@@ -98,7 +98,7 @@ gdk_win32_gl_context_egl_end_frame (GdkDrawContext *draw_context,
|
||||
GdkRectangle rect = {0, 0, gdk_surface_get_width (surface), gdk_surface_get_height (surface)};
|
||||
|
||||
/* We need to do gdk_window_invalidate_rect() so that we don't get glitches after maximizing or
|
||||
* restoring or using aerosnap
|
||||
* restoring
|
||||
*/
|
||||
gdk_surface_invalidate_rect (surface, &rect);
|
||||
reset_egl_force_redraw (surface);
|
||||
|
||||
@@ -256,9 +256,6 @@ void _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen);
|
||||
GdkDisplay *_gdk_win32_display_open (const char *display_name);
|
||||
void _gdk_win32_append_event (GdkEvent *event);
|
||||
|
||||
void _gdk_win32_surface_handle_aerosnap (GdkSurface *surface,
|
||||
GdkWin32AeroSnapCombo combo);
|
||||
|
||||
gboolean gdk_win32_get_surface_hwnd_rect (GdkSurface *surface,
|
||||
RECT *rect);
|
||||
void _gdk_win32_do_emit_configure_event (GdkSurface *surface,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,36 +52,6 @@ typedef enum
|
||||
GDK_DECOR_MAXIMIZE = 1 << 6
|
||||
} GdkWMDecoration;
|
||||
|
||||
enum _GdkWin32AeroSnapCombo
|
||||
{
|
||||
GDK_WIN32_AEROSNAP_COMBO_NOTHING = 0,
|
||||
GDK_WIN32_AEROSNAP_COMBO_UP,
|
||||
GDK_WIN32_AEROSNAP_COMBO_DOWN,
|
||||
GDK_WIN32_AEROSNAP_COMBO_LEFT,
|
||||
GDK_WIN32_AEROSNAP_COMBO_RIGHT,
|
||||
/* Same order as non-shift variants. We use it to do things like:
|
||||
* AEROSNAP_UP + 4 = AEROSNAP_SHIFTUP
|
||||
*/
|
||||
GDK_WIN32_AEROSNAP_COMBO_SHIFTUP,
|
||||
GDK_WIN32_AEROSNAP_COMBO_SHIFTDOWN,
|
||||
GDK_WIN32_AEROSNAP_COMBO_SHIFTLEFT,
|
||||
GDK_WIN32_AEROSNAP_COMBO_SHIFTRIGHT
|
||||
};
|
||||
|
||||
typedef enum _GdkWin32AeroSnapCombo GdkWin32AeroSnapCombo;
|
||||
|
||||
enum _GdkWin32AeroSnapState
|
||||
{
|
||||
GDK_WIN32_AEROSNAP_STATE_UNDETERMINED = 0,
|
||||
GDK_WIN32_AEROSNAP_STATE_HALFLEFT,
|
||||
GDK_WIN32_AEROSNAP_STATE_HALFRIGHT,
|
||||
GDK_WIN32_AEROSNAP_STATE_FULLUP,
|
||||
/* Maximize state is only used by edge-snap */
|
||||
GDK_WIN32_AEROSNAP_STATE_MAXIMIZE
|
||||
};
|
||||
|
||||
typedef enum _GdkWin32AeroSnapState GdkWin32AeroSnapState;
|
||||
|
||||
struct _GdkRectangleDouble
|
||||
{
|
||||
double x;
|
||||
@@ -209,20 +179,6 @@ struct _GdkW32DragMoveResizeContext
|
||||
* (passing from one edge region into another doesn't count).
|
||||
*/
|
||||
gboolean revealed;
|
||||
|
||||
/* Arrays of GdkRectangle pairs, describing the areas of the virtual
|
||||
* desktop that trigger various AeroSnap window transformations
|
||||
* Coordinates are GDK screen coordinates.
|
||||
*/
|
||||
GArray *halfleft_regions;
|
||||
GArray *halfright_regions;
|
||||
GArray *maximize_regions;
|
||||
GArray *fullup_regions;
|
||||
|
||||
/* Current pointer position will result in this kind of snapping,
|
||||
* if the drag op is finished.
|
||||
*/
|
||||
GdkWin32AeroSnapState current_snap;
|
||||
};
|
||||
|
||||
typedef struct _GdkW32DragMoveResizeContext GdkW32DragMoveResizeContext;
|
||||
@@ -285,22 +241,6 @@ struct _GdkWin32Surface
|
||||
|
||||
GdkW32DragMoveResizeContext drag_move_resize_context;
|
||||
|
||||
/* Remembers where the surface was snapped.
|
||||
* Some snap operations change their meaning if
|
||||
* the surface is already snapped.
|
||||
*/
|
||||
GdkWin32AeroSnapState snap_state;
|
||||
|
||||
/* Remembers surface position before it was snapped.
|
||||
* This is used to unsnap it.
|
||||
* Position and size are percentages of the workarea
|
||||
* of the monitor on which the surface was before it was snapped.
|
||||
*/
|
||||
GdkRectangleDouble *snap_stash;
|
||||
|
||||
/* Also remember the same position, but in absolute form. */
|
||||
GdkRectangle *snap_stash_int;
|
||||
|
||||
/* Enable all decorations? */
|
||||
gboolean decorate_all;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user