Click here if you are having trouble viewing the slideshow on a mobile device.

HAYWARD — East Bay Rep. Eric Swalwell’s plan to ban assault weapons and force owners to sell their firearms back to the government may not have helped his short-lived presidential campaign gain traction.

But in the wake of the back-to-back mass shootings in El Paso and Dayton last weekend, as well as the Gilroy Garlic Festival shooting a week earlier, the idea of a mandatory assault weapons buyback is starting to catch on among other presidential contenders and gun-control activists.

Three White House hopefuls — former Vice President Joe Biden, Sen. Bernie Sanders and former Texas Rep. Beto O’Rourke — have supported or said they’d be open to a national buyback. It’s a sign of how the carnage over the past week has spurred candidates to propose farther-reaching and more ambitious gun-control policies than the party’s mainstream has embraced in the past.

“A ban would leave 15 million (assault weapons) in our community, so I don’t think that really protects us,” Swalwell, who dropped out of the presidential race last month, said before a town hall on gun violence Wednesday at Hayward City Hall. “The buyback is the hard part politically, but I think that’s what it’s ultimately going to take. … I’m going to continue to insist that those running for president sign onto that.”

A buyback program would declare possession of certain assault weapons illegal and require owners to sell them to the federal government for fair market value. Those who refuse would be criminally prosecuted.

It’s nearly impossible to imagine a mandatory buyback policy passing the Republican-held Senate or getting support from President Trump, who on Wednesday ruled out an assault weapons ban. Less far-reaching options such as a red flag law, which would allow courts to temporarily take guns from people deemed to be a danger to themselves or others, have found some backing among GOP officials.

But academics say a buyback could be the most effective way to reduce the national arsenal of assault weapons that have been used again and again in recent mass shootings. The plan would take a page from Australia, which passed a similar ban-and-buyback measure after a massacre in Tasmania in 1996, taking more than 660,000 firearms off its streets. Now, Australia sees far lower rates of gun violence than the U.S.

“If you really want to deal with the problem, you have to get rid of the assault weapons that are out there, and a gun buyback becomes probably the only way that can be achieved,” said John Donohue, a Stanford law professor who’s studied gun control and called Australia’s program “overwhelmingly successful.”

“There was a lot of opposition (among gun owners) when they first took that step, but now almost everyone in Australia realizes this was a good, good thing,” Donohue said.

Swalwell has estimated that it would cost $15 to $20 billion for the government to buy back 15 million assault weapons, which he suggested could be paid for by reducing defense spending.

Many politicians and gun-control activists have avoided such far-reaching policies in an effort to not allow gun-rights groups to say that they wanted to “confiscate” Americans’ guns. But that reluctance has started to fall away in the past few days, as reports of the dead and injured in Texas, Ohio and California filled front pages and newscasts.

O’Rourke, an El Paso native, said in an interview this weekend that he was “open” to a mandatory buyback because the U.S. needed to do everything possible “to prevent the kinds of tragedies that we saw.” It was a shift from a few months ago, when he had argued only for banning new sales going forward.

Sanders tweeted Sunday that “the federal government must ban assault weapons and implement a buyback program to get assault weapons off the streets.”

Several other candidates have said they’d support voluntary buybacks, including frontrunner Biden. When asked if a Biden administration would confiscate Americans’ guns, he said in a CNN interview, “Bingo! You’re right, if you have an assault weapon.”

And California Sen. Kamala Harris also has sounded open to a mandatory buyback, telling Swalwell in the first presidential debate, “I think your idea is a great one.”

A mandatory buyback would go further in restricting assault weapons than previous federal policies. The 1994 assault weapons ban, for example, only blocked the sale and possession of guns manufactured after it was enacted. It expired in 2004.

Gun-rights groups would be sure to vigorously fight the idea.

“The government cannot ‘buy back’ firearms it never owned in the first place,” said Brandon Combs, the president of the pro-gun rights California-based Firearms Policy Coalition. “The people of the United States would not comply with a total ban or submit their property for destruction. It’s just not going to happen. Politicians are talking about gun bans for attention and free media exposure just like mass killers do.”

A mandatory buyback also could face legal headwinds in the Supreme Court. Newly appointed justice Brett Kavanaugh, for example, wrote in a 2011 ruling that “there is no meaningful or persuasive constitutional distinction” between most handguns and semiautomatic rifles.

Caitlin King, a teacher and activist with the pro-gun control Moms Demand Action in Pacifica, said the debate over a buyback shouldn’t distract from efforts to pass laws such as universal background checks and red flag laws, which would reduce shootings and are likelier to make it through Congress.

“It makes sense to focus on the measures that will not only pass but save the most lives,” King said.

Still, she noted, more than 3,300 Californians have contacted her group to sign up since Saturday, a sign of how the tragedies had emboldened people to push for stronger action on gun control. Meanwhile, the National Rifle Association has been hobbled by financial difficulties and internal scandals.

“No idea is pie-in-the-sky to me anymore,” King said. “We’ve never been more powerful, and the NRA’s never been weaker.”

Swalwell argued that Harris, Sanders and the five other Democratic senators running for president should filibuster to demand background checks legislation when the Senate reconvenes.

“When they go back in session, they should stand until their legs give in and speak until their lungs give out,” he said. “That is what it’s going to take.”