Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Patch to add window constraint functions

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Patch to add window constraint functions
jmasterx
Member #11,410
October 2009

Here is (what I hope is) the final version of the patch.

This one includes an example, and no more tabs. The example has been tested on all 3 platforms and performs consistently across all 3.

The example lets you press keys to toggle constraints so that is tested too.
It also displays the resolution and the result of al_get_constraints for easy debugging.

Here it is:
http://www.mediafire.com/?l7h595pp6cbtz67
{"name":"605085","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/9\/f99ee73ef41ecf75d04af0b10aa5d1eb.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/9\/f99ee73ef41ecf75d04af0b10aa5d1eb"}605085

Peter Wang
Member #23
April 2000

Where did the 9000 come from?

jmasterx
Member #11,410
October 2009

I needed some kind of value, I do not know how to get the maximum window size but I figure a window won't be bigger than 9000. Is there a better way?

Peter Wang
Member #23
April 2000

I don't know off the top of my head.

Also, the constraints don't apply to maximisation, at least on X. Should they? The docs don't say. I don't know if it's even possible, short of disabling the maximise button.

Anyway, the patch is in my local workspace with additional formatting fixes.

Matthew Leverton
Supreme Loser
January 1999
avatar

Also, the constraints don't apply to maximisation, at least on X. Should they?

On Windows and Linux, I would say no. They have a proper maximized state. (Windows does, at least. I guess it may vary on the window manager for Linux.) If the maximize button isn't wanted, then it should be disabled. I don't think Allegro should override it to provide non-standard functionality.

But OS X has that silly zoom button, so I think the constraint should apply there.

REVISION:

It appears that the maximize button was thrown into ALLEGRO_RESIZABLE, even though they are two distinct concepts. There should be two flags that control them separately.

jmasterx
Member #11,410
October 2009

On Windows and OSX, pressing the zoom, maximize etc maintains the constraints, and on Mint Linux for me maximizing respects the constraints, but remember, these are hints so the underlying window manager might not listen.

Here is what it looks like for me. Left is "maximized" right is not.

{"name":"605089","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/9\/393320cafed0b24dd8925835aea2b4ff.png","w":1680,"h":1050,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/9\/393320cafed0b24dd8925835aea2b4ff"}605089

Peter Wang
Member #23
April 2000

I've committed it now with some minor changes.

I saw on the Apple documentation that the window environment restricts windows to 10000 pixels so I replaced the 9000 with that. It also says the default is FLT_MAX so probably that's what we should be using in the no-constraint case. Can you check that and send a patch?

For X, I made it not set any size hints if all constraints are disabled. Again, removed the arbitrary limit of 9000.

jmasterx
Member #11,410
October 2009

Here is the patch.

I removed your comments about FLT_MAX and replaced 10000 with FLT_MAX. It compiled and works as well as before.

http://www.allegro.cc/files/attachment/605098

I was also wondering if this function will be able to go in the 5.0 branch (5.0.6) or if it breaks binary compatibility and thus must go into 5.1?

Peter Wang
Member #23
April 2000

It could. I've been considering a 5.0.6 release to backport some minor feature additions. It would be the first time we've done that, so I'd want to be doubly sure we don't break backwards compatibility.

jmasterx
Member #11,410
October 2009

I think as long as you do not change 5.0 function signatures I do not see how it could break backwards compatibility. I think dynamic libraries are intended with the idea of adding more functionality / functions without breaking the old.

Since things like ALLEGRO_DSPLAY are opaque data types to the user, the additions of data into ALLEGRO_DISPLAY should not be a problem.

Peter Wang
Member #23
April 2000

Of course, but shit happens.

jmasterx
Member #11,410
October 2009

You could get it tested by the community before officially releasing it. I'd be glad to test it out with some of my projects and see if it is still binary compatible.

Peter Wang
Member #23
April 2000

ex_window_constraints shows only the red background if I use video bitmaps and the Direct3D driver. Can you confirm this and investigate?

jmasterx
Member #11,410
October 2009

It seems this might be an Allegro bug. If I call al_resize_display before al_flip_display and after al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP) a call to al_resize_display seems to cause the backbuffer to stop working.

To 'fix' the example I simply moved the call to al_set_window_constraints to before setting the bitmap flag.

This bug shouldn't really affect developers since calls to al_resize_display and al_set_window_constraints are usually done before setting bitmap flags and after flipping the display but someone might eventually want to look into this.

 1   2 


Go to: