fix sizehints bug

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@316 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-14 04:57:50 +00:00
parent e78ab55b5a
commit bf5e65a40d
3 changed files with 56 additions and 37 deletions

View File

@@ -101,6 +101,10 @@ int main() {
NULL); NULL);
MwWidget viewport = MwCreateWidget(MwViewportClass, "viewport", window, 5, 5, 630, 470 - 16 - 5); MwWidget viewport = MwCreateWidget(MwViewportClass, "viewport", window, 5, 5, 630, 470 - 16 - 5);
hints.min_width = hints.max_width = 640;
hints.min_height = hints.max_height = 480;
MwVaApply(window, MwNsizeHints, &hints, NULL);
MwVaCreateWidget(MwLabelClass, "label", window, 5, 470 - 16 + 5, 630, 16, MwVaCreateWidget(MwLabelClass, "label", window, 5, 470 - 16 + 5, 630, 16,
MwNtext, "Press left click to draw triangle, right click to undo", MwNtext, "Press left click to draw triangle, right click to undo",
NULL); NULL);
@@ -111,10 +115,6 @@ int main() {
opengl = MwCreateWidget(MwOpenGLClass, "opengl", MwViewportGetViewport(viewport), 0, 0, 1024, 768); opengl = MwCreateWidget(MwOpenGLClass, "opengl", MwViewportGetViewport(viewport), 0, 0, 1024, 768);
hints.min_width = hints.max_width = 640;
hints.min_height = hints.max_height = 480;
MwVaApply(window, MwNsizeHints, &hints, NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL); MwAddUserHandler(window, MwNtickHandler, tick, NULL);
MwAddUserHandler(opengl, MwNmouseDownHandler, mouse, NULL); MwAddUserHandler(opengl, MwNmouseDownHandler, mouse, NULL);
MwAddUserHandler(opengl, MwNmouseMoveHandler, mouse_move, NULL); MwAddUserHandler(opengl, MwNmouseMoveHandler, mouse_move, NULL);

View File

@@ -572,7 +572,17 @@ void MwLLMakePopup(MwLL handle, MwLL parent) {
} }
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) { void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
XSizeHints* hints = XAllocSizeHints(); XSizeHints* hints = XAllocSizeHints();
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 = PMinSize | PMaxSize; hints->flags = PMinSize | PMaxSize;
hints->min_width = minx; hints->min_width = minx;
hints->min_height = miny; hints->min_height = miny;
@@ -580,6 +590,10 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
hints->max_height = maxy; hints->max_height = maxy;
XSetWMSizeHints(handle->display, handle->window, hints, XA_WM_NORMAL_HINTS); XSetWMSizeHints(handle->display, handle->window, hints, XA_WM_NORMAL_HINTS);
XFree(hints); XFree(hints);
XUnmapWindow(handle->display, handle->window);
XMapWindow(handle->display, handle->window);
XMoveWindow(handle->display, handle->window, x, y);
} }
void MwLLMakeBorderless(MwLL handle, int toggle) { void MwLLMakeBorderless(MwLL handle, int toggle) {

View File

@@ -4,39 +4,39 @@
our $WIDTH = 80; our $WIDTH = 80;
sub l { sub l {
my $len = 0; my $len = 0;
my $last = 0; my $last = 0;
my @msg = split(/ /, $_[0]); my @msg = split(/ /, $_[0]);
foreach my $m (@msg){ foreach my $m (@msg) {
$len += 1 + length($m); $len += 1 + length($m);
$last = 0; $last = 0;
if($len > $WIDTH){ if ($len > $WIDTH) {
print(OUT "\n"); print(OUT "\n");
$len = 0; $len = 0;
$last = 1; $last = 1;
} }
print(OUT "$m "); print(OUT "$m ");
} }
if(!$last){ if (!$last) {
print(OUT "\n"); print(OUT "\n");
} }
} }
sub c { sub c {
my ($msg) = @_; my ($msg) = @_;
my $len = length($msg); my $len = length($msg);
if($_[1]){ if ($_[1]) {
$len = $_[1]; $len = $_[1];
} }
print(OUT (" " x (($WIDTH - $len) / 2)) . "$msg\n"); print(OUT (" " x (($WIDTH - $len) / 2)) . "$msg\n");
} }
sub h { sub h {
my ($msg) = @_; my ($msg) = @_;
print(OUT "\n"); print(OUT "\n");
print(OUT "$msg\n"); print(OUT "$msg\n");
print(OUT ("-" x length($msg)) . "\n"); print(OUT ("-" x length($msg)) . "\n");
print(OUT "\n"); print(OUT "\n");
} }
open(OUT, ">", "README.txt"); open(OUT, ">", "README.txt");
@@ -44,12 +44,16 @@ open(OUT, ">", "README.txt");
l(""); l("");
l("Greetings - Welcome to the Milsko GUI Toolkit (Version 1.0)"); l("Greetings - Welcome to the Milsko GUI Toolkit (Version 1.0)");
l(""); l("");
l(" This document contains a brief summary of the contents of this source distributions and building instructions for Milsko GUI Toolkit."); l(
" This document contains a brief summary of the contents of this source distributions and building instructions for Milsko GUI Toolkit."
);
l(""); l("");
c("Requirements"); c("Requirements");
l(""); l("");
l(" Milsko requires the Windows environment with GDI (so anything NT or 9x) or the Unix-like environment with X11 for runtime."); l(
" Milsko requires the Windows environment with GDI (so anything NT or 9x) or the Unix-like environment with X11 for runtime."
);
l(""); l("");
l(" To build Milsko for Windows, you must have one of following compilers:"); l(" To build Milsko for Windows, you must have one of following compilers:");
l(" * Visual C++ 6.0 or newer"); l(" * Visual C++ 6.0 or newer");
@@ -85,7 +89,8 @@ l("");
l(""); l("");
c("Building Milsko"); c("Building Milsko");
l(""); l("");
l(" Building Milsko depends on the platform you use, and the compiler you use."); l(" Building Milsko depends on the platform you use, and the compiler you use."
);
h("A. Visual C++"); h("A. Visual C++");
l("1) Run `nmake -f NTMakefile'."); l("1) Run `nmake -f NTMakefile'.");
h("B. Borland C++"); h("B. Borland C++");
@@ -104,10 +109,10 @@ l("");
c("This section exists for people who chose D.", 60); c("This section exists for people who chose D.", 60);
l(""); l("");
c("TARGET - Target environment, chosen by Makefile in", 60); c("TARGET - Target environment, chosen by Makefile in", 60);
c(" default settings.", 60); c(" default settings.", 60);
l(""); l("");
c("GCC - Prefix for GCC toolchains. This does not", 60); c("GCC - Prefix for GCC toolchains. This does not", 60);
c(" matter if you set CC/CXX manually.", 60); c(" matter if you set CC/CXX manually.", 60);
l(""); l("");
c("CC - C compiler.", 60); c("CC - C compiler.", 60);
l(""); l("");