Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select screen in a multi screen enviornment #2

Open
coderhs opened this issue Jun 2, 2022 · 2 comments
Open

Select screen in a multi screen enviornment #2

coderhs opened this issue Jun 2, 2022 · 2 comments

Comments

@coderhs
Copy link

coderhs commented Jun 2, 2022

Is it possible to select second screen or system primary screen when running this script. I was testing on a laptop with an external monitor on a linux machine (kubuntu). I had the second bigger screen set as my primary display, but it still picked up the laptop screen and was only tracking movement on that.

Any way to select screen or default to primary screen?

@coderhs
Copy link
Author

coderhs commented Jun 2, 2022

I ran this code in python (interactive), got the following output.

<VideoInfo(hw = 0, wm = 1,video_mem = 0
         blit_hw = 0, blit_hw_CC = 0, blit_hw_A = 0,
         blit_sw = 0, blit_sw_CC = 0, blit_sw_A = 0,
         bitsize  = 32, bytesize = 4,
         masks =  (16711680, 65280, 255, 0),
         shifts = (16, 8, 0, 0),
         losses =  (0, 0, 0, 8),
         current_w = 2560, current_h = 1080
>

That is the right resolution for the primary screen I am using. I think the issue is co-ordinates 0,0 is not in this screen but on the laptop as the laptop is left to my monitor.

@coderhs
Copy link
Author

coderhs commented Jun 2, 2022

Just an update:

I cloned the code and hacked around. It is getting the right co-ordinates with respect to the screen like (4152, 249), but that co-ordinate is beyond the bg.surface which is set to 2560 and 1080. I wrote a hacky solution to make it work

         w, h = screen.current_w, screen.current_h
+        self.width = w
         self.window_surface = pg.display.set_mode((w, h), pg.RESIZABLE)
         self.ui_manager = pg_gui.UIManager((w, h))
         self.bg = pg.Surface((w, h))
@@ -110,12 +111,14 @@ class Karbon:
             pg.display.update()
 
     def on_click(self, x, y, button, pressed):
+        x = x - self.width
         if button is button.left:
             pg.draw.circle(self.bg, YELLOW, (x, y), 4)
         elif button is button.right:
             pg.draw.circle(self.bg, (128, 0, 128), (x, y), 6)
 
     def on_move(self, x, y):
+        x = x - self.width
         pg.draw.line(self.bg, LINE_COLOR, (x, y), (x, y), 1)

I feel like being able to control the monitor for tracking would be a cool addition to this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant