1 package reader 2 3 // Options is used by the DisplayReader to configure how each field of 4 // the DisplayConfig will be queried. 5 type Options struct { 6 // Returns the resolution for each display as the preferred 7 // resolution rather than the currently configured resolution. 8 PreferredResolution bool 9 // Returns the default layout (displays ordered right-to-left 10 // as they are found), rather than their currently configured 11 // layout. 12 DefaultLayout bool 13 // Ignores input devices which do not have an absolute mode. 14 IgnoreRelativeInputDevices bool 15 // Ignore querying display resolutions (current resolution 16 // will still be queried). 17 IgnoreSupportedResolutions bool 18 } 19 20 func CreateOptions(options ...Option) Options { 21 opts := &Options{} 22 for _, o := range options { 23 o(opts) 24 } 25 return *opts 26 } 27 28 // A Option is used to modify how the Reader obtains the 29 // DisplayConfig fields. 30 type Option func(*Options) 31 32 // WithPreferredResolution instructs the reader to return the 33 // resolution for each display as the preferred resolution 34 // rather than the currently configured resolution. 35 func WithPreferredResolution() Option { 36 return func(opts *Options) { 37 opts.PreferredResolution = true 38 } 39 } 40 41 // WithDefaultLayout tells the reader to return the default 42 // layout (displays ordered right-to-left as they are found), 43 // rather than their currently configured layout. 44 func WithDefaultLayout() Option { 45 return func(opts *Options) { 46 opts.DefaultLayout = true 47 } 48 } 49 50 // WithAbsoluteInputDevices instructs the reader to 51 // obtain absolute input devices only. 52 func WithIgnoreRelativeInputDevices() Option { 53 return func(opts *Options) { 54 opts.IgnoreRelativeInputDevices = true 55 } 56 } 57 58 // WithIgnoreSupportedResolutions instructs the reader to ignore 59 // querying display resolutions (current resolution will 60 // still be queried). 61 func WithIgnoreSupportedResolutions() Option { 62 return func(opts *Options) { 63 opts.IgnoreSupportedResolutions = true 64 } 65 } 66