PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Fixed monitor (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Fixed monitor


#55
Fragarach 87 (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Fixed monitor 6 Years, 8 Months ago Karma: 0  
Does anyone know of a way to set your application to open on the last monitor the application was closed on.

I've got two monitors hooked up on windows vista and when my mouse is over one monitor the application will open on that monitor. I'd like it to open on the monitor that I last closed it on. I've also noticed this on Ubuntu Linux as well.
 
  The administrator has disabled public write access.

#65
Fragarach 87 (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Re:Fixed monitor 6 Years, 8 Months ago Karma: 0  
I've been looking at GdkScreen::get_monitor_geometry() but it seems to be broken. And sense I can't seem to find a way to set the monitor. Assuming monitor 1 is to the left of 0, this appears to be the only way to get the display correctly:

Code:
$scr=$wnd->get_screen();
$pos=$wnd->get_position();

$curr=$scr->get_monitor_at_point($pos[0],$pos[1]);

if($curr!=0) {
    for($i=0;$iget_n_monitors();$i++) {
        $geo=new GdkRectangle(0,0,0,0);
        
        $scr->get_monitor_geometry(0,$geo);
        
        var_dump($geo);
    }
}
However this results in, because of the broken get_monitor_geometry(): object(GdkRectangle)#120 (4) { ["x"]=> int(0) ["y"]=> int(0) ["width"]=> int(0) ["height"]=> int(0) } So its useless. Is there a function out there that will let me set the monitor? Any help would be greatly appreciated.
 
  The administrator has disabled public write access.

#67
Fragarach 87 (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Re:Fixed monitor 6 Years, 8 Months ago Karma: 0  
I solved the problem by using the gdkwindow's position and the gtkwindow's position to determine the decorator width when you first run the application. Then from there on in I use gdkwindow's position and subtract the decorator width which gives me the exact position.

I changed my idea from getting it to always open on the same display to just open where it was closed.
 
  The administrator has disabled public write access.
#68
kksou (Admin)
Admin
Posts: 1728
graph
User Online Now Click here to see the profile of this user
Re:Fixed monitor 6 Years, 8 Months ago Karma: 27  
Hi Fragarach 87,

Thanks much for sharing.

Out of curiosity, I borrowed a monitor from my friend and did some trials and errors.

Came out with a sample code that allows you to open an application at last saved position:

Sample Code 438: How to open an application at last window position

This works on multiple monitors too. If you exit the application from the second monitor and go back in again, the application will be opened at the same position in the second monitor.

Regards,
/kksou

p.s. I tried GdkScreen::get_monitor_geometry() too. Yes, it doesn't work. In C, the second parameter (GdkRectangle) is a pointer. In PHP, apparently it's not a pointer, and it doesn't return a GdkRectangle. So I guess at this point in time, there's no way to get the screen size for each of the monitor.
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved