pure-x11 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/example/query_pointer.rb +40 -0
- data/example/query_pointer_simple.rb +25 -0
- data/lib/X11/display.rb +4 -0
- data/lib/X11/form.rb +25 -4
- data/lib/X11/version.rb +1 -1
- metadata +4 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a54ae04997fddd16eaeea021a1b8141649b94c01fc4da4172395432fb119b768
         | 
| 4 | 
            +
              data.tar.gz: 67a426e9ecd3befd4e4d33c74a63a2504b1aff720c6a871cdf69c9900637b7eb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4c71571ad6cb34be6d9aa6d60871bba90efcc29931829035c93a11f7de9fa45741e4851179b03bf00ba2eff7aad26f2362c1323f35bf2f3f34eb2f787ca0a3f4
         | 
| 7 | 
            +
              data.tar.gz: 3b727bf9aa3be18791b50178a64766626655ce8c48f743333e142fe3b2cece7c4ecbb65a78e77dd54ea7c5ebb11959493ffcd1e265d247acc34e63a423ede4c8
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require_relative '../lib/X11'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            display = X11::Display.new
         | 
| 5 | 
            +
            root = display.screens.first.root
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Create a simple window
         | 
| 8 | 
            +
            window = display.create_window(
         | 
| 9 | 
            +
              100, 100, 400, 300,
         | 
| 10 | 
            +
              depth: 24,
         | 
| 11 | 
            +
              values: { X11::Form::CWBackPixel => 0xFFFFFF }
         | 
| 12 | 
            +
            )
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # Select input events (pointer motion)
         | 
| 15 | 
            +
            display.select_input(window, X11::Form::PointerMotionMask)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            # Map the window (make it visible)
         | 
| 18 | 
            +
            display.map_window(window)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            # Wait for window to be visible
         | 
| 21 | 
            +
            sleep(0.5)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            puts "Window created. Moving your mouse over the window will display coordinates."
         | 
| 24 | 
            +
            puts "Press Ctrl+C to exit."
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            # Main event loop
         | 
| 27 | 
            +
            display.run do |event|
         | 
| 28 | 
            +
              case event
         | 
| 29 | 
            +
              when X11::Form::MotionNotify
         | 
| 30 | 
            +
                # Query pointer position relative to window
         | 
| 31 | 
            +
                pointer = display.query_pointer(window)
         | 
| 32 | 
            +
                puts "Pointer position:"
         | 
| 33 | 
            +
                puts "  Window: (#{pointer.win_x}, #{pointer.win_y})"
         | 
| 34 | 
            +
                puts "  Root:   (#{pointer.root_x}, #{pointer.root_y})"
         | 
| 35 | 
            +
                puts "  Child:  #{pointer.child == 0 ? 'None' : pointer.child}"
         | 
| 36 | 
            +
                puts "  Mask:   #{pointer.mask.to_s(16)}"
         | 
| 37 | 
            +
                puts "  Same screen: #{pointer.same_screen}"
         | 
| 38 | 
            +
                puts "--------------------"
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require_relative '../lib/X11'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            # Create display connection
         | 
| 5 | 
            +
            display = X11::Display.new
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            # Get root window of first screen
         | 
| 8 | 
            +
            root = display.screens.first.root
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            puts "Move your mouse around and watch the coordinates update."
         | 
| 11 | 
            +
            puts "Press Ctrl+C to exit."
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            # Loop and query pointer position every 0.1 seconds
         | 
| 14 | 
            +
            loop do
         | 
| 15 | 
            +
              pointer = display.query_pointer(root)
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              system("clear") # Clear terminal
         | 
| 18 | 
            +
              puts "Pointer position relative to root window:"
         | 
| 19 | 
            +
              puts "  Root coordinates: (#{pointer.root_x}, #{pointer.root_y})"
         | 
| 20 | 
            +
              puts "  Window under pointer: #{pointer.child == 0 ? 'None' : pointer.child}"
         | 
| 21 | 
            +
              puts "  Button/modifier mask: #{pointer.mask.to_s(16)}"
         | 
| 22 | 
            +
              puts "  Same screen: #{pointer.same_screen}"
         | 
| 23 | 
            +
              
         | 
| 24 | 
            +
              sleep(0.1)
         | 
| 25 | 
            +
            end
         | 
    
        data/lib/X11/display.rb
    CHANGED
    
    | @@ -659,6 +659,10 @@ module X11 | |
| 659 659 | 
             
                def render_free_picture(picture)
         | 
| 660 660 | 
             
                  write_request(Form::XRenderFreePicture.new(render_opcode, picture))
         | 
| 661 661 | 
             
                end
         | 
| 662 | 
            +
                
         | 
| 663 | 
            +
                def query_pointer(window)
         | 
| 664 | 
            +
                  write_sync(Form::QueryPointer.new(window), Form::QueryPointerReply)
         | 
| 665 | 
            +
                end
         | 
| 662 666 |  | 
| 663 667 | 
             
                private
         | 
| 664 668 |  | 
    
        data/lib/X11/form.rb
    CHANGED
    
    | @@ -215,6 +215,10 @@ module X11 | |
| 215 215 | 
             
                ## X11 Packet Defintions
         | 
| 216 216 | 
             
                ##
         | 
| 217 217 |  | 
| 218 | 
            +
                class Reply < BaseForm
         | 
| 219 | 
            +
                  field :reply, Uint8
         | 
| 220 | 
            +
                end
         | 
| 221 | 
            +
             | 
| 218 222 | 
             
                class ClientHandshake < BaseForm
         | 
| 219 223 | 
             
                  field :byte_order, Uint8
         | 
| 220 224 | 
             
                  unused 1
         | 
| @@ -458,6 +462,27 @@ module X11 | |
| 458 462 | 
             
                  field :request_length, Uint16, value: 2
         | 
| 459 463 | 
             
                  field :window, Window
         | 
| 460 464 | 
             
                end
         | 
| 465 | 
            +
                
         | 
| 466 | 
            +
                class QueryPointer < BaseForm
         | 
| 467 | 
            +
                  field :opcode, Uint8, value: 38
         | 
| 468 | 
            +
                  unused 1
         | 
| 469 | 
            +
                  field :request_length, Uint16, value: 2
         | 
| 470 | 
            +
                  field :window, Window
         | 
| 471 | 
            +
                end
         | 
| 472 | 
            +
                
         | 
| 473 | 
            +
                class QueryPointerReply < Reply
         | 
| 474 | 
            +
                  field :same_screen, Bool
         | 
| 475 | 
            +
                  field :sequence_number, Uint16
         | 
| 476 | 
            +
                  field :reply_length, Uint32
         | 
| 477 | 
            +
                  field :root, Window
         | 
| 478 | 
            +
                  field :child, Window
         | 
| 479 | 
            +
                  field :root_x, Int16
         | 
| 480 | 
            +
                  field :root_y, Int16
         | 
| 481 | 
            +
                  field :win_x, Int16
         | 
| 482 | 
            +
                  field :win_y, Int16
         | 
| 483 | 
            +
                  field :mask, Uint16
         | 
| 484 | 
            +
                  unused 6
         | 
| 485 | 
            +
                end
         | 
| 461 486 |  | 
| 462 487 | 
             
                class ChangeSaveSet < BaseForm
         | 
| 463 488 | 
             
                  field :opcode, Uint8, value: 6
         | 
| @@ -553,10 +578,6 @@ module X11 | |
| 553 578 | 
             
                  field :name, String8, :string
         | 
| 554 579 | 
             
                end
         | 
| 555 580 |  | 
| 556 | 
            -
                class Reply < BaseForm
         | 
| 557 | 
            -
                  field :reply, Uint8
         | 
| 558 | 
            -
                end
         | 
| 559 | 
            -
             | 
| 560 581 | 
             
                class InternAtomReply < Reply
         | 
| 561 582 | 
             
                  unused 1
         | 
| 562 583 | 
             
                  field :sequence_number, Uint16
         | 
    
        data/lib/X11/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pure-x11
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.12
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Vidar Hokstad
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2025- | 
| 12 | 
            +
            date: 2025-04-05 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies: []
         | 
| 14 14 | 
             
            description: Pure Ruby X11 bindings
         | 
| 15 15 | 
             
            email:
         | 
| @@ -28,6 +28,8 @@ files: | |
| 28 28 | 
             
            - docs/protocol.pdf
         | 
| 29 29 | 
             
            - example/client_message.rb
         | 
| 30 30 | 
             
            - example/genie.png
         | 
| 31 | 
            +
            - example/query_pointer.rb
         | 
| 32 | 
            +
            - example/query_pointer_simple.rb
         | 
| 31 33 | 
             
            - example/test.rb
         | 
| 32 34 | 
             
            - lib/X11.rb
         | 
| 33 35 | 
             
            - lib/X11/auth.rb
         |