Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 5.1.9 (GIT) -- al_set_new_window_position

This thread is locked; no one can reply to it. rss feed Print
Allegro 5.1.9 (GIT) -- al_set_new_window_position
Stagera
Member #4,606
May 2004

Hi,
I'm trying to create a 100*100 window in the middle of the screen. My resolution is 1920x1080.
I've set the upper-left corner at 960,540 but the windows is drawn further (Screenshot attached).

Maybe someone can help me out

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3 4int main(int argc, char **argv) 5{ 6 ALLEGRO_DISPLAY *display = NULL; 7 8 al_init(); 9 ALLEGRO_MONITOR_INFO info; 10 al_get_monitor_info(0, &info); 11 12 fprintf(stderr, "info.x1: %d -- info.x2: %d\n", info.x1,info.x2); 13 fprintf(stderr, "info.y1: %d -- info.y2: %d\n\n", info.y1,info.y2); 14 15 al_set_new_window_position(info.x2 / 2, info.y2 / 2); 16 fprintf(stderr, "set new window position: %d %d\n\n", info.x2 / 2, info.y2 / 2); 17 al_set_new_display_flags (ALLEGRO_FRAMELESS); 18 display = al_create_display(100, 100); 19 al_clear_to_color(al_map_rgb(0,0,0)); 20 al_flip_display(); 21 22 int x,y; 23 al_get_window_position(display, &x, &y); 24 fprintf(stderr, "get window position: %d %d\n\n", x, y); 25 26 al_rest(10.0); 27 28 al_destroy_display(display); 29 return 0; 30}

pkrcel
Member #14,001
February 2012

I can't really evaluate the apparent discrepancy from the screenshot

the top lef corner seems indeed a bit off....try drawing the window WITH the frame and check wehre that ends up drwan.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Stagera
Member #4,606
May 2004

Hi pkrcel,
the gap is always present, also when I draw the frame.

The screenshot refer to my last test. I did several.
With a bigger window it's more noticeable

Update
On Windows Seven/XP the window is correctly created in the middle of the screen
Displacement happens only on Windows 8 (8.1)

SiegeLord
Member #7,827
October 2006
avatar

Stagera said:

Displacement happens only on Windows 8 (8.1)

Damn, I was going to try to fix this, but I only have Windows 7 :-/.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Stagera
Member #4,606
May 2004

Also the window size is messed up on my Windows 8.1
The real size of a 100*100 window (no frame) is 125*125 pixel

Go to: