Screen area only targets one screen in twinview setup

Bug #666701 reported by Oli
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Nanoshot
Status tracked in 0.2
0.2
Fix Released
Undecided
Vlad

Bug Description

I have two monitors plugged into one Nvidia card, running under Ubuntu.

When you do the default Area Select option it only greys out the primary screen (and therefore only lets you select an area from that screen).

This might be the same with other technologies but I can only test nvidia.

Vlad (vvladxx)
Changed in nanoshot:
status: New → Confirmed
assignee: nobody → Vlad (vvladxx)
Revision history for this message
Vlad (vvladxx) wrote :

Hi!
I'm currently working on this problem. But I've never used TwinView and I can't understand how it works.
Can you help me? Please run this and post the output:

python -c "import gtk
dm=gtk.gdk.display_manager_get()
for d in dm.list_displays():
    print(d.get_name(), d.get_n_screens())"

Revision history for this message
Oli (oli) wrote : Re: [Bug 666701] Re: Screen area only targets one screen in twinview setup

Thanks for getting back to me so fast. The return of your code was:

(':0.0', 1)

I also ran the following in a Python console to try and help:

>>> import gtk.gdk
>>> screen = gtk.gdk.screen_get_default()
>>> print "X default screen size: %d x %d" % (screen.get_width(),
screen.get_height())
X default screen size: 3840 x 1200
>>> print "xid of root window: %d" % screen.get_root_window().xid
xid of root window: 349
>>> monitors = int(screen.get_n_monitors())
>>> print "== %d monitors ==" % monitors
== 2 monitors ==
>>> for m in range(0, monitors):
... print " - geometry of monitor %d: %s" % (m,
screen.get_monitor_geometry(m))
...
 - geometry of monitor 0: gtk.gdk.Rectangle(0, 0, 1920, 1200)
 - geometry of monitor 1: gtk.gdk.Rectangle(1920, 0, 1920, 1200)

It *looks* like instead of getting the display manager from gtk, you should
get the screen (as twinview counts both monitors as one screen, unlike
xinerama IIRC). From that you can count the screens and then work out the
geometry.

In my case where both monitors have the same geometry, one giant rectangle
across the two monitors would work but you should also consider how this
would work for people whose monitors have different geometry. I think a
giant spanning rect could work but you'd need to work out the maximum
dimensions so the rect would be:

width = 0
height = 0

for w, h in [(screen.get_monitor_geometry(m).width,
screen.get_monitor_geometry(m).height) for m in range(0, monitors)]:
    width += w
    if h > height: height = h

In my case:

>>> print width, height
3840 1200

Revision history for this message
Vlad (vvladxx) wrote :

Thank you for the detailed explanation. It helps me a lot.
I think that the right way is to calculate the mouse pointer position, and then display the crop tool where the pointer is.
Can you check if this code returns correct coordinates for both of your monitors?

python -c "import gtk; print gtk.gdk.screen_get_default().get_root_window().get_pointer();"

for second monitor this should return X > 1920.

Revision history for this message
Oli (oli) wrote :

Ran from the two extreme corners of my X screen:

>>> gtk.gdk.screen_get_default().get_root_window().get_pointer()
(0, 0, <flags GDK_MOD2_MASK of type GdkModifierType>)

>>> gtk.gdk.screen_get_default().get_root_window().get_pointer()
(3839, 1199, <flags GDK_MOD2_MASK of type GdkModifierType>)

I've just noticed there's a get_geometry() function on the gtk window class.

>>> gtk.gdk.screen_get_default().get_root_window().get_geometry()
(0, 0, 3840, 1200, 24)

I'm not sure what's best for positioning the crop tool. I tend to move my
cursor out of the way if I don't want the cursor in-shot (I know I can turn
it off, it's just by habit) but this would mean the mouse is not in the
place I want it.

I think detecting the active window and its geometry is probably going to
help people more. You already have the logic for that in the windowshot
code.

On Wed, Oct 27, 2010 at 11:44 AM, Vlad <email address hidden> wrote:

> Thank you for the detailed explanation. It helps me a lot.
> I think that the right way is to calculate the mouse pointer position, and
> then display the crop tool where the pointer is.
> Can you check if this code returns correct coordinates for both of your
> monitors?
>
> python -c "import gtk; print
> gtk.gdk.screen_get_default().get_root_window().get_pointer();"
>
> for second monitor this should return X > 1920.
>
> --
> Screen area only targets one screen in twinview setup
> https://bugs.launchpad.net/bugs/666701
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Vlad (vvladxx) wrote :

I tried to fix it in the last commit. Please check if the crop tool works properly

git clone git://nanoshot.git.sourceforge.net/gitroot/nanoshot/nanoshot
cd nanoshot
./Nanoshot

I did this (temporarily) based on the cursor coordinates. I'll try to implement your idea later.

Revision history for this message
Oli (oli) wrote :

Not quite.

When the cursor is on the second monitor, the Selector area loads on the
second monitor but only the second monitor. And drag events don't work on it
because it's limited to the geometry of the first monitor. If I drag from
the second monitor to the first, I can create a selection area but this is
clearly not how it's supposed to work.

Ideally I think this should load the overlay over all monitors and obviously
the selector positioning should work too.

All my Python experience is in writing backend webdevelopment stuff (never
any GTK) but I'm going to dive into this and see if I can find out how to
solve this problem. I suspect it's all in lib/Selector.py ~line 37

Revision history for this message
Oli (oli) wrote :

Success!! I'm attaching a patch.

You were very close. You didn't need to worry about monitors, you just
needed the root screen. I've therefore dumped the pointer and monitor lines
from the code as they weren't used anywhere else.

Unrelated to this problem (except it's for the screen area shot again) is
that you can't overlay the panel. I'll have another poke as this should be
another simple fix.

Revision history for this message
Vlad (vvladxx) wrote :

Strange...
You have made almost the same, as were before my unworking fix :) See diff between commits - http://bit.ly/bPRrfv
Maybe because of this line

drawingWindow.set_geometry_hints(min_width = width, min_height = height, max_width = width, max_height = height)

it doesn't goes fullscreen and panel is above. Try to replace it with drawingWindow.resize(width, height)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.