borderless

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@303 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-13 06:30:36 +00:00
parent 9fd99d3ab2
commit 28250bbaab
16 changed files with 104 additions and 2 deletions

View File

@@ -452,6 +452,9 @@
<dd>
<a href="#Mw_Widget_Window_h__MwWindowClass">MwWindowClass</a>
</dd>
<dd>
<a href="#Mw_Widget_Window_h__MwWindowMakeBorderless">MwWindowMakeBorderless</a>
</dd>
</dl>
<hr>
<h2 align="center" id="Mw_Constants_h">Mw/Constants.h</h2>
@@ -2694,6 +2697,28 @@
Window widget class.
</dd>
</dl>
<hr>
<pre id="Mw_Widget_Window_h__MwWindowMakeBorderless">MWDECL <B><FONT COLOR="#228B22">void</FONT></B> <B><FONT COLOR="#0000FF">MwWindowMakeBorderless</FONT></B> (
MwWidget handle,
<B><FONT COLOR="#228B22">int</FONT></B> toggle
);</pre>
<dl>
<dd>
Makes window borderless.
</dd>
<dt>
Parameter <code>handle</code>
</dt>
<dd>
Widget.
</dd>
<dt>
Parameter <code>toggle</code>
</dt>
<dd>
Toggle.
</dd>
</dl>
<hr>
</body>
</html>

View File

@@ -110,6 +110,7 @@ MWDECL void MwLLShow(MwLL handle, int show);
MWDECL void MwLLMakePopup(MwLL handle, MwLL parent);
MWDECL void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy);
MWDECL void MwLLMakeBorderless(MwLL handle, int toggle);
#ifdef __cplusplus
}

View File

@@ -19,6 +19,13 @@ extern "C" {
*/
MWDECL MwClass MwWindowClass;
/*!
* %brief Makes window borderless
* %param handle Widget
* %param toggle Toggle
*/
MWDECL void MwWindowMakeBorderless(MwWidget handle, int toggle);
#ifdef __cplusplus
}
#endif

View File

@@ -36,6 +36,7 @@ class Base {
virtual void OnMenu(void*) {};
virtual void OnMouseDownHandler(void*) {};
virtual void OnMouseUpHandler(void*) {};
virtual void OnMouseMoveHandler(void*) {};
virtual void OnChangedHandler(void*) {};
virtual void OnKeyHandler(void*) {};
virtual void OnKeyReleaseHandler(void*) {};

View File

@@ -8,6 +8,7 @@ namespace MwOO {
class Window : public MwOO::Base {
public:
Window(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);
void MakeBorderless(int toggle);
void SetTitle(const char* value);
const char* GetTitle(void);
void SetBackground(const char* value);

View File

@@ -92,6 +92,10 @@ static void __OnMouseUpHandler(MwWidget widget, void* user, void* call){
MwOO::Base* c = (MwOO::Base*)user;
(void)widget; c->OnMouseUpHandler(call);
}
static void __OnMouseMoveHandler(MwWidget widget, void* user, void* call){
MwOO::Base* c = (MwOO::Base*)user;
(void)widget; c->OnMouseMoveHandler(call);
}
static void __OnChangedHandler(MwWidget widget, void* user, void* call){
MwOO::Base* c = (MwOO::Base*)user;
(void)widget; c->OnChangedHandler(call);
@@ -116,6 +120,7 @@ void MwOO::Base::SetHandler(void){
MwAddUserHandler(this->widget, MwNmenuHandler, __OnMenu, this);
MwAddUserHandler(this->widget, MwNmouseDownHandler, __OnMouseDownHandler, this);
MwAddUserHandler(this->widget, MwNmouseUpHandler, __OnMouseUpHandler, this);
MwAddUserHandler(this->widget, MwNmouseMoveHandler, __OnMouseMoveHandler, this);
MwAddUserHandler(this->widget, MwNchangedHandler, __OnChangedHandler, this);
MwAddUserHandler(this->widget, MwNkeyHandler, __OnKeyHandler, this);
MwAddUserHandler(this->widget, MwNkeyReleaseHandler, __OnKeyReleaseHandler, this);

View File

@@ -5,6 +5,9 @@
MwOO::Window::Window(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwWindowClass, widget_name, parent, x, y, w, h){
}
void MwOO::Window::MakeBorderless(int toggle){
MwWindowMakeBorderless(this->widget, toggle);
}
void MwOO::Window::SetTitle(const char* value){
MwSetText(this->widget, MwNtitle, value);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 B

After

Width:  |  Height:  |  Size: 498 B

View File

@@ -488,3 +488,17 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
u->max.x = maxx;
u->max.y = maxy;
}
void MwLLMakeBorderless(MwLL handle, int toggle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
if(toggle) {
lp &= ~WS_CAPTION;
} else {
lp |= WS_CAPTION;
}
SetWindowLongPtr(handle->hWnd, GWL_STYLE, lp);
SetWindowPos(handle->hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}

View File

@@ -1,6 +1,25 @@
/* $Id$ */
#include <Mw/Milsko.h>
typedef struct mwm_hints {
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long input_mode;
unsigned long status;
} mwm_hints_t;
enum mwm_hints_enum {
MWM_HINTS_FUNCTIONS = (1L << 0),
MWM_HINTS_DECORATIONS = (1L << 1),
MWM_FUNC_ALL = (1L << 0),
MWM_FUNC_RESIZE = (1L << 1),
MWM_FUNC_MOVE = (1L << 2),
MWM_FUNC_MINIMIZE = (1L << 3),
MWM_FUNC_MAXIMIZE = (1L << 4),
MWM_FUNC_CLOSE = (1L << 5)
};
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | KeymapNotify;
static void create_pixmap(MwLL handle) {
@@ -180,9 +199,9 @@ void MwLLNextEvent(MwLL handle) {
p.button = MwLLMouseWheelDown;
}
MwLLDispatch(handle, down, &p);
XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime);
MwLLDispatch(handle, down, &p);
} else if(ev.type == ButtonRelease) {
MwLLMouse p;
p.point.x = ev.xbutton.x;
@@ -562,3 +581,25 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
XSetWMSizeHints(handle->display, handle->window, hints, XA_WM_NORMAL_HINTS);
XFree(hints);
}
void MwLLMakeBorderless(MwLL handle, int toggle) {
Atom atom = XInternAtom(handle->display, "_MOTIF_WM_HINTS", 0);
mwm_hints_t hints;
int x = 0, y = 0;
Window child, root, parent;
Window* children;
unsigned int nchild;
XQueryTree(handle->display, handle->window, &root, &parent, &children, &nchild);
if(children != NULL) XFree(children);
XTranslateCoordinates(handle->display, parent, RootWindow(handle->display, DefaultScreen(handle->display)), 0, 0, &x, &y, &child);
hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = toggle ? 0 : 1;
XChangeProperty(handle->display, handle->window, atom, atom, 32, PropModeReplace, (unsigned char*)&hints, 5);
XUnmapWindow(handle->display, handle->window);
XMapWindow(handle->display, handle->window);
XMoveWindow(handle->display, handle->window, x, y);
}

View File

@@ -42,3 +42,7 @@ MwClass MwWindowClass = &MwWindowClassRec;
void MwWindowSetIcon(MwWidget handle, MwLLPixmap pixmap) {
MwLLSetIcon(handle->lowlevel, pixmap);
}
void MwWindowMakeBorderless(MwWidget handle, int toggle) {
MwLLMakeBorderless(handle->lowlevel, toggle);
}