Mercurial > dwindows
comparison gtk4/dw.c @ 2320:829228de003f
GTK4: Use package gtk4-x11 instead of gtk4 so we can call Xlib directly to
fill in the gaps of removed functionality. Apparently Wayland has no
globaly coordinate system? So this will only work on X11 not Wayland.
This enables basic functionality for window positioning. Might need to port
some of the workarounds back from GTK3 that got removed in the rewrite.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 16 Feb 2021 14:14:54 +0000 |
parents | 36522ed00ef8 |
children | 52ca7647f665 |
comparison
equal
deleted
inserted
replaced
2319:36522ed00ef8 | 2320:829228de003f |
---|---|
27 #include <fcntl.h> | 27 #include <fcntl.h> |
28 #include <unistd.h> | 28 #include <unistd.h> |
29 #include <math.h> | 29 #include <math.h> |
30 #include <gdk/gdkkeysyms.h> | 30 #include <gdk/gdkkeysyms.h> |
31 | 31 |
32 #ifdef GDK_WINDOWING_X11 | |
33 #include <gdk/x11/gdkx.h> | |
34 #endif | |
32 | 35 |
33 #ifdef USE_WEBKIT | 36 #ifdef USE_WEBKIT |
34 #include <webkit2/webkit2.h> | 37 #include <webkit2/webkit2.h> |
35 #endif | 38 #endif |
36 | 39 |
1684 /* | 1687 /* |
1685 * Makes the window topmost. | 1688 * Makes the window topmost. |
1686 * Parameters: | 1689 * Parameters: |
1687 * handle: The window handle to make topmost. | 1690 * handle: The window handle to make topmost. |
1688 */ | 1691 */ |
1692 #ifndef GDK_WINDOWING_X11 | |
1689 int dw_window_raise(HWND handle) | 1693 int dw_window_raise(HWND handle) |
1690 { | 1694 { |
1691 /* TODO: See if this is possible in GTK4 */ | |
1692 return DW_ERROR_UNKNOWN; | 1695 return DW_ERROR_UNKNOWN; |
1693 } | 1696 } |
1697 #else | |
1698 DW_FUNCTION_DEFINITION(dw_window_raise, int, HWND handle) | |
1699 DW_FUNCTION_ADD_PARAM1(handle) | |
1700 DW_FUNCTION_RETURN(dw_window_raise, int) | |
1701 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) | |
1702 { | |
1703 int retval = DW_ERROR_UNKNOWN; | |
1704 | |
1705 if(handle && GTK_IS_WINDOW(handle)) | |
1706 { | |
1707 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle)); | |
1708 | |
1709 if(surface) | |
1710 { | |
1711 XRaiseWindow(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface)); | |
1712 retval = DW_ERROR_NONE; | |
1713 } | |
1714 } | |
1715 DW_FUNCTION_RETURN_THIS(retval); | |
1716 } | |
1717 #endif | |
1694 | 1718 |
1695 /* | 1719 /* |
1696 * Makes the window bottommost. | 1720 * Makes the window bottommost. |
1697 * Parameters: | 1721 * Parameters: |
1698 * handle: The window handle to make bottommost. | 1722 * handle: The window handle to make bottommost. |
1699 */ | 1723 */ |
1724 #ifndef GDK_WINDOWING_X11 | |
1700 int dw_window_lower(HWND handle) | 1725 int dw_window_lower(HWND handle) |
1701 { | 1726 { |
1702 /* TODO: See if this is possible in GTK4 */ | |
1703 return DW_ERROR_UNKNOWN; | 1727 return DW_ERROR_UNKNOWN; |
1704 } | 1728 } |
1729 #else | |
1730 DW_FUNCTION_DEFINITION(dw_window_lower, int, HWND handle) | |
1731 DW_FUNCTION_ADD_PARAM1(handle) | |
1732 DW_FUNCTION_RETURN(dw_window_lower, int) | |
1733 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) | |
1734 { | |
1735 int retval = DW_ERROR_UNKNOWN; | |
1736 | |
1737 if(handle && GTK_IS_WINDOW(handle)) | |
1738 { | |
1739 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle)); | |
1740 | |
1741 if(surface) | |
1742 { | |
1743 XLowerWindow(GDK_SURFACE_XDISPLAY(surface), GDK_SURFACE_XID(surface)); | |
1744 retval = DW_ERROR_NONE; | |
1745 } | |
1746 } | |
1747 DW_FUNCTION_RETURN_THIS(retval); | |
1748 } | |
1749 #endif | |
1705 | 1750 |
1706 /* | 1751 /* |
1707 * Makes the window visible. | 1752 * Makes the window visible. |
1708 * Parameters: | 1753 * Parameters: |
1709 * handle: The window handle to make visible. | 1754 * handle: The window handle to make visible. |
8481 * Parameters: | 8526 * Parameters: |
8482 * handle: Window (widget) handle. | 8527 * handle: Window (widget) handle. |
8483 * x: X location from the bottom left. | 8528 * x: X location from the bottom left. |
8484 * y: Y location from the bottom left. | 8529 * y: Y location from the bottom left. |
8485 */ | 8530 */ |
8531 #ifndef GDK_WINDOWING_X11 | |
8486 void dw_window_set_pos(HWND handle, long x, long y) | 8532 void dw_window_set_pos(HWND handle, long x, long y) |
8487 { | 8533 { |
8488 /* TODO: Figure out how to do this in GTK4 with no GdkWindow */ | 8534 } |
8489 } | 8535 #else |
8490 | 8536 DW_FUNCTION_DEFINITION(dw_window_set_pos, void, HWND handle, long x, long y) |
8537 DW_FUNCTION_ADD_PARAM3(handle, x, y) | |
8538 DW_FUNCTION_NO_RETURN(dw_window_set_pos) | |
8539 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, x, long, y, long) | |
8540 { | |
8541 if(handle && GTK_IS_WINDOW(handle)) | |
8542 { | |
8543 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle)); | |
8544 | |
8545 if(surface) | |
8546 { | |
8547 XMoveWindow(GDK_SURFACE_XDISPLAY(surface), | |
8548 GDK_SURFACE_XID(surface), | |
8549 x, y); | |
8550 } | |
8551 } | |
8552 DW_FUNCTION_RETURN_NOTHING; | |
8553 } | |
8554 #endif | |
8491 /* | 8555 /* |
8492 * Sets the position and size of a given window (widget). | 8556 * Sets the position and size of a given window (widget). |
8493 * Parameters: | 8557 * Parameters: |
8494 * handle: Window (widget) handle. | 8558 * handle: Window (widget) handle. |
8495 * x: X location from the bottom left. | 8559 * x: X location from the bottom left. |
8515 DW_FUNCTION_DEFINITION(dw_window_get_pos_size, void, HWND handle, long *x, long *y, ULONG *width, ULONG *height) | 8579 DW_FUNCTION_DEFINITION(dw_window_get_pos_size, void, HWND handle, long *x, long *y, ULONG *width, ULONG *height) |
8516 DW_FUNCTION_ADD_PARAM5(handle, x, y, width, height) | 8580 DW_FUNCTION_ADD_PARAM5(handle, x, y, width, height) |
8517 DW_FUNCTION_NO_RETURN(dw_window_get_pos_size) | 8581 DW_FUNCTION_NO_RETURN(dw_window_get_pos_size) |
8518 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, x, long *, y, long *, width, ULONG *, height, ULONG *) | 8582 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, x, long *, y, long *, width, ULONG *, height, ULONG *) |
8519 { | 8583 { |
8520 /* TODO: Figure out how to do this in GTK4 with no GdkWindow */ | |
8521 if(handle && GTK_IS_WIDGET(handle)) | 8584 if(handle && GTK_IS_WIDGET(handle)) |
8522 { | 8585 { |
8523 if(width) | 8586 if(width) |
8524 *width = (ULONG)gtk_widget_get_width(GTK_WIDGET(handle)); | 8587 *width = (ULONG)gtk_widget_get_width(GTK_WIDGET(handle)); |
8525 if(height) | 8588 if(height) |
8526 *height = (ULONG)gtk_widget_get_height(GTK_WIDGET(handle)); | 8589 *height = (ULONG)gtk_widget_get_height(GTK_WIDGET(handle)); |
8590 | |
8591 #ifdef GDK_WINDOWING_X11 | |
8592 { | |
8593 GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(handle)); | |
8594 | |
8595 if(surface) | |
8596 { | |
8597 XWindowAttributes xwa; | |
8598 | |
8599 XGetWindowAttributes(GDK_SURFACE_XDISPLAY(surface), | |
8600 GDK_SURFACE_XID(surface), &xwa); | |
8601 if(x) | |
8602 *x = (long)xwa.x; | |
8603 if(y) | |
8604 *y = (long)xwa.y; | |
8605 } | |
8606 } | |
8607 #else | |
8527 if(x) | 8608 if(x) |
8528 *x = 0; | 8609 *x = 0; |
8529 if(y) | 8610 if(y) |
8530 *y = 0; | 8611 *y = 0; |
8612 #endif | |
8531 } | 8613 } |
8532 DW_FUNCTION_RETURN_NOTHING; | 8614 DW_FUNCTION_RETURN_NOTHING; |
8533 } | 8615 } |
8534 | 8616 |
8535 /* | 8617 /* |