Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/classes/options.vala
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,50 @@ namespace pdfpc {
* Position of notes on slides
*/
public static string? notes_position = null;

/**
* Other screen to use
*/
public static string? other_screen = null;
}

/**
* Screen number and monitor number passed in as
* [ScreenNum][/MonitorNum]
*/
public struct ScreenMonitorNum {
/**
* Screen number, default to unspecified (-1)
*/
public int screen_num;

/**
* Monitor number, default to unspecified (-1)
*/
public int monitor_num;

/**
* Parse options into this structure
* [ScreenNum][/MonitorNum]
*/
public ScreenMonitorNum(string? screen_monitor_str) {
this.screen_num = -1;
this.monitor_num = -1;

if (screen_monitor_str == null) {
return;
}

if (screen_monitor_str.scanf("%d/%d", &this.screen_num, &this.monitor_num) <= 0) {
screen_monitor_str.scanf("/%d", &this.monitor_num);
}
}

/**
* Parse options into new structure
*/
public static ScreenMonitorNum from_string(string? screen_monitor_str) {
return ScreenMonitorNum(screen_monitor_str);
}
}
}
46 changes: 34 additions & 12 deletions src/classes/window/fullscreen.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,43 @@ namespace pdfpc.Window {
*/
protected bool frozen = false;

public Fullscreen( int screen_num ) {
/**
* Screen and monitor number
*/
protected int screen_num = -1;
protected int monitor_num = -1;

public Fullscreen( int screen_num, int monitor_num ) {
var display = Gdk.Display.get_default();
Gdk.Screen screen;

if ( screen_num >= 0 ) {
// Start in the given monitor
screen = Screen.get_default();
screen.get_monitor_geometry( screen_num, out this.screen_geometry );
} else {
// Start in the monitor the cursor is in
var display = Gdk.Display.get_default();
int pointerx, pointery;
display.get_pointer(out screen, out pointerx, out pointery, null);
int current_screen = screen.get_monitor_at_point(pointerx, pointery);
screen.get_monitor_geometry( current_screen, out this.screen_geometry );
// Start in the given screen
if (screen_num >= 0) {
screen = display.get_screen(screen_num);
if ( monitor_num >= 0 ) {
// Start in the given monitor
screen.get_monitor_geometry( monitor_num, out this.screen_geometry );
} else {
// Start in the primary monitor
monitor_num = screen.get_primary_monitor();
screen.get_monitor_geometry( monitor_num, out this.screen_geometry );
}
} else { // Start in default screen
if ( monitor_num >= 0 ) {
// Start in the given monitor
screen = Screen.get_default();
screen.get_monitor_geometry( monitor_num, out this.screen_geometry );
} else {
// Start in the monitor the cursor is in
int pointerx, pointery;
display.get_pointer(out screen, out pointerx, out pointery, null);
monitor_num = screen.get_monitor_at_point(pointerx, pointery);
screen.get_monitor_geometry( monitor_num, out this.screen_geometry );
}
}
this.set_screen(screen);
this.screen_num = screen_num;
this.monitor_num = monitor_num;

if ( !Options.windowed ) {
// Move to the correct monitor
Expand Down
4 changes: 2 additions & 2 deletions src/classes/window/presentation.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace pdfpc.Window {
/**
* Base constructor instantiating a new presentation window
*/
public Presentation( Metadata.Pdf metadata, int screen_num, PresentationController presentation_controller ) {
base( screen_num );
public Presentation( Metadata.Pdf metadata, int screen_num, int monitor_num, PresentationController presentation_controller ) {
base( screen_num, monitor_num );
this.role = "presentation";

this.destroy.connect( (source) => {
Expand Down
4 changes: 2 additions & 2 deletions src/classes/window/presenter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ namespace pdfpc.Window {
/**
* Base constructor instantiating a new presenter window
*/
public Presenter( Metadata.Pdf metadata, int screen_num, PresentationController presentation_controller ) {
base( screen_num );
public Presenter( Metadata.Pdf metadata, int screen_num, int monitor_num, PresentationController presentation_controller ) {
base( screen_num, monitor_num );
this.role = "presenter";

this.destroy.connect( (source) => {
Expand Down
58 changes: 52 additions & 6 deletions src/pdfpc.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace pdfpc {
{ "list-actions", 'L', 0, 0, ref Options.list_actions, "List actions supported in the config file(s)", null},
{ "windowed", 'w', 0, 0, ref Options.windowed, "Run in windowed mode (devel tool)", null},
{ "notes", 'n', 0, OptionArg.STRING, ref Options.notes_position, "Position of notes on the pdf page (either left, right, top or bottom)", "P"},
{ "other-screen", 'O', 0, OptionArg.STRING, ref Options.other_screen, "Other screen[/monitor] to use", "P"},
{ null }
};

Expand Down Expand Up @@ -108,8 +109,8 @@ namespace pdfpc {
* Create and return a PresenterWindow using the specified monitor
* while displaying the given file
*/
private Window.Presenter create_presenter_window( Metadata.Pdf metadata, int monitor ) {
var presenter_window = new Window.Presenter( metadata, monitor, this.controller );
private Window.Presenter create_presenter_window( Metadata.Pdf metadata, int monitor, int screen = -1 ) {
var presenter_window = new Window.Presenter( metadata, screen, monitor, this.controller );
//controller.register_controllable( presenter_window );
presenter_window.set_cache_observer( this.cache_status );

Expand All @@ -120,8 +121,8 @@ namespace pdfpc {
* Create and return a PresentationWindow using the specified monitor
* while displaying the given file
*/
private Window.Presentation create_presentation_window( Metadata.Pdf metadata, int monitor ) {
var presentation_window = new Window.Presentation( metadata, monitor, this.controller );
private Window.Presentation create_presentation_window( Metadata.Pdf metadata, int monitor, int screen = -1 ) {
var presentation_window = new Window.Presentation( metadata, screen, monitor, this.controller );
//controller.register_controllable( presentation_window );
presentation_window.set_cache_observer( this.cache_status );

Expand Down Expand Up @@ -179,8 +180,53 @@ namespace pdfpc {
configFileReader.readConfig(etc_path + "/pdfpcrc");
configFileReader.readConfig(Environment.get_home_dir() + "/.pdfpcrc");

var screen = Gdk.Screen.get_default();
if ( !Options.windowed && !Options.single_screen && screen.get_n_monitors() > 1 ) {
Gdk.Screen screen = Gdk.Screen.get_default();
Gdk.Screen? other_screen = null;

/* other screen can set screen and/or monitor */
var other_option = pdfpc.ScreenMonitorNum.from_string(Options.other_screen);
if (other_option.screen_num >= 0 || other_option.monitor_num >= 0) {
var display = screen.get_display();
if (other_option.screen_num >= display.get_n_screens()) {
other_option.screen_num = -1;
}
if (other_option.screen_num < 0) {
other_option.screen_num = screen.get_number();
}

other_screen = display.get_screen(other_option.screen_num);
if (other_screen != null) {
if (other_option.monitor_num >= other_screen.get_n_monitors()) {
other_option.monitor_num = -1;
}
if (other_option.monitor_num < 0) {
other_option.monitor_num = other_screen.get_primary_monitor();
}
if (other_option.monitor_num < 0) {
other_screen = null;
}
}
}

if ( !Options.windowed && !Options.single_screen && other_screen != null ) {
int presenter_screen, presentation_screen;
int presenter_monitor, presentation_monitor;
if ( Options.display_switch != true ) {
presenter_screen = screen.get_number();
presenter_monitor = screen.get_primary_monitor();
presentation_screen = other_screen.get_number();
presentation_monitor = other_option.monitor_num;
} else {
presenter_screen = other_screen.get_number();
presenter_monitor = other_option.monitor_num;
presentation_screen = screen.get_number();
presentation_monitor = screen.get_primary_monitor();
}
this.presenter_window =
this.create_presenter_window( metadata, presenter_monitor, presenter_screen );
this.presentation_window =
this.create_presentation_window( metadata, presentation_monitor, presentation_screen );
} else if ( !Options.windowed && !Options.single_screen && screen.get_n_monitors() > 1 ) {
int presenter_monitor, presentation_monitor;
if ( Options.display_switch != true )
presenter_monitor = screen.get_primary_monitor();
Expand Down