Function/field for distinguishing if a widget is using global/local coordinates. #3
6 changed files with 30 additions and 5 deletions
|
|
@ -354,6 +354,11 @@ MWDECL void MwGetCursorCoord(MwWidget handle, MwPoint* point);
|
||||||
*/
|
*/
|
||||||
MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect);
|
MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Reports whether a widget reports global or local coordinates upon GetXY/SetXY. Anything with a parent reports local, and most backends report global coordinates being supported for top level windows, but some (Wayland) do not.
|
||||||
|
*/
|
||||||
|
MWDECL int MwGetCoordinateType(MwWidget handle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ struct _MwLLCommon {
|
||||||
void* user;
|
void* user;
|
||||||
int copy_buffer;
|
int copy_buffer;
|
||||||
int type;
|
int type;
|
||||||
|
int coordinate_type;
|
||||||
|
|
||||||
MwLLHandler handler;
|
MwLLHandler handler;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -219,4 +219,10 @@ struct _MwClass {
|
||||||
void* reserved4;
|
void* reserved4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Whether or not GetXY/SetXY works with global or local coordinates */
|
||||||
|
enum MwCoordinateType {
|
||||||
|
MwCoordinatesGlobal = 0,
|
||||||
|
MwCoordinatesLocal,
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1299,7 +1299,6 @@ static void setup_popup(MwLL r, int x, int y) {
|
||||||
xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE);
|
xdg_positioner_set_anchor(r->wayland.popup->xdg_positioner, XDG_POSITIONER_ANCHOR_NONE);
|
||||||
xdg_positioner_set_anchor_rect(
|
xdg_positioner_set_anchor_rect(
|
||||||
r->wayland.popup->xdg_positioner, 0, 0, 1, 1);
|
r->wayland.popup->xdg_positioner, 0, 0, 1, 1);
|
||||||
printf("%d, %d\n", x, y);
|
|
||||||
xdg_positioner_set_offset(r->wayland.popup->xdg_positioner, x, y);
|
xdg_positioner_set_offset(r->wayland.popup->xdg_positioner, x, y);
|
||||||
|
|
||||||
xdg_surface = topmost_parent->wayland.toplevel->xdg_surface;
|
xdg_surface = topmost_parent->wayland.toplevel->xdg_surface;
|
||||||
|
|
@ -1344,6 +1343,10 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
memset(r, 0, sizeof(*r));
|
memset(r, 0, sizeof(*r));
|
||||||
MwLLCreateCommon(r);
|
MwLLCreateCommon(r);
|
||||||
|
|
||||||
|
/* Wayland does not report global coordinates ever. Compositors are not even expected to have knowledge of this.
|
||||||
|
*/
|
||||||
|
r->common.coordinate_type = MwCoordinatesLocal;
|
||||||
|
|
||||||
r->common.type = MwLLBackendWayland;
|
r->common.type = MwLLBackendWayland;
|
||||||
|
|
||||||
if(width < 2) width = 2;
|
if(width < 2) width = 2;
|
||||||
|
|
|
||||||
|
|
@ -797,3 +797,11 @@ void MwGetCursorCoord(MwWidget handle, MwPoint* point) {
|
||||||
void MwGetScreenSize(MwWidget handle, MwRect* rect) {
|
void MwGetScreenSize(MwWidget handle, MwRect* rect) {
|
||||||
MwLLGetScreenSize(handle->lowlevel, rect);
|
MwLLGetScreenSize(handle->lowlevel, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MwGetCoordinateType(MwWidget handle) {
|
||||||
|
if(handle->parent == NULL) {
|
||||||
|
return handle->lowlevel->common.coordinate_type;
|
||||||
|
} else {
|
||||||
|
return MwCoordinatesLocal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -183,10 +183,12 @@ static void mwSubMenuAppearImpl(MwWidget handle, MwMenu menu, MwPoint* point, in
|
||||||
MwLLMakeToolWindow(handle->lowlevel);
|
MwLLMakeToolWindow(handle->lowlevel);
|
||||||
MwLLDetach(handle->lowlevel, &p);
|
MwLLDetach(handle->lowlevel, &p);
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNy) + sz.height > rc.height) {
|
if(handle->lowlevel->common.coordinate_type == MwCoordinatesGlobal) {
|
||||||
MwVaApply(handle,
|
if(MwGetInteger(handle, MwNy) + sz.height > rc.height) {
|
||||||
MwNy, rc.height - sz.height,
|
MwVaApply(handle,
|
||||||
NULL);
|
MwNy, rc.height - sz.height,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLEndStateChange(handle->lowlevel);
|
MwLLEndStateChange(handle->lowlevel);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue